src/stores/user.js
@@ -1,6 +1,7 @@ // 加载状态的逻辑管理 import { defineStore } from 'pinia' import { ref, computed } from 'vue' export const useLoginUserStore = defineStore('loginUser',() => { // 当前登陆的用户名 @@ -10,12 +11,10 @@ currentLoginUser.value = user } const getUserName = computed(()=>{ return currentLoginUser.value == '-1' ? localStorage.getItem('currentUserName'): currentLoginUser.value return currentLoginUser.value == '-1' ? localStorage.getItem('currentUserName') : currentLoginUser.value }) return {currentLoginUser,setUser,getUserName} })