Compare commits

...

3 Commits

Author SHA1 Message Date
npmrun fa6ef80493 Merge branch 'feat/优化' of ssh://git.xieyaxin.top:8892/topuser/electron-app into feat/优化 3 weeks ago
npmrun 0f093b2ef9 refactor(PlatForm): 重构 PlatForm 相关代码并添加重载功能 3 weeks ago
npmrun 28eea56a3d refactor(config): 导出 IDefaultConfig 接口以重用类型定义 3 weeks ago
  1. 2
      config/index.ts
  2. 5
      src/common/event/PlatForm/hook.ts
  3. 4
      src/common/event/PlatForm/index.ts
  4. 9
      src/common/usePlatform.ts
  5. 3
      src/main/modules/setting/index.ts
  6. 10
      src/renderer/src/components/NavBar.vue

2
config/index.ts

@ -6,7 +6,7 @@ type LanguageType = "zh" | "en"
type LogoType = "logo" | "bg" type LogoType = "logo" | "bg"
// 配置接口定义 // 配置接口定义
interface IDefaultConfig { export interface IDefaultConfig {
language: LanguageType language: LanguageType
"common.theme": ThemeType "common.theme": ThemeType
"desktop:wallpaper": string "desktop:wallpaper": string

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") return this.api.call("PlatFormCommand.fullscreen")
} }
async reload() {
return this.api.call("PlatFormCommand.reload")
}
async toggleDevTools() { async toggleDevTools() {
return this.api.call("PlatFormCommand.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>(),
}
}

3
src/main/modules/setting/index.ts

@ -4,12 +4,13 @@ import path from "path"
import { cloneDeep } from "lodash" import { cloneDeep } from "lodash"
import { injectable } from "inversify" import { injectable } from "inversify"
import Config from "config" import Config from "config"
import type { IDefaultConfig } from "config"
import _debug from "debug" import _debug from "debug"
import BaseClass from "main/base/base" import BaseClass from "main/base/base"
const debug = _debug("app:setting") const debug = _debug("app:setting")
type IConfig = typeof Config.default_config type IConfig = IDefaultConfig
type IOnFunc = (n: IConfig, c: IConfig, keys?: (keyof IConfig)[]) => void type IOnFunc = (n: IConfig, c: IConfig, keys?: (keyof IConfig)[]) => void
type IT = (keyof IConfig)[] | keyof IConfig | "_" type IT = (keyof IConfig)[] | keyof IConfig | "_"

10
src/renderer/src/components/NavBar.vue

@ -42,9 +42,9 @@
import icon from "@res/icon.png" import icon from "@res/icon.png"
import config from "config" import config from "config"
import { PopupMenu } from "@/bridge/PopupMenu" 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 router = useRouter()
const route = useRoute() const route = useRoute()
@ -80,6 +80,12 @@
PlatForm.toggleDevTools() PlatForm.toggleDevTools()
}, },
}, },
{
label: "重载",
async click() {
PlatForm.reload()
},
},
]) ])
const obj = e.target.getBoundingClientRect() const obj = e.target.getBoundingClientRect()
menu.show({ x: ~~obj.x, y: ~~(obj.y + obj.height) }) menu.show({ x: ~~obj.x, y: ~~(obj.y + obj.height) })

Loading…
Cancel
Save