From 0fd727ec13933115898e1ac0322b028f0e1674a5 Mon Sep 17 00:00:00 2001 From: Tianpao Date: Sat, 27 Dec 2025 15:33:40 +0800 Subject: [PATCH] =?UTF-8?q?chore(AI):=E5=89=8D=E7=AB=AF=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/App.vue | 112 +++++----- front/src/component/Main.vue | 352 ++++++++++++++++++-------------- front/src/component/Setting.vue | 86 +++++--- 3 files changed, 309 insertions(+), 241 deletions(-) diff --git a/front/src/App.vue b/front/src/App.vue index 5a0a922..3bf807f 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -4,47 +4,46 @@ import { MenuProps, message } from 'ant-design-vue'; import { SettingOutlined, UserOutlined, WindowsOutlined } from '@ant-design/icons-vue'; import { useRouter } from 'vue-router'; import * as shell from '@tauri-apps/plugin-shell'; - import { invoke } from "@tauri-apps/api/core"; -async function contant() { - await invoke("open_url", { url: "https://space.bilibili.com/1728953419" }) + +// 打开作者B站空间 +async function openAuthorBilibili() { + await invoke("open_url", { url: "https://space.bilibili.com/1728953419" }); } -//屏蔽右键菜单 -document.oncontextmenu = function (event: any) { +// 屏蔽右键菜单(输入框和文本域除外) +document.oncontextmenu = (event: any) => { try { - var the = event.srcElement - if ( - !( - (the.tagName == 'INPUT' && the.type.toLowerCase() == 'text') || - the.tagName == 'TEXTAREA' - ) - ) { - return false - } - return true - } catch (e) { - return false + const target = event.srcElement; + const isInput = target.tagName === 'INPUT' && target.type.toLowerCase() === 'text'; + const isTextarea = target.tagName === 'TEXTAREA'; + return isInput || isTextarea; + } catch { + return false; } -} +}; -/* 启动后端 */ -message.loading("DeEarthX.Core启动中,此过程中请勿执行任何操作......").then(() => { - shell.Command.create("core").spawn().then(() => { - fetch("http://localhost:37019/", { method: "GET" }).catch((e) => { - router.push('/error') - }).then(() => { - message.success("DeEarthX.Core 启动成功") - }) - console.log(`DeEarthX V3 Core`) - }).catch((e) => { - console.log(e) - message.error("DeEarthX.Core 启动失败,请检查37019是否被占用!") - }) -}) const router = useRouter(); -const selectedKeys = ref(['main']); -const items: MenuProps['items'] = [ + +// 启动后端核心服务 +message.loading("DeEarthX.Core启动中,请勿操作...").then(() => { + shell.Command.create("core").spawn() + .then(() => { + // 检查后端服务是否成功启动 + fetch("http://localhost:37019/", { method: "GET" }) + .catch(() => router.push('/error')) + .then(() => message.success("DeEarthX.Core 启动成功")); + console.log("DeEarthX V3 Core"); + }) + .catch((error) => { + console.error(error); + message.error("DeEarthX.Core 启动失败,请检查37019端口是否被占用!"); + }); +}); + +// 导航菜单配置 +const selectedKeys = ref<(string | number)[]>(['main']); +const menuItems: MenuProps['items'] = [ { key: 'main', icon: h(WindowsOutlined), @@ -63,31 +62,26 @@ const items: MenuProps['items'] = [ label: '关于', title: '关于', } -] -const handleClick: MenuProps['onClick'] = (e) => { - switch (e.key) { - case 'main': - selectedKeys.value[0] = 'main'; - router.push('/'); - break; - case 'setting': - selectedKeys.value[0] = 'setting'; - router.push('/setting'); - break; - case 'about': - selectedKeys.value[0] = 'about'; - router.push('/about'); - break; - default: - break; - } -} +]; +// 菜单点击事件处理 +const handleMenuClick: MenuProps['onClick'] = (e) => { + selectedKeys.value[0] = e.key; + const routeMap: Record = { + main: '/', + setting: '/setting', + about: '/about' + }; + const route = routeMap[e.key] || '/'; + router.push(route); +}; + +// 主题配置 const theme = ref({ - "token": { - "colorPrimary": "#67eac3", + token: { + colorPrimary: '#67eac3', } -}) +});