mirror of
https://github.com/coaidev/coai.git
synced 2025-06-07 22:30:17 +09:00
feat: add refresh button in mask dialog
This commit is contained in:
parent
f5b31d3283
commit
1b28b22fc3
@ -10,7 +10,12 @@ type ListMaskResponse = CommonResponse & {
|
|||||||
export async function listMasks(): Promise<ListMaskResponse> {
|
export async function listMasks(): Promise<ListMaskResponse> {
|
||||||
try {
|
try {
|
||||||
const resp = await axios.get("/conversation/mask/view");
|
const resp = await axios.get("/conversation/mask/view");
|
||||||
return resp.data;
|
return (
|
||||||
|
resp.data ?? {
|
||||||
|
status: true,
|
||||||
|
data: [],
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
status: false,
|
status: false,
|
||||||
|
@ -30,6 +30,7 @@ import {
|
|||||||
MousePointerSquareDashed,
|
MousePointerSquareDashed,
|
||||||
Pencil,
|
Pencil,
|
||||||
Plus,
|
Plus,
|
||||||
|
RotateCw,
|
||||||
Search,
|
Search,
|
||||||
Trash,
|
Trash,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
@ -557,6 +558,7 @@ function searchMasks(search: string, masks: Mask[]): Mask[] {
|
|||||||
|
|
||||||
function MaskSelector() {
|
function MaskSelector() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const global = useDispatch();
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
const custom_masks = useSelector(selectCustomMasks);
|
const custom_masks = useSelector(selectCustomMasks);
|
||||||
@ -570,6 +572,8 @@ function MaskSelector() {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [selected, dispatch] = useReducer(reducer, { ...initialCustomMask });
|
const [selected, dispatch] = useReducer(reducer, { ...initialCustomMask });
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const event = (e: any) => {
|
const event = (e: any) => {
|
||||||
dispatch(e);
|
dispatch(e);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@ -583,25 +587,42 @@ function MaskSelector() {
|
|||||||
open={open}
|
open={open}
|
||||||
onOpenChange={setOpen}
|
onOpenChange={setOpen}
|
||||||
/>
|
/>
|
||||||
<div className={`mask-header`}>
|
<div
|
||||||
<Button variant={`outline`} size={`icon`} className={`shrink-0`}>
|
className={`mask-header-actions flex flex-row translate-y-[-0.5rem] mb-1`}
|
||||||
<Search className={`h-4 w-4`} />
|
>
|
||||||
</Button>
|
|
||||||
<Input
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
placeholder={t("mask.search")}
|
|
||||||
className={`mx-2`}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
size={`icon`}
|
|
||||||
className={`shrink-0`}
|
className={`shrink-0`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch({ type: "reset" });
|
dispatch({ type: "reset" });
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Plus className={`h-4 w-4`} />
|
<Plus className={`h-4 w-4 mr-1`} />
|
||||||
|
{t("mask.create")}
|
||||||
|
</Button>
|
||||||
|
<div className={`grow`} />
|
||||||
|
<Button
|
||||||
|
variant={`outline`}
|
||||||
|
size={`icon`}
|
||||||
|
className={`shrink-0`}
|
||||||
|
onClick={async () => {
|
||||||
|
setLoading(true);
|
||||||
|
await updateMasks(global);
|
||||||
|
setLoading(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RotateCw className={cn(`h-4 w-4`, loading && "animate-spin")} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className={`mask-header`}>
|
||||||
|
<Input
|
||||||
|
value={search}
|
||||||
|
onChange={(e) => setSearch(e.target.value)}
|
||||||
|
placeholder={t("mask.search")}
|
||||||
|
className={`mr-2`}
|
||||||
|
/>
|
||||||
|
<Button variant={`outline`} size={`icon`} className={`shrink-0`}>
|
||||||
|
<Search className={`h-4 w-4`} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@
|
|||||||
"dashboard": "仪表盘",
|
"dashboard": "仪表盘",
|
||||||
"users": "后台管理",
|
"users": "后台管理",
|
||||||
"user": "用户管理",
|
"user": "用户管理",
|
||||||
"broadcast": "公告通知",
|
"broadcast": "通知管理",
|
||||||
"channel": "渠道设置",
|
"channel": "渠道设置",
|
||||||
"settings": "系统设置",
|
"settings": "系统设置",
|
||||||
"prize": "价格设定",
|
"prize": "价格设定",
|
||||||
|
Loading…
Reference in New Issue
Block a user