init
This commit is contained in:
27
app.js
Normal file
27
app.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { getRuntimeConfig } = require('./config/env')
|
||||
const { setUnauthorizedHandler } = require('./services/request')
|
||||
const { sessionStore } = require('./stores')
|
||||
|
||||
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'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user