Browse Source

feat

feat/icon
npmrun 3 weeks ago
parent
commit
2d5a57853d
  1. 6
      electron.vite.config.ts
  2. 6
      packages/locales/index.ts
  3. 3
      packages/locales/languages/en.json
  4. 3
      packages/locales/languages/zh.json
  5. 25
      src/common/event/PlatForm/index.ts
  6. 2
      src/common/event/Tabs/index.ts
  7. 4
      src/common/event/common.ts
  8. 2
      src/common/event/update/index.ts
  9. 6
      src/common/event/update/main.ts
  10. 0
      src/common/lib/_Base.ts
  11. 4
      src/common/usePlatform.ts
  12. 2
      src/renderer/auto-imports.d.ts
  13. 13
      src/renderer/src/components/NavBar.vue
  14. 17
      src/renderer/src/platform/PlatForm.ts
  15. 67
      tsconfig.node.json
  16. 91
      tsconfig.web.json

6
electron.vite.config.ts

@ -18,7 +18,7 @@ export default defineConfig({
alias: {
config: resolve("config"),
main: resolve("src/main"),
"common": resolve("src/common"),
common: resolve("src/common"),
"@res": resolve("resources"),
},
},
@ -32,7 +32,7 @@ export default defineConfig({
resolve: {
alias: {
config: resolve("config"),
"common": resolve("src/common"),
common: resolve("src/common"),
"@": resolve("src/renderer/src"),
"@res": resolve("resources"),
},
@ -41,7 +41,7 @@ export default defineConfig({
preprocessorOptions: {
scss: {
additionalData: `@use "@/assets/style/global" as *;\n`,
api: "modern-compiler"
api: "modern-compiler",
},
},
},

6
packages/locales/index.ts

@ -1,3 +1,9 @@
if (import.meta.env.DEV) {
// 引入之后可以热更新
import("./languages/zh.json")
import("./languages/en.json")
}
const datetimeFormats = {
en: {
short: {

3
packages/locales/languages/en.json

@ -73,5 +73,6 @@
},
"qie-huan-kai-fa-zhe-gong-ju": "ToggleDevtool",
"qu-xiao-quan-ping": "Canel FullScreen",
"quan-ping": "FullScreen"
"quan-ping": "FullScreen",
"caidan": "Menu"
}

3
packages/locales/languages/zh.json

@ -72,5 +72,6 @@
},
"qie-huan-kai-fa-zhe-gong-ju": "切换开发者工具",
"qu-xiao-quan-ping": "取消全屏",
"quan-ping": "全屏"
"quan-ping": "全屏",
"caidan": "菜单"
}

25
src/common/event/PlatForm/index.ts

@ -0,0 +1,25 @@
import { _Base } from "common/lib/_Base"
class PlatForm extends _Base {
constructor() {
super()
}
async showAbout() {
return await fetch("api://fuck/BasicService/showAbout")
}
async isFullScreen() {
return await api.call("BasicCommand.isFullscreen")
}
async toggleFullScreen() {
return api.call("BasicCommand.fullscreen")
}
async toggleDevTools() {
return api.call("BasicCommand.toggleDevTools")
}
}
export { PlatForm }

2
src/renderer/src/platform/Tabs.ts → src/common/event/Tabs/index.ts

@ -1,4 +1,4 @@
import { _Base } from "./_Base"
import { _Base } from "../../lib/_Base"
export class Tabs extends _Base {
constructor() {

4
src/common/event/update/common.ts → src/common/event/common.ts

@ -2,6 +2,4 @@ const keys = ["progress"] as const
type AllKeys = (typeof keys)[number]
export type{
AllKeys
}
export type { AllKeys }

2
src/common/event/update/renderer.ts → src/common/event/update/index.ts

@ -1,4 +1,4 @@
import type { AllKeys } from "./common"
import type { AllKeys } from "../common"
const curProgress = ref(0)
api.on<AllKeys>("progress", () => {

6
src/common/event/update/main.ts

@ -1,10 +1,8 @@
import { broadcast } from "main/utils"
import { AllKeys } from "./common"
import { AllKeys } from "../common"
function emitProgress(...argu) {
broadcast<AllKeys>("progress", ...argu)
}
export {
emitProgress
}
export { emitProgress }

0
src/renderer/src/platform/_Base.ts → src/common/lib/_Base.ts

4
src/renderer/src/composables/usePlatform.ts → src/common/usePlatform.ts

@ -1,5 +1,5 @@
import { PlatForm } from "@/platform/PlatForm"
import { Tabs } from "@/platform/Tabs"
import { PlatForm } from "./event/PlatForm"
import { Tabs } from "./event/Tabs"
export function usePlatForm() {
return {

2
src/renderer/auto-imports.d.ts

@ -212,7 +212,6 @@ declare global {
const useParentElement: typeof import('@vueuse/core')['useParentElement']
const usePerformanceObserver: typeof import('@vueuse/core')['usePerformanceObserver']
const usePermission: typeof import('@vueuse/core')['usePermission']
const usePlatForm: typeof import('./src/composables/usePlatform')['usePlatForm']
const usePointer: typeof import('@vueuse/core')['usePointer']
const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe']
@ -514,7 +513,6 @@ declare module 'vue' {
readonly useParentElement: UnwrapRef<typeof import('@vueuse/core')['useParentElement']>
readonly usePerformanceObserver: UnwrapRef<typeof import('@vueuse/core')['usePerformanceObserver']>
readonly usePermission: UnwrapRef<typeof import('@vueuse/core')['usePermission']>
readonly usePlatForm: UnwrapRef<typeof import('./src/composables/usePlatform')['usePlatForm']>
readonly usePointer: UnwrapRef<typeof import('@vueuse/core')['usePointer']>
readonly usePointerLock: UnwrapRef<typeof import('@vueuse/core')['usePointerLock']>
readonly usePointerSwipe: UnwrapRef<typeof import('@vueuse/core')['usePointerSwipe']>

13
src/renderer/src/components/NavBar.vue

@ -15,7 +15,7 @@
<img w="16px" h="16px" :src="icon" />
<div relative h-full inline-flex items-center text-sm>{{ config.app_title }}</div>
<div relative class="list">
<div class="item" @click="onClickMenu">菜单</div>
<div class="item" @click="onClickMenu">{{ t("caidan") }}</div>
</div>
</div>
<div float-right h-full flex items-center relative style="-webkit-app-region: no-drag">
@ -42,19 +42,20 @@
import icon from "@res/icon.png"
import config from "config"
import { PopupMenu } from "@/bridge/PopupMenu"
import { usePlatForm } from "common/usePlatform"
const { PlatForm } = usePlatForm()
const router = useRouter()
const route = useRoute()
const isFullScreen = ref(false)
onBeforeMount(async () => {
isFullScreen.value = await api.call("BasicCommand.isFullscreen")
isFullScreen.value = await PlatForm.isFullScreen()
})
const { PlatForm } = usePlatForm()
const isHome = computed(() => {
if (route?.meta?.home) {
if (route.fullPath === "/") {
return true
}
return false
@ -85,7 +86,7 @@ const onClickMenu = e => {
}
const onClickAbout = () => {
fetch("api://fuck/BasicService/showAbout")
PlatForm.showAbout()
}
</script>

17
src/renderer/src/platform/PlatForm.ts

@ -1,17 +0,0 @@
import { _Base } from "./_Base"
class PlatForm extends _Base {
constructor() {
super()
}
toggleFullScreen() {
return api.call("BasicCommand.fullscreen")
}
toggleDevTools() {
return api.call("BasicCommand.toggleDevTools")
}
}
export { PlatForm }

67
tsconfig.node.json

@ -1,22 +1,51 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": ["electron.vite.config.*", "src/main/**/*", "src/preload/**/*", "config/**/*", "src/types/**/*", "packages/locales/main.ts",
"src/common/**/*.main.ts", "src/common/**/main.ts", "src/common/**/*.common.ts", "src/common/**/common.ts"],
"compilerOptions": {
"composite": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"types": ["electron-vite/node", "reflect-metadata",],
"baseUrl": ".",
"paths": {
"#": ["src/types/index"],
"#/*": ["src/types/*"],
"config": ["config/index.ts"],
"config/*": ["config/*"],
"main/*": ["src/main/*"],
"common/*": ["src/common/*"],
"@res/*": ["resources/*"],
"locales/*": ["packages/locales/*"],
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": [
"electron.vite.config.*",
"src/main/**/*",
"src/preload/**/*",
"config/**/*",
"src/types/**/*",
"packages/locales/main.ts",
"src/common/**/*.main.ts",
"src/common/**/main.ts",
"src/common/**/*.common.ts",
"src/common/**/common.ts"
, "src/common/event/_Base.ts" ],
"compilerOptions": {
"composite": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"types": [
"electron-vite/node",
"reflect-metadata",
],
"baseUrl": ".",
"paths": {
"#": [
"src/types/index"
],
"#/*": [
"src/types/*"
],
"config": [
"config/index.ts"
],
"config/*": [
"config/*"
],
"main/*": [
"src/main/*"
],
"common/*": [
"src/common/*"
],
"@res/*": [
"resources/*"
],
"locales/*": [
"packages/locales/*"
],
}
}
}
}

91
tsconfig.web.json

@ -1,39 +1,56 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": [
"src/renderer/auto-imports.d.ts",
"src/renderer/components.d.ts",
"src/renderer/src/env.d.ts",
"src/renderer/src/**/*",
"src/renderer/src/**/*.vue",
"src/preload/*.d.ts",
"src/types/**/*",
"config/**/*",
"./typed-router.d.ts",
"src/common/**/*.renderer.ts",
"src/common/**/renderer.ts",
"src/common/**/*.common.ts", "src/common/**/common.ts",
],
"vueCompilerOptions": {
"plugins": ["unplugin-vue-macros/volar"],
},
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"moduleResolution": "Bundler",
"types": ["unplugin-vue-macros/macros-global", "vite-plugin-vue-layouts/client"],
"paths": {
"#": ["src/types/index"],
"#/*": ["src/types/*"],
"config": ["config/index.ts"],
"config/*": ["config/*"],
"common/*": ["src/common/*"],
"@/*": [
"src/renderer/src/*"
],
"@res/*": [
"resources/*"
],
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": [
"src/renderer/auto-imports.d.ts",
"src/renderer/components.d.ts",
"src/renderer/src/env.d.ts",
"src/renderer/src/**/*",
"src/renderer/src/**/*.vue",
"src/preload/*.d.ts",
"src/types/**/*",
"config/**/*",
"./typed-router.d.ts",
"src/common/**/*"
],
"exclude": [
"src/common/**/*.main.ts",
"src/common/**/main.ts"
],
"vueCompilerOptions": {
"plugins": [
"unplugin-vue-macros/volar"
],
},
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"moduleResolution": "Bundler",
"types": [
"unplugin-vue-macros/macros-global",
"vite-plugin-vue-layouts/client"
],
"paths": {
"#": [
"src/types/index"
],
"#/*": [
"src/types/*"
],
"config": [
"config/index.ts"
],
"config/*": [
"config/*"
],
"common/*": [
"src/common/*"
],
"@/*": [
"src/renderer/src/*"
],
"@res/*": [
"resources/*"
],
}
}
}
}
}
Loading…
Cancel
Save