修复'透明窗口'下出现窗口闪烁的问题。

This commit is contained in:
unknown 2024-09-22 22:42:25 +08:00
parent a2ccd8670b
commit 5c791874c6
20 changed files with 142 additions and 25 deletions

View File

@ -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"),

View File

@ -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"),

View File

@ -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"),

View File

@ -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

View File

@ -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"),

View File

@ -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,

View File

@ -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;

View File

@ -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"),

View File

@ -5,6 +5,8 @@ import { Setting } from "../../types/setting";
declare global {
// addon
var addon: any;
// 是否是首次打开软件
var first: boolean;
// 语言
var language: any;
// 主窗口

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">

View File

@ -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,
}"
>
<div

View File

@ -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,
}"
>
<div class="flex items-center px-2 app-region-drag">