Browse Source

refactor(PlatForm): 重构 PlatForm 相关代码并添加重载功能

将 `usePlatForm` 钩子函数从 `src/common/usePlatform.ts` 迁移到 `src/common/event/PlatForm/hook.ts`,并简化其返回结构。同时在 `PlatForm` 类中添加 `reload` 方法,并在导航栏组件中新增重载菜单项。
feat/icon
npmrun 2 weeks ago
parent
commit
0f093b2ef9
  1. 5
      src/common/event/PlatForm/hook.ts
  2. 4
      src/common/event/PlatForm/index.ts
  3. 9
      src/common/usePlatform.ts
  4. 10
      src/renderer/src/components/NavBar.vue

5
src/common/event/PlatForm/hook.ts

@ -0,0 +1,5 @@
import { PlatForm } from "."
export function usePlatForm() {
return PlatForm.getInstance<PlatForm>()
}

4
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")
}

9
src/common/usePlatform.ts

@ -1,9 +0,0 @@
import { PlatForm } from "./event/PlatForm"
import { Tabs } from "./event/Tabs"
export function usePlatForm() {
return {
Tabs: Tabs.getInstance<Tabs>(),
PlatForm: PlatForm.getInstance<PlatForm>(),
}
}

10
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) })

Loading…
Cancel
Save