mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 优化深色主题
This commit is contained in:
parent
1ddb88a3a6
commit
02fd214b33
23
electron/electron.js
vendored
23
electron/electron.js
vendored
@ -17,6 +17,7 @@ const {
|
|||||||
BrowserWindow
|
BrowserWindow
|
||||||
} = require('electron')
|
} = require('electron')
|
||||||
const {autoUpdater} = require("electron-updater")
|
const {autoUpdater} = require("electron-updater")
|
||||||
|
const Store = require("electron-store");
|
||||||
const loger = require("electron-log");
|
const loger = require("electron-log");
|
||||||
const electronConf = require('electron-config')
|
const electronConf = require('electron-config')
|
||||||
const userConf = new electronConf()
|
const userConf = new electronConf()
|
||||||
@ -29,6 +30,7 @@ const utils = require('./utils');
|
|||||||
const config = require('./package.json');
|
const config = require('./package.json');
|
||||||
const electronMenu = require("./electron-menu");
|
const electronMenu = require("./electron-menu");
|
||||||
const spawn = require("child_process").spawn;
|
const spawn = require("child_process").spawn;
|
||||||
|
const store = new Store();
|
||||||
|
|
||||||
const isMac = process.platform === 'darwin'
|
const isMac = process.platform === 'darwin'
|
||||||
const isWin = process.platform === 'win32'
|
const isWin = process.platform === 'win32'
|
||||||
@ -133,6 +135,7 @@ function createMainWindow() {
|
|||||||
minHeight: 360,
|
minHeight: 360,
|
||||||
center: true,
|
center: true,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
backgroundColor: utils.getDefaultBackgroundColor(),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
@ -276,6 +279,7 @@ function preCreateChildWindow() {
|
|||||||
show: false,
|
show: false,
|
||||||
parent: mainWindow,
|
parent: mainWindow,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
backgroundColor: utils.getDefaultBackgroundColor(),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
@ -328,6 +332,7 @@ function createChildWindow(args) {
|
|||||||
show: false,
|
show: false,
|
||||||
parent: mainWindow,
|
parent: mainWindow,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
backgroundColor: utils.getDefaultBackgroundColor(),
|
||||||
webPreferences: Object.assign({
|
webPreferences: Object.assign({
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
@ -499,6 +504,7 @@ function createWebTabWindow(args) {
|
|||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
titleBarOverlay,
|
titleBarOverlay,
|
||||||
|
backgroundColor: utils.getDefaultBackgroundColor(),
|
||||||
webPreferences: Object.assign({
|
webPreferences: Object.assign({
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
@ -1264,6 +1270,23 @@ ipcMain.on('openNotification', (event, args) => {
|
|||||||
event.returnValue = "ok"
|
event.returnValue = "ok"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存缓存
|
||||||
|
*/
|
||||||
|
ipcMain.on('setStore', (event, args) => {
|
||||||
|
if (utils.isJson(args)) {
|
||||||
|
store.set(args.key, args.value)
|
||||||
|
}
|
||||||
|
event.returnValue = "ok"
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存
|
||||||
|
*/
|
||||||
|
ipcMain.handle('getStore', (event, args) => {
|
||||||
|
return store.get(args)
|
||||||
|
});
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
// Update
|
// Update
|
||||||
//================================================================
|
//================================================================
|
||||||
|
|||||||
28
electron/utils.js
vendored
28
electron/utils.js
vendored
@ -5,8 +5,10 @@ const dayjs = require("dayjs");
|
|||||||
const http = require('http')
|
const http = require('http')
|
||||||
const https = require('https')
|
const https = require('https')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const {shell, dialog, session, Notification} = require("electron");
|
const {shell, dialog, session, Notification, nativeTheme} = require("electron");
|
||||||
const loger = require("electron-log");
|
const loger = require("electron-log");
|
||||||
|
const Store = require("electron-store");
|
||||||
|
const store = new Store();
|
||||||
|
|
||||||
const utils = {
|
const utils = {
|
||||||
/**
|
/**
|
||||||
@ -659,6 +661,30 @@ const utils = {
|
|||||||
}
|
}
|
||||||
browser.loadFile('./public/index.html', options).then(_ => { }).catch(_ => { })
|
browser.loadFile('./public/index.html', options).then(_ => { }).catch(_ => { })
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主题名称
|
||||||
|
* @returns {string|*}
|
||||||
|
*/
|
||||||
|
getThemName() {
|
||||||
|
const themeConf = store.get("themeConf");
|
||||||
|
if (["dark", "light"].includes(themeConf)) {
|
||||||
|
return themeConf;
|
||||||
|
}
|
||||||
|
return nativeTheme.shouldUseDarkColors ? "dark" : "light";
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取默认背景颜色
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
getDefaultBackgroundColor() {
|
||||||
|
if (utils.getThemName() === "dark") {
|
||||||
|
return "#0D0D0D";
|
||||||
|
} else {
|
||||||
|
return "#FFFFFF";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<router-view class="child-view"></router-view>
|
<router-view class="child-view" @hook:mounted.once="onRouterViewMounted"></router-view>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
|
|
||||||
<!--任务操作-->
|
<!--任务操作-->
|
||||||
@ -270,6 +270,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRouterViewMounted() {
|
||||||
|
document.documentElement.setAttribute("data-platform", $A.isElectron ? "desktop" : $A.isEEUiApp ? "app" : "web")
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取链接打开方式
|
* 获取链接打开方式
|
||||||
* @param url
|
* @param url
|
||||||
|
|||||||
3
resources/assets/js/functions/web.js
vendored
3
resources/assets/js/functions/web.js
vendored
@ -1056,6 +1056,9 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
|||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
html[data-platform="desktop"] {
|
||||||
|
background-color: #0D0D0D;
|
||||||
|
}
|
||||||
.child-view {
|
.child-view {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|||||||
5
resources/assets/js/store/actions.js
vendored
5
resources/assets/js/store/actions.js
vendored
@ -472,6 +472,11 @@ export default {
|
|||||||
action: 'updateTheme',
|
action: 'updateTheme',
|
||||||
themeName: state.themeName,
|
themeName: state.themeName,
|
||||||
});
|
});
|
||||||
|
} else if ($A.isElectron) {
|
||||||
|
$A.Electron.sendMessage('setStore', {
|
||||||
|
key: 'themeConf',
|
||||||
|
value: state.themeConf
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user