diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 529acc3..e7b246c 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -95,6 +95,9 @@ export default defineConfig({ "@vueuse/core", VueRouterAutoImports, { + "vue3-toastify": ["toast"], + }, + { // add any other imports you were relying on "vue-router/auto": ["useLink"], }, diff --git a/package.json b/package.json index 2beb1fd..d2441a1 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "vue": "^3.5.13", "vue-i18n": "^11.1.1", "vue-router": "^4.5.0", - "vue-tsc": "^2.1.10" + "vue-tsc": "^2.1.10", + "vue3-toastify": "^0.2.8" } } diff --git a/packages/setting/common.ts b/packages/setting/common.ts new file mode 100644 index 0000000..884d5ff --- /dev/null +++ b/packages/setting/common.ts @@ -0,0 +1,7 @@ +import type { IOnFunc } from "setting/main" + +export type EventMaps = { + init: IOnFunc + update: IOnFunc + change: (key: string, value: any) => void +} diff --git a/packages/setting/main.ts b/packages/setting/main.ts index 875a667..55ddf46 100644 --- a/packages/setting/main.ts +++ b/packages/setting/main.ts @@ -62,6 +62,7 @@ class SettingClass { this.init() } + events = emitter #cb: [IT, IOnFunc][] = [] onChange(fn: IOnFunc, that?: any) @@ -138,7 +139,7 @@ class SettingClass { this.#sync() } init.call(this, this.#config) - emitter.emit("update", this.#config, this.#config) + this.events.emit("update", this.#config, this.#config) } config() { return this.#config @@ -217,7 +218,11 @@ class SettingClass { if (isChange) { this.#sync() this.#runCB(this.#config, oldMainConfig, changeKeys) - emitter.emit("update", this.#config, oldMainConfig, changeKeys) + this.events.emit("update", this.#config, oldMainConfig, changeKeys) + for (let i = 0; i < changeKeys.length; i++) { + const k = changeKeys[i] + this.events.emit("change", k, this.#config[k]) + } } } values(key: T): IConfig[T] { diff --git a/packages/setting/main/event.ts b/packages/setting/main/event.ts index 8bc297d..41fd457 100644 --- a/packages/setting/main/event.ts +++ b/packages/setting/main/event.ts @@ -1,7 +1,4 @@ import { buildEmitter } from "base/event/main" -import type { IOnFunc } from "setting/main" +import { EventMaps } from "setting/common" -export const emitter = buildEmitter<{ - init: IOnFunc - update: IOnFunc -}>() +export const emitter = buildEmitter() diff --git a/packages/utils/main/session/cookies.ts b/packages/utils/main/session/cookies.ts index 3088021..330b687 100644 --- a/packages/utils/main/session/cookies.ts +++ b/packages/utils/main/session/cookies.ts @@ -2,12 +2,12 @@ import { BrowserView, BrowserWindow } from "electron" const cookies = { getCurrCookies(params = {}, currWin: BrowserView | BrowserWindow) { - let currSession = currWin.webContents.session + const currSession = currWin.webContents.session return currSession.cookies.get(Object.assign({}, params)) }, removeCurrCookies(cookies = [], currWin: BrowserView | BrowserWindow) { - let currSession = currWin.webContents.session - let err = [] + const currSession = currWin.webContents.session + const err = [] let apiCount = 0 return new Promise((resove, reject) => { cookies.forEach(async (item: any) => { @@ -22,8 +22,8 @@ const cookies = { }) }, setCurrCookies(cookies = [], currWin: BrowserView | BrowserWindow) { - let currSession = currWin.webContents.session - let err = [] + const currSession = currWin.webContents.session + const err = [] let apiCount = 0 return new Promise((resove, reject) => { cookies.forEach(async (item: any) => { @@ -44,4 +44,4 @@ const cookies = { }, } -export default cookies \ No newline at end of file +export default cookies diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58b9c24..1a9f970 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -189,6 +189,9 @@ importers: vue-tsc: specifier: ^2.1.10 version: 2.1.10(typescript@5.7.3) + vue3-toastify: + specifier: ^0.2.8 + version: 0.2.8(vue@3.5.13(typescript@5.7.3)) packages/base: {} @@ -3712,6 +3715,15 @@ packages: peerDependencies: typescript: '>=5.0.0' + vue3-toastify@0.2.8: + resolution: {integrity: sha512-8jDOqsJaBZEbGpCbhWDETJc11D1lZefvgFPq/IPdM+U7+qyXoVPDvK6uq/FIgyV7qV0NcNzvGBMEzjsLQqGROw==} + engines: {node: '>=20', npm: '>=9.0.0'} + peerDependencies: + vue: '>=3.2.0' + peerDependenciesMeta: + vue: + optional: true + vue@3.5.13: resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==} peerDependencies: @@ -7755,6 +7767,10 @@ snapshots: semver: 7.6.3 typescript: 5.7.3 + vue3-toastify@0.2.8(vue@3.5.13(typescript@5.7.3)): + optionalDependencies: + vue: 3.5.13(typescript@5.7.3) + vue@3.5.13(typescript@5.7.3): dependencies: '@vue/compiler-dom': 3.5.13 diff --git a/src/main/command/Setting/command.ts b/src/main/command/Setting/command.ts index 6c9afd6..77df4a2 100644 --- a/src/main/command/Setting/command.ts +++ b/src/main/command/Setting/command.ts @@ -1,8 +1,12 @@ import Setting, { IConfig } from "setting/main" +import { broadcast } from "utils/main" export default class SettingCommand { static init() { - console.log("SettingCommand init") + Setting.events.on("change", (k, value) => { + console.log(k, value) + broadcast("SettingCommand.change", k, value) + }) } sync() { return Setting.config() diff --git a/src/main/command/Setting/type.d.ts b/src/main/command/Setting/type.d.ts new file mode 100644 index 0000000..d728145 --- /dev/null +++ b/src/main/command/Setting/type.d.ts @@ -0,0 +1,8 @@ +import type { EventMaps } from "setting/common" + +export interface SettingCommand { + save: () => void + reset: () => void +} + +export { EventMaps } diff --git a/src/main/command/Updater/command.ts b/src/main/command/Updater/command.ts index 277e33a..fe99803 100644 --- a/src/main/command/Updater/command.ts +++ b/src/main/command/Updater/command.ts @@ -9,7 +9,7 @@ export default class UpdaterCommand { // 命令初始化 logger.debug("UpdaterCommand init") Updater.events.on("*", (name, ...argus) => { - broadcast(name, ...argus) + broadcast("UpdaterCommand." + name, ...argus) }) } diff --git a/src/renderer/auto-imports.d.ts b/src/renderer/auto-imports.d.ts index 6249747..395fe51 100644 --- a/src/renderer/auto-imports.d.ts +++ b/src/renderer/auto-imports.d.ts @@ -101,6 +101,7 @@ declare global { const toRef: typeof import('vue')['toRef'] const toRefs: typeof import('vue')['toRefs'] const toValue: typeof import('vue')['toValue'] + const toast: typeof import('vue3-toastify')['toast'] const triggerRef: typeof import('vue')['triggerRef'] const tryOnBeforeMount: typeof import('@vueuse/core')['tryOnBeforeMount'] const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount'] @@ -405,6 +406,7 @@ declare module 'vue' { readonly toRef: UnwrapRef readonly toRefs: UnwrapRef readonly toValue: UnwrapRef + readonly toast: UnwrapRef readonly triggerRef: UnwrapRef readonly tryOnBeforeMount: UnwrapRef readonly tryOnBeforeUnmount: UnwrapRef diff --git a/src/renderer/components.d.ts b/src/renderer/components.d.ts index 00676e6..a584a5a 100644 --- a/src/renderer/components.d.ts +++ b/src/renderer/components.d.ts @@ -12,6 +12,8 @@ declare module 'vue' { CodeEditor: typeof import('./src/components/CodeEditor/code-editor.vue')['default'] 'IconBxs:error': typeof import('~icons/bxs/error')['default'] 'IconGrommetIcons:update': typeof import('~icons/grommet-icons/update')['default'] + 'IconIx:reset': typeof import('~icons/ix/reset')['default'] + 'IconMaterialSymbols:save': typeof import('~icons/material-symbols/save')['default'] 'IconStash:arrowReplyDuotone': typeof import('~icons/stash/arrow-reply-duotone')['default'] NavBar: typeof import('./src/ui/NavBar.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 6ce5d66..114e57e 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -1,13 +1,24 @@ diff --git a/src/renderer/src/assets/style/_anim.scss b/src/renderer/src/assets/style/_anim.scss new file mode 100644 index 0000000..63d3b2c --- /dev/null +++ b/src/renderer/src/assets/style/_anim.scss @@ -0,0 +1,13 @@ + .slide-fade-enter-active { + transition: all 0.2s ease-out; + } + + .slide-fade-leave-active { + transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1); + } + + .slide-fade-enter-from, + .slide-fade-leave-to { + // transform: translateX(20px); + opacity: 0; + } \ No newline at end of file diff --git a/src/renderer/src/assets/style/_common.scss b/src/renderer/src/assets/style/_common.scss index 9765d4f..69b8d44 100644 --- a/src/renderer/src/assets/style/_common.scss +++ b/src/renderer/src/assets/style/_common.scss @@ -1,3 +1,5 @@ +@use "./_anim.scss"; + *, *::before, *::after { diff --git a/src/renderer/src/bridge/PopupMenu.ts b/src/renderer/src/bridge/PopupMenu.ts index 7d02c29..d4c7f24 100644 --- a/src/renderer/src/bridge/PopupMenu.ts +++ b/src/renderer/src/bridge/PopupMenu.ts @@ -15,14 +15,14 @@ export class PopupMenu { private _id: string private _items: IMenuItemOption[] private _offs: any[] = [] - private clickEvent: Function = ()=>{} + private clickEvent: (...args: any[]) => void = () => {} constructor(menu_items: IMenuItemOption[]) { this._id = `popup_menu_${Math.floor(Math.random() * 1e8)}` this._items = menu_items } - setClickEvent(fn: Function) { + setClickEvent(fn: () => void) { this.clickEvent = fn } @@ -34,11 +34,11 @@ export class PopupMenu { function readMenu(_items: IMenuItemOption[]) { return _items.map(i => { const d = { ...i } - if(!d.click) { + if (!d.click) { const r = Math.floor(Math.random() * 1e8) const evt = `popup_menu_item_${_idx++}_${r}` - const off = api.once(evt, (...argus)=>{ - console.log(1231); + const off = api.once(evt, (...argus) => { + console.log(1231) that.clickEvent(i, ...argus) }) that._offs.push(off) diff --git a/src/renderer/src/components/AdjustLine.vue b/src/renderer/src/components/AdjustLine.vue index a448944..ac3cc8e 100644 --- a/src/renderer/src/components/AdjustLine.vue +++ b/src/renderer/src/components/AdjustLine.vue @@ -10,9 +10,6 @@