From 5c791874c61ec934375335848709a7b656876b8c Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 22 Sep 2024 22:42:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D'=E9=80=8F=E6=98=8E=E7=AA=97?= =?UTF-8?q?=E5=8F=A3'=E4=B8=8B=E5=87=BA=E7=8E=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E9=97=AA=E7=83=81=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/about/index.ts | 6 ++++- electron/main/classification/index.ts | 24 ++++++++++++++--- electron/main/data/index.ts | 6 ++++- electron/main/index.ts | 28 ++++++++++++++++---- electron/main/item/index.ts | 18 ++++++++++--- electron/main/search/index.ts | 12 +++++++-- electron/main/setting/data.ts | 10 ++----- electron/main/setting/index.ts | 6 ++++- electron/types/global.d.ts | 2 ++ src/pages/about/Index.vue | 5 ++++ src/pages/classification/AddEdit.vue | 5 ++++ src/pages/classification/Aggregate.vue | 5 ++++ src/pages/classification/AssociateFolder.vue | 5 ++++ src/pages/classification/SetIcon.vue | 5 ++++ src/pages/data/BackupRestore.vue | 5 ++++ src/pages/item/AddEdit.vue | 5 ++++ src/pages/item/NetworkIcon.vue | 5 ++++ src/pages/item/SVGIcon.vue | 5 ++++ src/pages/search/QuickSearch.vue | 5 ++++ src/pages/setting/Index.vue | 5 ++++ 20 files changed, 142 insertions(+), 25 deletions(-) diff --git a/electron/main/about/index.ts b/electron/main/about/index.ts index 75fcda1..9fc4eba 100644 --- a/electron/main/about/index.ts +++ b/electron/main/about/index.ts @@ -24,7 +24,11 @@ function createWindow() { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), diff --git a/electron/main/classification/index.ts b/electron/main/classification/index.ts index bceff10..e50355d 100644 --- a/electron/main/classification/index.ts +++ b/electron/main/classification/index.ts @@ -49,7 +49,11 @@ function createAddEditWindow(id: number | null, parentId: number | null) { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), @@ -113,7 +117,11 @@ function createSetIconWindow(id: number) { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), @@ -172,7 +180,11 @@ function createAssociateFolderWindow(id: number) { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), @@ -236,7 +248,11 @@ function createAggregateWindow(id: number) { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), diff --git a/electron/main/data/index.ts b/electron/main/data/index.ts index 200b1f8..9ebfdd1 100644 --- a/electron/main/data/index.ts +++ b/electron/main/data/index.ts @@ -25,7 +25,11 @@ function createBackupRestoreDataWindow() { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), diff --git a/electron/main/index.ts b/electron/main/index.ts index 62d669b..f4ad8a5 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -8,7 +8,10 @@ import { initSystemItem } from "./item/commons/data"; import commonIpcEvent from "./commons/ipcEvent"; import itemIpcEvent from "./item/ipcEvent"; import settingIpcEvent from "./setting/ipcEvent"; -import { init as settingDataInit } from "./setting/data"; +import { + init as settingDataInit, + update as updateSetting, +} from "./setting/data"; import { setShortcutKey } from "./setting"; import searchIpcEvent from "./search/ipcEvent"; import { createMainWindow } from "./main"; @@ -37,8 +40,13 @@ process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL // 解决透明窗口闪烁 app.commandLine.appendSwitch("wm-window-animations-disabled"); -// 解决创建窗口屏幕闪烁问题 -app.disableHardwareAcceleration(); +// 初始化设置数据 +settingDataInit(); +// 如果主窗口是非透明窗口的话,禁止GPU加速,解决白屏问题。 +// 如果主窗口是透明窗口的话,将除主窗口外的窗口都改为透明度0.99,解决解决白屏问题。 +if (global.setting.appearance.transparency === 1) { + app.disableHardwareAcceleration(); +} // Set application name for Windows 10+ notifications if (process.platform === "win32") app.setAppUserModelId(app.getName()); @@ -62,8 +70,18 @@ app.whenReady().then(() => { } // addon global.addon = require("../../native/addon.node"); - // 初始化数据 - settingDataInit(); + if (global.first) { + // 首次添加,判断系统语言 + if (app.getLocale().toLowerCase().indexOf("zh-") === 0) { + // 简体中文 + global.setting.general.language = "SimplifiedChinese"; + } else { + // 英文 + global.setting.general.language = "English"; + } + // 修改 + updateSetting(global.setting); + } // 获取语言 global.language = getLanguage(global.setting.general.language); // 禁用debugtron diff --git a/electron/main/item/index.ts b/electron/main/item/index.ts index 1b0a177..cab1be2 100644 --- a/electron/main/item/index.ts +++ b/electron/main/item/index.ts @@ -59,7 +59,11 @@ async function createAddEditWindow( fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), @@ -119,7 +123,11 @@ async function createNetworkIconWindow() { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), @@ -170,7 +178,11 @@ async function createSVGIconWindow() { fullscreenable: false, focusable: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), diff --git a/electron/main/search/index.ts b/electron/main/search/index.ts index 290ced2..663ff2b 100644 --- a/electron/main/search/index.ts +++ b/electron/main/search/index.ts @@ -1,6 +1,10 @@ import { BrowserWindow, shell, screen } from "electron"; import { join } from "node:path"; -import { getWindowInScreen, sendToWebContent } from "../commons"; +import { + getMainBackgorunColor, + getWindowInScreen, + sendToWebContent, +} from "../commons"; import cacheData from "../commons/cacheData"; // 窗口 @@ -24,7 +28,11 @@ function createQuickSearchWindow() { fullscreenable: false, resizable: false, alwaysOnTop: true, - backgroundColor: global.setting.appearance.theme.mainBackgroundColor, + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, backgroundThrottling: false, diff --git a/electron/main/setting/data.ts b/electron/main/setting/data.ts index ab4883b..6880806 100644 --- a/electron/main/setting/data.ts +++ b/electron/main/setting/data.ts @@ -51,14 +51,6 @@ function select() { * 添加 */ function add(setting: Setting) { - // 首次添加,判断系统语言 - if (app.getLocale().toLowerCase().indexOf("zh-") === 0) { - // 简体中文 - setting.general.language = "SimplifiedChinese"; - } else { - // 英文 - setting.general.language = "English"; - } // SQL let sql = `INSERT INTO ${settingTableName} (id, setting) @@ -67,6 +59,8 @@ function add(setting: Setting) { let id = db.prepare(sql).run(1, JSON.stringify(setting)).lastInsertRowid; if (id) { global.setting = setting; + // 添加设置被视为首次打开软件 + global.first = true; return true; } return false; diff --git a/electron/main/setting/index.ts b/electron/main/setting/index.ts index 7b01d1f..cf0e67e 100644 --- a/electron/main/setting/index.ts +++ b/electron/main/setting/index.ts @@ -34,7 +34,11 @@ function createSettingWindow() { fullscreenable: false, skipTaskbar: true, show: false, - backgroundColor: getMainBackgorunColor(), + transparent: global.setting.appearance.transparency < 1, + backgroundColor: + global.setting.appearance.transparency === 1 + ? getMainBackgorunColor() + : null, webPreferences: { spellcheck: false, preload: join(__dirname, "../preload/index.js"), diff --git a/electron/types/global.d.ts b/electron/types/global.d.ts index c822052..01f238f 100644 --- a/electron/types/global.d.ts +++ b/electron/types/global.d.ts @@ -5,6 +5,8 @@ import { Setting } from "../../types/setting"; declare global { // addon var addon: any; + // 是否是首次打开软件 + var first: boolean; // 语言 var language: any; // 主窗口 diff --git a/src/pages/about/Index.vue b/src/pages/about/Index.vue index 4e8c670..bb1f61a 100644 --- a/src/pages/about/Index.vue +++ b/src/pages/about/Index.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/classification/AddEdit.vue b/src/pages/classification/AddEdit.vue index 9a7728b..519d918 100644 --- a/src/pages/classification/AddEdit.vue +++ b/src/pages/classification/AddEdit.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/classification/Aggregate.vue b/src/pages/classification/Aggregate.vue index e458cf2..22e58b5 100644 --- a/src/pages/classification/Aggregate.vue +++ b/src/pages/classification/Aggregate.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/classification/AssociateFolder.vue b/src/pages/classification/AssociateFolder.vue index 5132256..2d6dc4b 100644 --- a/src/pages/classification/AssociateFolder.vue +++ b/src/pages/classification/AssociateFolder.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/classification/SetIcon.vue b/src/pages/classification/SetIcon.vue index 34ca85b..b9004a8 100644 --- a/src/pages/classification/SetIcon.vue +++ b/src/pages/classification/SetIcon.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/data/BackupRestore.vue b/src/pages/data/BackupRestore.vue index 6fcb781..299ac13 100644 --- a/src/pages/data/BackupRestore.vue +++ b/src/pages/data/BackupRestore.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/item/AddEdit.vue b/src/pages/item/AddEdit.vue index 2dab776..7fdc4b0 100644 --- a/src/pages/item/AddEdit.vue +++ b/src/pages/item/AddEdit.vue @@ -5,6 +5,11 @@ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, height: height + 'px', + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/item/NetworkIcon.vue b/src/pages/item/NetworkIcon.vue index a56ed5e..70acbf2 100644 --- a/src/pages/item/NetworkIcon.vue +++ b/src/pages/item/NetworkIcon.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/item/SVGIcon.vue b/src/pages/item/SVGIcon.vue index f57b5f9..57ee038 100644 --- a/src/pages/item/SVGIcon.vue +++ b/src/pages/item/SVGIcon.vue @@ -4,6 +4,11 @@ :style="{ backgroundColor: store.setting.appearance.theme.mainBackgroundColor, color: store.setting.appearance.theme.mainFontColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >
diff --git a/src/pages/search/QuickSearch.vue b/src/pages/search/QuickSearch.vue index 1225e9e..2926c7a 100644 --- a/src/pages/search/QuickSearch.vue +++ b/src/pages/search/QuickSearch.vue @@ -4,6 +4,11 @@ :style="{ color: store.setting.appearance.theme.mainFontColor, backgroundColor: store.setting.appearance.theme.mainBackgroundColor, + borderRadius: + store.setting.appearance.transparency < 1 && + store.setting.appearance.windowRounded + ? '8px' + : undefined, }" >