Merge remote-tracking branch 'upstream/master' into arm-support

pull/401/head
王良 2024-11-26 17:02:18 +08:00
commit ca3e94218f
6 changed files with 29 additions and 14 deletions

View File

@ -1,5 +1,7 @@
cd ../ cd ../
chcp 65001
node -v node -v
pnpm install pnpm install

View File

@ -1,5 +1,7 @@
cd ../packages/gui cd ../packages/gui
chcp 65001
node -v node -v
npm run electron npm run electron

View File

@ -68,7 +68,7 @@ module.exports = {
}, },
// 慢速IP延迟时间测速超过该值时则视为延迟高显示为橙色 // 慢速IP延迟时间测速超过该值时则视为延迟高显示为橙色
lowSpeedDelay: 150, lowSpeedDelay: 200,
}, },
compatible: { compatible: {
// **** 自定义兼容配置 **** // // **** 自定义兼容配置 **** //

View File

@ -1,6 +1,7 @@
<script> <script>
import createMenus from '@/view/router/menu' import createMenus from '@/view/router/menu'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN' import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import { colorTheme } from './composables/theme'
export default { export default {
name: 'App', name: 'App',
@ -16,12 +17,20 @@ export default {
}, },
computed: { computed: {
themeClass () { themeClass () {
return `theme-${this.config.app.theme}` return `theme-${colorTheme.value}`
}, },
theme () { 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 () { created () {
this.menus = createMenus(this) this.menus = createMenus(this)
this.config = this.$global.config this.config = this.$global.config

View File

@ -0,0 +1,3 @@
import { ref } from 'vue'
export const colorTheme = ref('dark')

View File

@ -1,6 +1,7 @@
<script> <script>
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import Plugin from '../mixins/plugin' import Plugin from '../mixins/plugin'
import { colorTheme } from '../composables/theme'
export default { export default {
name: 'Setting', name: 'Setting',
@ -10,19 +11,12 @@ export default {
key: 'app', key: 'app',
removeUserConfigLoading: false, removeUserConfigLoading: false,
reloadLoading: false, reloadLoading: false,
themeBackup: null,
urlBackup: null, urlBackup: null,
personalUrlBackup: null, personalUrlBackup: null,
} }
}, },
created () {
},
mounted () {
},
methods: { methods: {
ready (config) { ready (config) {
this.themeBackup = config.app.theme
this.urlBackup = config.app.remoteConfig.url this.urlBackup = config.app.remoteConfig.url
this.personalUrlBackup = config.app.remoteConfig.personalUrl this.personalUrlBackup = config.app.remoteConfig.personalUrl
}, },
@ -187,15 +181,17 @@ export default {
async applyAfter () { async applyAfter () {
let reloadLazy = 10 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) { if (this.config.app.remoteConfig.url !== this.urlBackup || this.config.app.remoteConfig.personalUrl !== this.personalUrlBackup) {
await this.$api.config.downloadRemoteConfig() await this.$api.config.downloadRemoteConfig()
await this.reloadConfigAndRestart() await this.reloadConfigAndRestart()
reloadLazy = 300 reloadLazy = 300
}
//
if (this.config.app.theme !== this.themeBackup) {
setTimeout(() => window.location.reload(), reloadLazy) setTimeout(() => window.location.reload(), reloadLazy)
} }
@ -373,6 +369,9 @@ export default {
<a-radio-button value="dark" title="dark"> <a-radio-button value="dark" title="dark">
暗色 暗色
</a-radio-button> </a-radio-button>
<a-radio-button value="system" title="system">
跟随系统
</a-radio-button>
</a-radio-group> </a-radio-group>
</a-form-item> </a-form-item>
<a-form-item label="首页提示" :label-col="labelCol" :wrapper-col="wrapperCol"> <a-form-item label="首页提示" :label-col="labelCol" :wrapper-col="wrapperCol">