优化登录报错

This commit is contained in:
carry 2025-02-16 13:29:42 +08:00
parent 43e94434d1
commit eed370eaad
3 changed files with 6 additions and 2 deletions

View File

@ -36,7 +36,10 @@ export const userStore = defineStore('user', () => {
id.value = parseInt(decoded.id); id.value = parseInt(decoded.id);
} catch (error) { } catch (error) {
console.error('Login failed:', error); console.error('Login failed:', error);
throw error; const err = new Error('登录失败');
err.name = 'LoginError';
err.cause = error;
throw err;
} }
} }

View File

@ -44,7 +44,7 @@ const handleLogin = async () => {
await store.login(username, password) await store.login(username, password)
router.push({ name: 'manage' }) router.push({ name: 'manage' })
} catch (error: any) { } catch (error: any) {
ElMessage.error(error.message || '登录失败,请检查用户名和密码') ElMessage.error(error.message || '登录失败')
} }
} }
</script> </script>

View File

@ -9,6 +9,7 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true, "noUncheckedSideEffectImports": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
} }