1. 用户管理页:新增启用状态列与启用/禁用操作按钮(对接 user/enable|disable) 2. 机构账号/记录查询页:时间区间改用官方 shadcn Range Picker 模式 (Popover+Calendar mode=range 双月面板,新增 components/date-range-picker.tsx) 3. 上传配置页:文件类型限制改为标签式输入(新增 suffix-tag-input.tsx, Badge标签+回车添加+常用后缀快捷点选),替换自由文本框 4. 修复:.env 的 VITE_APP_TITLE 加引号,规避 Bun 1.3.10 env 解析 对行尾多字节中文的截断(标题乱码"森睿智�") 5. 新增共享 hook hooks/use-user-status-actions.ts(从 org-account 迁出) 6. vite 代理保留 本地Docker(localhost:8080)/公司 两种目标,切换注释即可
128 lines
3.0 KiB
TypeScript
128 lines
3.0 KiB
TypeScript
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@/components/ui/dialog";
|
|
import {
|
|
FormField,
|
|
FormItem,
|
|
FormControl,
|
|
FormMessage,
|
|
Form,
|
|
} from "@/components/ui/form";
|
|
import { Input } from "@/components/ui/input";
|
|
import { useForm } from "react-hook-form";
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import { z } from "zod";
|
|
import { Spinner } from "@/components/ui/spinner";
|
|
import { useEffect } from "react";
|
|
import { useSaveFile } from "../-hooks/useSaveFile";
|
|
import { FileType } from "@/apis/file";
|
|
|
|
const formSchema = z.object({
|
|
fileName: z
|
|
.string()
|
|
.min(1, {
|
|
message: "目录至少1个字符",
|
|
})
|
|
.max(32, {
|
|
message: "目录最多32个字符",
|
|
})
|
|
.nonempty({
|
|
message: "目录不能为空",
|
|
}),
|
|
});
|
|
|
|
type EditFileDialogProps = {
|
|
open: boolean;
|
|
setOpen: (open: boolean) => void;
|
|
data?: any;
|
|
parentId?: number;
|
|
refetch?: () => void;
|
|
};
|
|
|
|
export function EditFileDialog({
|
|
open,
|
|
setOpen,
|
|
data,
|
|
parentId,
|
|
refetch,
|
|
}: EditFileDialogProps) {
|
|
const form = useForm<z.infer<typeof formSchema>>({
|
|
resolver: zodResolver(formSchema),
|
|
defaultValues: {
|
|
fileName: "",
|
|
},
|
|
});
|
|
|
|
const { save, saveIsPending } = useSaveFile({
|
|
onSuccess: () => {
|
|
refetch?.();
|
|
setOpen(false);
|
|
},
|
|
});
|
|
|
|
const onSubmit = (values: z.infer<typeof formSchema>) => {
|
|
save({
|
|
...(data || {}),
|
|
...values,
|
|
parentId,
|
|
});
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (open) {
|
|
form.reset({ fileName: data?.fileName || "" });
|
|
}
|
|
}, [open, data]);
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
<DialogContent className="w-[400px]">
|
|
<DialogHeader>
|
|
<DialogTitle>
|
|
{data?.fileType === FileType.DIRECTORY && !data?.id
|
|
? "创建目录"
|
|
: "重命名"}
|
|
</DialogTitle>
|
|
</DialogHeader>
|
|
<Form {...form}>
|
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
|
<FormField
|
|
control={form.control}
|
|
name="fileName"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
placeholder={
|
|
data?.fileType === FileType.DIRECTORY
|
|
? "请输入目录名"
|
|
: "请输入文件名"
|
|
}
|
|
{...field}
|
|
/>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button variant="outline">取消</Button>
|
|
</DialogClose>
|
|
<Button type="submit" disabled={saveIsPending}>
|
|
{saveIsPending && <Spinner />}确定
|
|
</Button>
|
|
</DialogFooter>
|
|
</form>
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|