Files
attractor/attractor-ui/App.vue
2026-04-07 11:18:02 +08:00

34 lines
874 B
Vue

<script>
import config from './config'
import { getToken } from '@/utils/auth'
import updateManager from '@/utils/upgrade.js'
export default {
onLaunch() {
this.initApp()
updateManager.checkUpdate()
},
methods: {
initApp() {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen()
// #endif
this.initConfig()
this.ensureAuthState()
},
initConfig() {
this.globalData.config = config
},
ensureAuthState() {
const token = getToken()
const pages = getCurrentPages()
const currentRoute = pages && pages.length ? `/${pages[0].route}` : ''
if (!token && currentRoute !== '/pages/login') {
uni.reLaunch({ url: '/pages/login' })
}
}
}
}
</script>
<style lang="scss">
@import '@/static/scss/index.scss';
</style>