This commit is contained in:
sijinhui 2024-05-14 17:28:09 +08:00
parent cb62fa7634
commit ebbf9e4f7c
2 changed files with 35 additions and 1 deletions

View File

@ -78,6 +78,7 @@ import {
List, List,
ListItem, ListItem,
Modal, Modal,
ModalSelector,
Selector, Selector,
showConfirm, showConfirm,
showPrompt, showPrompt,
@ -606,7 +607,7 @@ export function ChatActions(props: {
{/*/>*/} {/*/>*/}
{showModelSelector && ( {showModelSelector && (
<Selector <ModalSelector
defaultSelectedValue={currentModel} defaultSelectedValue={currentModel}
items={models.map((m) => ({ items={models.map((m) => ({
title: m.displayName, title: m.displayName,

View File

@ -15,6 +15,7 @@ import Locale from "../locales";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import React, { HTMLProps, useEffect, useState } from "react"; import React, { HTMLProps, useEffect, useState } from "react";
import { IconButton } from "./button"; import { IconButton } from "./button";
import { Card as AntCard, List as AntList, Row, Col, Grid } from "antd";
export function Popover(props: { export function Popover(props: {
children: JSX.Element; children: JSX.Element;
@ -485,3 +486,35 @@ export function Selector<T>(props: {
</div> </div>
); );
} }
export function ModalSelector<T>(props: {
items: Array<{
title: string;
subTitle?: string;
value: T;
}>;
defaultSelectedValue?: T;
onSelection?: (selection: T[]) => void;
onClose?: () => void;
multiple?: boolean;
}) {
console.log("-----", props);
return (
<div className={styles["selector"]}>
<Modal title="test" onClose={() => props.onClose?.()}>
<AntList grid={{ gutter: 16, column: 4 }}>
<Col span={8}>
<AntList.Item>
<AntCard title="你好">Card</AntCard>
</AntList.Item>
</Col>
<AntList.Item>
<AntCard title="你好">Card</AntCard>
</AntList.Item>
</AntList>
</Modal>
</div>
);
}