Skip to content

Commit

Permalink
perf: 仅客户端或Chrome浏览器支持主题功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Jan 22, 2022
1 parent 7ce15d5 commit f09b864
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.6.79",
"version": "0.6.80",
"description": "DooTask is task management system.",
"main": "main.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.6.79",
"version": "0.6.80",
"description": "DooTask is task management system.",
"scripts": {
"start": "./cmd dev",
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/build/412.js → public/js/build/845.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions resources/assets/js/functions/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,15 @@
return (ua.match(/MicroMessenger/i) + '' === 'micromessenger');
},

/**
* 是否Chrome
* @returns {boolean}
*/
isChrome() {
let ua = typeof window !== 'undefined' && window.navigator.userAgent.toLowerCase();
return (ua.match(/Chrome/i) + '' === 'chrome');
},

/**
* 获取对象
* @param obj
Expand Down
3 changes: 3 additions & 0 deletions resources/assets/js/functions/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,9 @@
},

enableDarkMode() {
if (!$A.isChrome()) {
return;
}
if (this.isDarkEnabled()) {
return
}
Expand Down
4 changes: 4 additions & 0 deletions resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ export default {
},
setTheme(mode) {
if (!$A.isChrome()) {
$A.modalWarning("仅客户端或Chrome浏览器支持主题功能");
return;
}
switch (mode) {
case 'dark':
$A.dark.enableDarkMode()
Expand Down
3 changes: 2 additions & 1 deletion resources/assets/js/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const stateData = {
],

// 主题皮肤
themeMode: $A.getStorageString("cacheThemeMode", "auto"),
themeMode: $A.getStorageString("cacheThemeMode"),
themeList: [
{name: '跟随系统', value: 'auto'},
{name: '明亮', value: 'light'},
Expand Down Expand Up @@ -134,6 +134,7 @@ switch (stateData.themeMode) {
$A.dark.disableDarkMode()
break;
default:
stateData.themeMode = "auto"
$A.dark.autoDarkMode()
break;
}
Expand Down

0 comments on commit f09b864

Please sign in to comment.