Otsuka-APP/App.vue

38 lines
685 B
Vue
Raw Normal View History

2025-08-19 17:07:46 +08:00
<script setup>
2026-02-05 15:11:40 +08:00
import config from './config'
import {getToken} from '@/utils/auth'
import {useConfigStore} from '@/store'
import {getCurrentInstance} from "vue"
import {onLaunch} from '@dcloudio/uni-app'
2025-08-19 17:07:46 +08:00
2026-02-05 15:11:40 +08:00
const {proxy} = getCurrentInstance()
2025-08-19 17:07:46 +08:00
2026-02-05 15:11:40 +08:00
onLaunch(() => {
2025-08-19 17:07:46 +08:00
initApp()
2026-02-05 15:11:40 +08:00
})
2025-08-19 17:07:46 +08:00
2026-02-05 15:11:40 +08:00
// 初始化应用
function initApp() {
2025-08-19 17:07:46 +08:00
// 初始化应用配置
initConfig()
// 检查用户登录状态
//#ifdef H5
checkLogin()
//#endif
2026-02-05 15:11:40 +08:00
}
2025-08-19 17:07:46 +08:00
2026-02-05 15:11:40 +08:00
function initConfig() {
2025-08-19 17:07:46 +08:00
useConfigStore().setConfig(config)
2026-02-05 15:11:40 +08:00
}
2025-08-19 17:07:46 +08:00
2026-02-05 15:11:40 +08:00
function checkLogin() {
2025-08-19 17:07:46 +08:00
if (!getToken()) {
2026-02-05 15:11:40 +08:00
proxy.$tab.reLaunch('/pages/login')
2025-08-19 17:07:46 +08:00
}
2026-02-05 15:11:40 +08:00
}
2025-08-19 17:07:46 +08:00
</script>
<style lang="scss">
2026-02-05 15:11:40 +08:00
@import '@/static/scss/index.scss'
2025-08-19 17:07:46 +08:00
</style>