提交修改
CI / Server (Go) (push) Has been cancelled
CI / Web (Next.js) (push) Has been cancelled
CI / Mobile (React Native) (push) Has been cancelled
CI / Admin (React) (push) Has been cancelled
CI / Docker Build (push) Has been cancelled

This commit is contained in:
zeronline
2026-06-29 16:49:54 +08:00
parent 545329ac40
commit b01a5f91c3
43 changed files with 740 additions and 338 deletions
+45 -2
View File
@@ -2,7 +2,8 @@ App({
globalData: {
token: '',
user: null,
apiUrl: 'http://localhost:8080'
apiUrl: 'http://localhost:8080',
themeMode: 'light',
},
onLaunch() {
const token = wx.getStorageSync('token')
@@ -13,5 +14,47 @@ App({
if (user) this.globalData.user = user
} catch(e) {}
}
}
this.initTheme()
},
initTheme() {
const stored = wx.getStorageSync('inchstep-theme')
if (stored === 'light' || stored === 'dark') {
this.globalData.themeMode = stored
} else {
try {
const sysInfo = wx.getSystemInfoSync()
this.globalData.themeMode = sysInfo.theme === 'dark' ? 'dark' : 'light'
} catch(e) {}
}
this.applyTheme(this.globalData.themeMode)
},
applyTheme(mode) {
this.globalData.themeMode = mode
wx.setStorageSync('inchstep-theme', mode)
try {
wx.setNavigationBarColor({
frontColor: mode === 'dark' ? '#ffffff' : '#000000',
backgroundColor: mode === 'dark' ? '#1C1C1E' : '#F5F5F7',
})
wx.setTabBarStyle({
backgroundColor: mode === 'dark' ? '#1C1C1E' : '#F5F5F7',
borderStyle: mode === 'dark' ? 'black' : 'white',
})
} catch(e) {}
this.notifyPages(mode)
},
toggleTheme() {
const newMode = this.globalData.themeMode === 'light' ? 'dark' : 'light'
this.applyTheme(newMode)
},
notifyPages(mode) {
const pages = getCurrentPages()
pages.forEach(page => {
if (page.setData && typeof page.setThemeData === 'function') {
page.setThemeData(mode)
} else if (page.setData) {
page.setData({ themeMode: mode })
}
})
},
})