使用Pinia代替Vuex进行数据存储

This commit is contained in:
RuoYi
2025-04-23 20:53:28 +08:00
parent fd97380edb
commit 3eca7b1219
15 changed files with 169 additions and 155 deletions

26
App.vue
View File

@@ -1,7 +1,9 @@
<script setup>
import config from './config'
import { getToken } from '@/utils/auth'
import { useConfigStore } from '@/store'
import { getCurrentInstance } from "vue"
import { onLaunch } from '@dcloudio/uni-app'
import { getToken } from '@/utils/auth'
import { getCurrentInstance } from "vue"
const { proxy } = getCurrentInstance()
@@ -10,29 +12,25 @@
})
// 初始化应用
function initApp() {
function initApp() {
// 初始化应用配置
initConfig()
// 检查用户登录状态
//#ifdef H5
checkLogin()
//#endif
}
function initConfig() {
useConfigStore().setConfig(config)
}
function checkLogin() {
if (!getToken()) {
proxy.$tab.reLaunch('/pages/login')
}
}
}
</script>
<script>
import config from './config'
export default {
onLaunch: function() {
this.globalData.config = config
}
}
</script>
<style lang="scss">
@import '@/static/scss/index.scss'