diff --git a/src/views/login.vue b/src/views/login.vue index f5dcde0..c757ab1 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -30,7 +30,10 @@ function getMachineId() { const form = ref({account: null, password: '', token: '', machineId: machineId1.value}) -const adminRoleId = ref(null) +const adminRoleId = ref(null) + +// pinia 存储用户相关信息 +const adminStore = useAdminStore() //调用方法 const login = async function () { @@ -45,8 +48,6 @@ const login = async function () { // 本地存储token localStorage.setItem('token', result.msg) - // pinia 存储用户相关信息 - const adminStore = useAdminStore() // 存储用户信息 adminStore.setAdminData(result.data) @@ -90,7 +91,9 @@ const getMenuTree = async function () { return result.data // 直接返回接口响应数据 } catch (error) { console.error('菜单数据请求失败:', error) - return {code: 500, msg: '获取菜单失败'} + // return { code: 500, msg: '获取菜单失败' } + ElMessage.error('网络异常') + adminStore.clearState() } }