-
ChainChat
+
+
ChainChat
+
diff --git a/AI_React/src/components/TopBar.tsx b/AI_React/src/components/TopBar.tsx
index a10db9f..1844f7d 100644
--- a/AI_React/src/components/TopBar.tsx
+++ b/AI_React/src/components/TopBar.tsx
@@ -3,6 +3,7 @@ import { API } from "@/api";
import ChatModal from "@/components/ChatModal.tsx";
import { useChatStore } from "@/stores/chatStore";
import { useSystemStore } from "@/stores/systemStore.ts";
+import {useStatusStore} from "@/stores/useStatusStore.ts";
import { hiddenMiddle } from "@/utils/addressUtils";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -17,6 +18,7 @@ import {
useWriteContract,
} from "wagmi";
import { sepolia } from "wagmi/chains";
+import { Modal } from "antd";
const CONTRACT = import.meta.env.VITE_CONTRACT as `0x${string}`;
@@ -43,8 +45,7 @@ export default function TopBar() {
args: [address ?? "0x0000000000000000000000000000000000000000"],
query: { enabled: !!address, refetchInterval: 4000 },
});
- const [statusInfo, setStatusInfo] = useState<{ used?: number; daily_limit?: number } | null>(null);
-
+ const { statusInfo, setStatusInfo } = useStatusStore();
const chainOk = !isConnected || chainId === sepolia.id;
async function refreshStatus() {
@@ -60,7 +61,7 @@ export default function TopBar() {
}
async function doUnstake() {
- await API.unstakeFixed(writeContractAsync, publicClient);
+ await API.unStakeFixed(writeContractAsync, publicClient);
await refetch();
await refreshStatus();
}
@@ -90,9 +91,21 @@ export default function TopBar() {
};
const onDisconnect = () => {
- disconnect();
- clearAll();
- switchSession(sessions[0].id);
+
+
+ Modal.confirm({
+ title: `${t("sidebar.modalText.title")}`,
+ content: `${t("sidebar.modalText.content")}`,
+ okText: `${t("sidebar.modalText.ok")}`,
+ cancelText: `${t("sidebar.modalText.cancel")}`,
+ onOk: () => {
+ // 删除会话
+ disconnect();
+ clearAll();
+ switchSession(sessions[0].id);
+ },
+ });
+
};
return (
diff --git a/AI_React/src/language/modules/en.ts b/AI_React/src/language/modules/en.ts
index aa6b750..069001d 100644
--- a/AI_React/src/language/modules/en.ts
+++ b/AI_React/src/language/modules/en.ts
@@ -6,7 +6,17 @@ export default {
sidebar: {
newChat: "New Chat",
defaultChat: "Default Chat",
- placeholder: "Untitled Chat"
+ placeholder: "Untitled Chat",
+ switchDark: "Switch dark",
+ switchLight: "Switch light",
+ modalText: {
+ title: "Are you sure you want to delete this conversation?",
+ content: "Once deleted, it cannot be restored. Please operate with caution.",
+ logoutTitle: "Are you sure you want to exit?",
+ logoutTip: "The data will be cleared after exiting",
+ ok: "OK",
+ cancel: "cancel",
+ }
},
topBar: {
toggleSidebar: "Toggle Sidebar",
diff --git a/AI_React/src/language/modules/zh.ts b/AI_React/src/language/modules/zh.ts
index 6b394a9..876a877 100644
--- a/AI_React/src/language/modules/zh.ts
+++ b/AI_React/src/language/modules/zh.ts
@@ -6,7 +6,17 @@ export default {
sidebar: {
newChat: "新建会话",
defaultChat: "默认会话",
- placeholder: "未命名会话"
+ placeholder: "未命名会话",
+ switchDark: "切换到深色模式",
+ switchLight: "切换到浅色模式",
+ modalText: {
+ title: "确定要删除此会话吗?",
+ content: "删除后无法恢复,请谨慎操作。",
+ logoutTitle: "确定要退出吗?",
+ logoutTip: "退出后数据将被清空",
+ ok: "确定",
+ cancel: "取消",
+ }
},
topBar: {
toggleSidebar: "切换侧边栏",
diff --git a/AI_React/src/stores/useStatusStore.ts b/AI_React/src/stores/useStatusStore.ts
new file mode 100644
index 0000000..01b24a4
--- /dev/null
+++ b/AI_React/src/stores/useStatusStore.ts
@@ -0,0 +1,14 @@
+import { create } from "zustand";
+
+interface StatusState {
+ statusInfo: {
+ used?: number;
+ daily_limit?: number;
+ } | null;
+ setStatusInfo: (info: { used?: number; daily_limit?: number } | null) => void;
+}
+
+export const useStatusStore = create
((set) => ({
+ statusInfo: null,
+ setStatusInfo: (info) => set({ statusInfo: info }),
+}));