mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-11 04:51:06 +00:00
Merge branch 'main' into fix/account-switch-task-running
This commit is contained in:
commit
596d876df4
2 changed files with 66 additions and 0 deletions
39
src/components/Dialog/CloseNotice.tsx
Normal file
39
src/components/Dialog/CloseNotice.tsx
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { useCallback } from "react";
|
||||
import { Button } from "../ui/button";
|
||||
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
trigger?: React.ReactNode;
|
||||
}
|
||||
export default function CloseNoticeDialog({open, onOpenChange, trigger}: Props) {
|
||||
|
||||
const onSubmit = useCallback(() => {
|
||||
window.electronAPI.closeWindow(true)
|
||||
}, [])
|
||||
|
||||
return <Dialog open={open} onOpenChange={onOpenChange}>
|
||||
{trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
|
||||
<DialogContent className="sm:max-w-[600px] p-0 !bg-popup-surface gap-0 !rounded-xl border border-zinc-300 shadow-sm">
|
||||
<DialogHeader className="!bg-popup-surface !rounded-t-xl p-md">
|
||||
<DialogTitle className="m-0">
|
||||
Close notice
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-md bg-popup-bg p-md">
|
||||
A task is currently running. Exiting will terminate it. Are you sure you want to exit?
|
||||
</div>
|
||||
<DialogFooter className="bg-white-100% !rounded-b-xl p-md">
|
||||
<DialogClose asChild>
|
||||
<Button variant="ghost" size="md">
|
||||
Cancel
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button size="md" onClick={onSubmit} variant="primary">
|
||||
Yes
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
}
|
||||
|
|
@ -6,10 +6,32 @@ import { useAuthStore } from "@/store/authStore";
|
|||
import { useEffect, useState } from "react";
|
||||
import { AnimationJson } from "@/components/AnimationJson";
|
||||
import animationData from "@/assets/animation/onboarding_success.json";
|
||||
import CloseNoticeDialog from "../Dialog/CloseNotice";
|
||||
import { useChatStore } from "@/store/chatStore";
|
||||
const Layout = () => {
|
||||
const { initState, setInitState, isFirstLaunch, setIsFirstLaunch } =
|
||||
useAuthStore();
|
||||
const [isInstalling, setIsInstalling] = useState(false);
|
||||
const [noticeOpen, setNoticeOpen] = useState(false);
|
||||
const chatStore = useChatStore();
|
||||
|
||||
useEffect(() => {
|
||||
const handleBeforeClose = () => {
|
||||
const currentStatus = chatStore.tasks[chatStore.activeTaskId as string]?.status;
|
||||
if(["pending", "running", "pause"].includes(currentStatus)) {
|
||||
setNoticeOpen(true);
|
||||
} else {
|
||||
window.electronAPI.closeWindow(true);
|
||||
}
|
||||
};
|
||||
|
||||
window.ipcRenderer.on("before-close", handleBeforeClose);
|
||||
|
||||
return () => {
|
||||
window.ipcRenderer.removeAllListeners("before-close");
|
||||
};
|
||||
}, [chatStore.tasks, chatStore.activeTaskId]);
|
||||
|
||||
useEffect(() => {
|
||||
const checkToolInstalled = async () => {
|
||||
// in render process
|
||||
|
|
@ -25,6 +47,7 @@ const Layout = () => {
|
|||
};
|
||||
checkToolInstalled();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
|
||||
|
|
@ -46,6 +69,10 @@ const Layout = () => {
|
|||
)}
|
||||
<Outlet />
|
||||
<HistorySidebar />
|
||||
<CloseNoticeDialog
|
||||
onOpenChange={setNoticeOpen}
|
||||
open={noticeOpen}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue