mirror of
https://github.com/yangzongzhuan/RuoYi-App.git
synced 2025-09-27 14:42:41 +00:00
兼容vue3模式获取config
This commit is contained in:
66
App.vue
66
App.vue
@@ -1,37 +1,39 @@
|
||||
<script setup>
|
||||
import { onLaunch } from '@dcloudio/uni-app'
|
||||
import config from './config'
|
||||
import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { getCurrentInstance } from "vue"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
<script setup>
|
||||
import { onLaunch } from '@dcloudio/uni-app'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { getCurrentInstance } from "vue"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
onLaunch(() => {
|
||||
initApp()
|
||||
})
|
||||
|
||||
// 初始化应用
|
||||
function initApp() {
|
||||
// 初始化应用配置
|
||||
initConfig()
|
||||
// 检查用户登录状态
|
||||
//#ifdef H5
|
||||
checkLogin()
|
||||
//#endif
|
||||
}
|
||||
|
||||
function initConfig() {
|
||||
getApp().globalData.config = config
|
||||
}
|
||||
|
||||
function checkLogin() {
|
||||
if (!getToken()) {
|
||||
proxy.$tab.reLaunch('/pages/login')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化应用
|
||||
function initApp() {
|
||||
// 检查用户登录状态
|
||||
//#ifdef H5
|
||||
checkLogin()
|
||||
//#endif
|
||||
}
|
||||
|
||||
function checkLogin() {
|
||||
if (!getToken()) {
|
||||
proxy.$tab.reLaunch('/pages/login')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import '@/static/scss/index.scss'
|
||||
<script>
|
||||
import config from './config'
|
||||
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
this.globalData.config = config
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import '@/static/scss/index.scss'
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user