From 0f093b2ef9d2a595be860a0b501987c03f56bf56 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Thu, 27 Mar 2025 21:28:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(PlatForm):=20=E9=87=8D=E6=9E=84=20Plat?= =?UTF-8?q?Form=20=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=87=8D=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 `usePlatForm` 钩子函数从 `src/common/usePlatform.ts` 迁移到 `src/common/event/PlatForm/hook.ts`,并简化其返回结构。同时在 `PlatForm` 类中添加 `reload` 方法,并在导航栏组件中新增重载菜单项。 --- src/common/event/PlatForm/hook.ts | 5 +++++ src/common/event/PlatForm/index.ts | 4 ++++ src/common/usePlatform.ts | 9 --------- src/renderer/src/components/NavBar.vue | 10 ++++++++-- 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/common/event/PlatForm/hook.ts delete mode 100644 src/common/usePlatform.ts diff --git a/src/common/event/PlatForm/hook.ts b/src/common/event/PlatForm/hook.ts new file mode 100644 index 0000000..0ebe033 --- /dev/null +++ b/src/common/event/PlatForm/hook.ts @@ -0,0 +1,5 @@ +import { PlatForm } from "." + +export function usePlatForm() { + return PlatForm.getInstance() +} diff --git a/src/common/event/PlatForm/index.ts b/src/common/event/PlatForm/index.ts index a94ba38..4393b90 100644 --- a/src/common/event/PlatForm/index.ts +++ b/src/common/event/PlatForm/index.ts @@ -22,6 +22,10 @@ class PlatForm extends _Base { return this.api.call("PlatFormCommand.fullscreen") } + async reload() { + return this.api.call("PlatFormCommand.reload") + } + async toggleDevTools() { return this.api.call("PlatFormCommand.toggleDevTools") } diff --git a/src/common/usePlatform.ts b/src/common/usePlatform.ts deleted file mode 100644 index 85f70ea..0000000 --- a/src/common/usePlatform.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PlatForm } from "./event/PlatForm" -import { Tabs } from "./event/Tabs" - -export function usePlatForm() { - return { - Tabs: Tabs.getInstance(), - PlatForm: PlatForm.getInstance(), - } -} diff --git a/src/renderer/src/components/NavBar.vue b/src/renderer/src/components/NavBar.vue index 78594bf..db0bc27 100644 --- a/src/renderer/src/components/NavBar.vue +++ b/src/renderer/src/components/NavBar.vue @@ -42,9 +42,9 @@ import icon from "@res/icon.png" import config from "config" import { PopupMenu } from "@/bridge/PopupMenu" - import { usePlatForm } from "common/usePlatform" + import { usePlatForm } from "common/event/PlatForm/hook" - const { PlatForm } = usePlatForm() + const PlatForm = usePlatForm() const router = useRouter() const route = useRoute() @@ -80,6 +80,12 @@ PlatForm.toggleDevTools() }, }, + { + label: "重载", + async click() { + PlatForm.reload() + }, + }, ]) const obj = e.target.getBoundingClientRect() menu.show({ x: ~~obj.x, y: ~~(obj.y + obj.height) })