perf: 优化深色模式

This commit is contained in:
kuaifan 2023-07-25 14:12:51 +08:00
parent c5f7073cc1
commit 40b52d8f3b
6 changed files with 27 additions and 23 deletions

View File

@ -26,7 +26,7 @@
"css-loader": "^6.7.2", "css-loader": "^6.7.2",
"dexie": "^3.2.3", "dexie": "^3.2.3",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"element-sea": "^2.15.10-4", "element-sea": "^2.15.10-5",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"inquirer": "^8.2.0", "inquirer": "^8.2.0",

View File

@ -161,6 +161,7 @@ export default {
windowActive(active) { windowActive(active) {
if (active) { if (active) {
this.autoTheme()
this.__windowTimer && clearTimeout(this.__windowTimer) this.__windowTimer && clearTimeout(this.__windowTimer)
this.__windowTimer = setTimeout(_ => { this.__windowTimer = setTimeout(_ => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
@ -174,9 +175,6 @@ export default {
}).catch(_ => { }).catch(_ => {
this.$store.dispatch("websocketConnection") this.$store.dispatch("websocketConnection")
}) })
if (this.themeMode === "auto") {
this.$store.dispatch("synchTheme")
}
}, 600) }, 600)
} else { } else {
this.$store.dispatch("audioStop", true) this.$store.dispatch("audioStop", true)
@ -221,6 +219,12 @@ export default {
}); });
}, },
autoTheme() {
if (this.themeMode === "auto") {
this.$store.dispatch("synchTheme")
}
},
synchThemeLanguage() { synchThemeLanguage() {
if (this.isSoftware) { if (this.isSoftware) {
this.iframes = this.iframes.filter(({key}) => key != 'synchThemeLanguage') this.iframes = this.iframes.filter(({key}) => key != 'synchThemeLanguage')
@ -298,9 +302,7 @@ export default {
} }
// APP // APP
window.__onAppActive = () => { window.__onAppActive = () => {
if (this.themeMode === "auto") { this.autoTheme()
this.$store.dispatch("synchTheme")
}
} }
// //
window.__onPagePause = () => { window.__onPagePause = () => {
@ -312,6 +314,8 @@ export default {
this.$store.state.windowActive = true; this.$store.state.windowActive = true;
if (num > 0) { if (num > 0) {
this.$store.dispatch("getBasicData", 600) this.$store.dispatch("getBasicData", 600)
} else {
this.autoTheme()
} }
} }
// //

View File

@ -83,6 +83,11 @@
} }
}); });
}, },
eeuiAppGetThemeName() {
if (!$A.isEEUiApp) return;
return requireModuleJs("eeui").getThemeName();
},
}); });
window.$A = $; window.$A = $;

View File

@ -1152,19 +1152,11 @@
}, },
defaultFilter() { defaultFilter() {
if (this.supportMode() === 'chrome') { return '-webkit-filter: invert(0.92) hue-rotate(180deg) !important; filter: invert(0.92) hue-rotate(180deg) !important;';
return '-webkit-filter: url(#dark-mode-filter) !important; filter: url(#dark-mode-filter) !important;';
} else if (this.supportMode() === 'webkit') {
return '-webkit-filter: invert(0.92) hue-rotate(180deg) !important; filter: invert(0.92) hue-rotate(180deg) !important;';
}
}, },
reverseFilter() { reverseFilter() {
if (this.supportMode() === 'chrome') { return '-webkit-filter: invert(0.92) hue-rotate(180deg) !important; filter: invert(0.92) hue-rotate(180deg) !important;';
return '-webkit-filter: url(#dark-mode-reverse-filter) !important; filter: url(#dark-mode-reverse-filter) !important;';
} else if (this.supportMode() === 'webkit') {
return '-webkit-filter: invert(0.92) hue-rotate(180deg) !important; filter: invert(0.92) hue-rotate(180deg) !important;';
}
}, },
noneFilter() { noneFilter() {
@ -1322,6 +1314,9 @@
autoDarkMode() { autoDarkMode() {
let darkScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches let darkScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
if ($A.isEEUiApp) {
darkScheme = $A.eeuiAppGetThemeName() === "dark"
}
if (darkScheme) { if (darkScheme) {
this.enableDarkMode() this.enableDarkMode()
} else { } else {

View File

@ -474,7 +474,7 @@ export default {
components: { components: {
UserSelect, UserSelect,
TaskExistTips, TaskExistTips,
ChatInput, ChatInput,
TaskMenu, TaskMenu,
ProjectLog, ProjectLog,
DialogWrapper, DialogWrapper,
@ -629,7 +629,7 @@ export default {
'taskContents', 'taskContents',
'taskFiles', 'taskFiles',
'taskPriority', 'taskPriority',
'dialogId', 'dialogId',
]), ]),
@ -981,7 +981,7 @@ export default {
&& (Math.abs($A.Time(this.taskDetail.start_at) - $A.Time(params.start_at)) > 60 || Math.abs($A.Time(this.taskDetail.end_at) - $A.Time(params.end_at)) > 60) && (Math.abs($A.Time(this.taskDetail.start_at) - $A.Time(params.start_at)) > 60 || Math.abs($A.Time(this.taskDetail.end_at) - $A.Time(params.end_at)) > 60)
&& typeof params.desc === "undefined") { && typeof params.desc === "undefined") {
$A.modalInput({ $A.modalInput({
title: `修改任务时间`, title: `修改${this.taskDetail.parent_id > 0 ? '子任务' : '任务'}时间`,
placeholder: `请输入修改备注`, placeholder: `请输入修改备注`,
okText: "确定", okText: "确定",
onOk: (desc) => { onOk: (desc) => {
@ -989,8 +989,8 @@ export default {
return `请输入修改备注` return `请输入修改备注`
} }
this.updateParams = Object.assign(params, { desc }) this.updateParams = Object.assign(params, { desc })
if (params.start_at && params.end_at) { if (params.start_at && params.end_at && this.$refs.taskExistTipsRef) {
this.$refs['taskExistTipsRef'].isExistTask({ this.$refs.taskExistTipsRef.isExistTask({
taskid: this.taskDetail.id, taskid: this.taskDetail.id,
userids: this.taskDetail.owner_userid, userids: this.taskDetail.owner_userid,
timerange: [params.start_at, params.end_at] timerange: [params.start_at, params.end_at]

@ -1 +1 @@
Subproject commit b95b0a9c439f04f9f19648bb2159187eb2b936ea Subproject commit 0df0faf4510aca0532784acfcc4feb54bdf37fd4