28 lines
767 B
JavaScript
28 lines
767 B
JavaScript
const { getRuntimeConfig } = require('./config/env')
|
|
const { setUnauthorizedHandler } = require('./services/request/index')
|
|
const { sessionStore } = require('./stores/index')
|
|
|
|
App({
|
|
globalData: {
|
|
runtimeConfig: getRuntimeConfig(),
|
|
session: sessionStore.getState()
|
|
},
|
|
onLaunch() {
|
|
this.globalData.runtimeConfig = getRuntimeConfig()
|
|
sessionStore.hydrate()
|
|
this.globalData.session = sessionStore.getState()
|
|
sessionStore.subscribe(nextSession => {
|
|
this.globalData.session = nextSession
|
|
})
|
|
setUnauthorizedHandler(() => {
|
|
const currentRoute = getCurrentPages().slice(-1)[0]?.route
|
|
|
|
if (currentRoute !== 'pages/login/index') {
|
|
wx.reLaunch({
|
|
url: '/pages/login/index'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|