初始化项目
This commit is contained in:
34
attractor-ui/App.vue
Normal file
34
attractor-ui/App.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user