| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <template>
- <view class="app-container">
- <router-view />
- </view>
- </template>
-
- <script>
- import config from './config'
- import { getToken } from '@/utils/auth'
-
- export default {
- onLaunch() {
- // 检查登录状态
- this.checkLogin()
-
- // 初始化主题(临时实现)
- this.initTheme()
- },
- methods: {
- // 检查用户登录状态
- checkLogin() {
- if (!getToken()) {
- this.$tab.reLaunch('/pages/login')
- }
- },
-
- // 临时主题初始化
- initTheme() {
- const themeName = uni.getStorageSync('selectedTheme') || 'aydzBlue'
-
- // 应用主题变量
- const themes = {
- aydzBlue: {
- '--primary-color': '#2a5caa',
- '--bg-color': '#e6f7ff',
- '--text-color': '#1a3353',
- '--card-bg': '#d0e8ff',
- '--header-bg': '#2a5caa'
- },
- darkMode: {
- '--primary-color': '#52c41a',
- '--bg-color': '#1a1a1a',
- '--text-color': '#e6e6e6',
- '--card-bg': '#2a2a2a'
- },
- default: {
- '--primary-color': '#1890ff',
- '--bg-color': '#f8f9fa',
- '--text-color': '#333',
- '--card-bg': '#ffffff'
- }
- }
-
- const root = document.documentElement
- const themeVars = themes[themeName] || themes.aydzBlue
-
- Object.keys(themeVars).forEach(key => {
- root.style.setProperty(key, themeVars[key])
- })
-
- // 动态设置导航栏颜色
- if (themeName === 'darkMode') {
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: '#1a1a1a'
- })
- } else if (themeName === 'aydzBlue') {
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: '#2a5caa'
- })
- }
- }
- }
- }
- </script>
-
- <style lang="scss">
- /* 保留原有样式 */
- </style>
|