Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into arm-support
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Nov 26, 2024
2 parents 83f8eb2 + 6f0311b commit ca3e942
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 2 additions & 0 deletions _script/2、installProject.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cd ../

chcp 65001

node -v

pnpm install
2 changes: 2 additions & 0 deletions _script/3、buildAndRun.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cd ../packages/gui

chcp 65001

node -v

npm run electron
2 changes: 1 addition & 1 deletion packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {
},

// 慢速IP延迟时间:测速超过该值时,则视为延迟高,显示为橙色
lowSpeedDelay: 150,
lowSpeedDelay: 200,
},
compatible: {
// **** 自定义兼容配置 **** //
Expand Down
13 changes: 11 additions & 2 deletions packages/gui/src/view/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import createMenus from '@/view/router/menu'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import { colorTheme } from './composables/theme'
export default {
name: 'App',
Expand All @@ -16,12 +17,20 @@ export default {
},
computed: {
themeClass () {
return `theme-${this.config.app.theme}`
return `theme-${colorTheme.value}`
},
theme () {
return this.config.app.theme
return colorTheme.value
},
},
mounted () {
let theme = this.config.app.theme
if (this.config.app.theme === 'system') {
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
colorTheme.value = theme
},
created () {
this.menus = createMenus(this)
this.config = this.$global.config
Expand Down
3 changes: 3 additions & 0 deletions packages/gui/src/view/composables/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ref } from 'vue'

export const colorTheme = ref('dark')
21 changes: 10 additions & 11 deletions packages/gui/src/view/pages/setting.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import { ipcRenderer } from 'electron'
import Plugin from '../mixins/plugin'
import { colorTheme } from '../composables/theme'
export default {
name: 'Setting',
Expand All @@ -10,19 +11,12 @@ export default {
key: 'app',
removeUserConfigLoading: false,
reloadLoading: false,
themeBackup: null,
urlBackup: null,
personalUrlBackup: null,
}
},
created () {
},
mounted () {
},
methods: {
ready (config) {
this.themeBackup = config.app.theme
this.urlBackup = config.app.remoteConfig.url
this.personalUrlBackup = config.app.remoteConfig.personalUrl
},
Expand Down Expand Up @@ -187,15 +181,17 @@ export default {
async applyAfter () {
let reloadLazy = 10
let theme = this.config.app.theme
if (theme === 'system') {
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
colorTheme.value = theme
// 判断远程配置地址是否变更过,如果是则重载远程配置并重启服务
if (this.config.app.remoteConfig.url !== this.urlBackup || this.config.app.remoteConfig.personalUrl !== this.personalUrlBackup) {
await this.$api.config.downloadRemoteConfig()
await this.reloadConfigAndRestart()
reloadLazy = 300
}
// 判断是否切换了主题,如果是,则刷新页面
if (this.config.app.theme !== this.themeBackup) {
setTimeout(() => window.location.reload(), reloadLazy)
}
Expand Down Expand Up @@ -373,6 +369,9 @@ export default {
<a-radio-button value="dark" title="dark">
暗色
</a-radio-button>
<a-radio-button value="system" title="system">
跟随系统
</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="首页提示" :label-col="labelCol" :wrapper-col="wrapperCol">
Expand Down

0 comments on commit ca3e942

Please sign in to comment.