提交
This commit is contained in:
1 parent
8be55c08e9
commit
a903fcf6d4
75 files changed
+9547
-124
No files matched your search
@@ -1,14 +1,9 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
import { AUTH_API, TOKEN_KEY, REFRESH_TOKEN_KEY, USER_INFO_KEY } from '@/config/api'
|
||||
import { AUTH_API, TOKEN_KEY, REFRESH_TOKEN_KEY, USER_INFO_KEY, PAGE_PATHS } from '@/config/api'
|
||||
import { request, parseResponseJson } from '@/utils/request'
|
||||
import { buildMiniEncryptedLoginBody } from '@/utils/loginRsa'
|
||||
|
||||
const PAGE_PATHS = {
|
||||
login: '/pages/login/login',
|
||||
home: '/pages/home/home'
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const token = ref('')
|
||||
const refreshToken = ref('')
|
||||
@@ -31,7 +26,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
|
||||
const isLoggedIn = computed(() => !!token.value && !!userInfo.value)
|
||||
const userRole = computed(() => userInfo.value?.role || '')
|
||||
const homePath = computed(() => PAGE_PATHS.home)
|
||||
/** 登录成功默认进入工作台 Tab */
|
||||
const homePath = computed(() => PAGE_PATHS.workbench)
|
||||
|
||||
function checkLoginStatus() {
|
||||
const savedToken = uni.getStorageSync(TOKEN_KEY)
|
||||
@@ -127,7 +123,12 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
|
||||
function navigateToHome() {
|
||||
uni.reLaunch({ url: homePath.value })
|
||||
uni.switchTab({
|
||||
url: homePath.value,
|
||||
fail: () => {
|
||||
uni.reLaunch({ url: homePath.value })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function updateUserInfo(info) {
|
||||
|
||||
Reference in new issue
Block a user