Skip to content

Commit f511a8a

Browse files
committed
✨ 继续完善新版ui
1 parent 12ee2c3 commit f511a8a

File tree

24 files changed

+366
-1021
lines changed

24 files changed

+366
-1021
lines changed

app/src/components/ui/dialog.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { SubWindow } from "@/core/service/SubWindow";
99
import { cn } from "@/utils/cn";
1010
import { Vector } from "@graphif/data-structures";
1111
import { Rectangle } from "@graphif/shapes";
12+
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
13+
import { toast } from "sonner";
1214

1315
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
1416
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
@@ -277,6 +279,55 @@ Dialog.buttons = <
277279
});
278280
};
279281

282+
Dialog.copy = (title = "导出成功", description = "", value = ""): Promise<void> => {
283+
return new Promise((resolve) => {
284+
function Component({ winId }: { winId?: string }) {
285+
const [open, setOpen] = React.useState(true);
286+
287+
return (
288+
<Dialog open={open}>
289+
<DialogContent>
290+
<DialogHeader>
291+
<DialogTitle>{title}</DialogTitle>
292+
<DialogDescription>{description}</DialogDescription>
293+
<Textarea value={value} />
294+
<DialogFooter>
295+
<Button
296+
variant="outline"
297+
onClick={async () => {
298+
await writeText(value);
299+
toast.success("已复制到剪贴板");
300+
}}
301+
>
302+
复制
303+
</Button>
304+
<Button
305+
onClick={() => {
306+
resolve();
307+
setOpen(false);
308+
setTimeout(() => {
309+
SubWindow.close(winId!);
310+
}, 500);
311+
}}
312+
>
313+
确定
314+
</Button>
315+
</DialogFooter>
316+
</DialogHeader>
317+
</DialogContent>
318+
</Dialog>
319+
);
320+
}
321+
322+
SubWindow.create({
323+
titleBarOverlay: true,
324+
closable: false,
325+
rect: new Rectangle(Vector.same(100), Vector.same(-1)),
326+
children: <Component />,
327+
});
328+
});
329+
};
330+
280331
export {
281332
Dialog,
282333
DialogClose,

app/src/core/Project.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ declare module "./Project" {
387387
controller: Controller;
388388
stageExport: StageExport;
389389
stageExportPng: StageExportPng;
390-
StageExportSvg: StageExportSvg;
390+
stageExportSvg: StageExportSvg;
391391
generateFromFolder: GenerateFromFolder;
392392
serializedDataAdder: SerializedDataAdder;
393393
keyBindsRegistrar: KeyBindsRegistrar;

0 commit comments

Comments
 (0)