diff --git a/electron/main/index.ts b/electron/main/index.ts index b5efeedd..3c641ddd 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -6,10 +6,11 @@ import { isDev, isMac, appName } from "./utils"; import { registerAllShortcuts, unregisterShortcuts } from "./shortcut"; import { initTray, MainTray } from "./tray"; import { initThumbar, Thumbar } from "./thumbar"; +import { type StoreType, initStore } from "./store"; +import Store from "electron-store"; import initAppServer from "../server"; import initIpcMain from "./ipcMain"; import log from "./logger"; -import store from "./store"; // icon import icon from "../../public/icons/favicon.png?asset"; @@ -29,6 +30,8 @@ class MainProcess { mainWindow: BrowserWindow | null = null; lyricWindow: BrowserWindow | null = null; loadingWindow: BrowserWindow | null = null; + // store + store: Store | null = null; // 托盘 mainTray: MainTray | null = null; // 工具栏 @@ -46,10 +49,12 @@ class MainProcess { process.exit(0); } else this.showWindow(); // 准备就绪 - app.whenReady().then(async () => { + app.on("ready", async () => { log.info("🚀 Application Process Startup"); // 设置应用程序名称 electronApp.setAppUserModelId(app.getName()); + // 初始化 store + this.store = initStore(); // 启动主服务进程 await initAppServer(); // 启动进程 @@ -68,7 +73,7 @@ class MainProcess { this.loadingWindow, this.mainTray, this.thumbar, - store, + this.store, ); // 注册快捷键 registerAllShortcuts(this.mainWindow!); @@ -111,8 +116,8 @@ class MainProcess { createMainWindow() { // 窗口配置项 const options: BrowserWindowConstructorOptions = { - width: store.get("window").width, - height: store.get("window").height, + width: this.store?.get("window").width, + height: this.store?.get("window").height, minHeight: 800, minWidth: 1280, // 菜单栏 @@ -132,8 +137,8 @@ class MainProcess { } // 配置网络代理 - if (store.get("proxy")) { - this.mainWindow.webContents.session.setProxy({ proxyRules: store.get("proxy") }); + if (this.store?.get("proxy")) { + this.mainWindow.webContents.session.setProxy({ proxyRules: this.store?.get("proxy") }); } // 窗口打开处理程序 @@ -162,15 +167,15 @@ class MainProcess { createLyricsWindow() { // 初始化窗口 this.lyricWindow = this.createWindow({ - width: store.get("lyric").width || 800, - height: store.get("lyric").height || 180, + width: this.store?.get("lyric").width || 800, + height: this.store?.get("lyric").height || 180, minWidth: 440, minHeight: 120, maxWidth: 1600, maxHeight: 300, // 窗口位置 - x: store.get("lyric").x, - y: store.get("lyric").y, + x: this.store?.get("lyric").x, + y: this.store?.get("lyric").y, transparent: true, backgroundColor: "rgba(0, 0, 0, 0)", alwaysOnTop: true, @@ -261,7 +266,7 @@ class MainProcess { const bounds = this.lyricWindow?.getBounds(); if (bounds) { const { width, height } = bounds; - store.set("lyric", { ...store.get("lyric"), width, height }); + this.store?.set("lyric", { ...this.store?.get("lyric"), width, height }); } }); @@ -279,7 +284,7 @@ class MainProcess { saveBounds() { if (this.mainWindow?.isFullScreen()) return; const bounds = this.mainWindow?.getBounds(); - if (bounds) store.set("window", bounds); + if (bounds) this.store?.set("window", bounds); } // 显示窗口 showWindow() { diff --git a/electron/main/store.ts b/electron/main/store.ts index 5aa57e6d..8c64a44c 100644 --- a/electron/main/store.ts +++ b/electron/main/store.ts @@ -25,23 +25,23 @@ export interface StoreType { } // 初始化仓库 -const store = new Store({ - defaults: { - window: { - width: 1280, - height: 800, +export const initStore = () => { + return new Store({ + defaults: { + window: { + width: 1280, + height: 800, + }, + lyric: { + fontSize: 30, + mainColor: "#fff", + shadowColor: "rgba(0, 0, 0, 0.5)", + x: screen.getPrimaryDisplay().workAreaSize.width / 2 - 400, + y: screen.getPrimaryDisplay().workAreaSize.height - 90, + width: 800, + height: 180, + }, + proxy: "", }, - lyric: { - fontSize: 30, - mainColor: "#fff", - shadowColor: "rgba(0, 0, 0, 0.5)", - x: screen.getPrimaryDisplay().workAreaSize.width / 2 - 400, - y: screen.getPrimaryDisplay().workAreaSize.height - 90, - width: 800, - height: 180, - }, - proxy: "", - }, -}); - -export default store; + }); +}; diff --git a/package.json b/package.json index 61f34802..b51b1f0f 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@pixi/filter-color-matrix": "^7.4.2", "@pixi/sprite": "^7.4.2", "@vueuse/core": "^10.11.1", - "NeteaseCloudMusicApi": "^4.23.3", + "NeteaseCloudMusicApi": "^4.24.0", "axios": "^1.7.7", "change-case": "^5.4.4", "dayjs": "^1.11.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7cb041ac..dd873721 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,8 +54,8 @@ importers: specifier: ^10.11.1 version: 10.11.1(vue@3.5.10(typescript@5.6.3)) NeteaseCloudMusicApi: - specifier: ^4.23.3 - version: 4.23.3 + specifier: ^4.24.0 + version: 4.24.0 axios: specifier: ^1.7.7 version: 1.7.7 @@ -1328,8 +1328,8 @@ packages: resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==} engines: {node: '>=10.0.0'} - NeteaseCloudMusicApi@4.23.3: - resolution: {integrity: sha512-CYlVytJOu5vap9pk0yF4DrhQyyuttdHhcj8lNcnt5weI/amKrEWxKfXmToraS84F+Wf96HxV2W/SRxA6yn8nkg==} + NeteaseCloudMusicApi@4.24.0: + resolution: {integrity: sha512-1fW3lf4iFlQFYpbAA2AptfnBh8fLPMH2aQnROhu77ub58ezzQdXahOAcN+PRvnnR4KcqmQeAFfYMkmuewBLiiA==} engines: {node: '>=12'} hasBin: true @@ -5332,7 +5332,7 @@ snapshots: '@xmldom/xmldom@0.8.10': {} - NeteaseCloudMusicApi@4.23.3: + NeteaseCloudMusicApi@4.24.0: dependencies: axios: 1.7.7 crypto-js: 4.2.0 diff --git a/src/components/Layout/Menu.vue b/src/components/Layout/Menu.vue index 6c9aa53c..df69f02f 100644 --- a/src/components/Layout/Menu.vue +++ b/src/components/Layout/Menu.vue @@ -122,7 +122,7 @@ const menuOptions = computed(() => { key: "cloud", link: "cloud", label: "我的云盘", - show: isElectron && dataStore.loginType !== "uid", + show: isLogin() === 1, icon: renderIcon("Cloud"), }, {