最新修改,初版

This commit is contained in:
2026-02-25 09:38:25 +08:00
parent 1f5bfba3b3
commit 0378198f55
15 changed files with 1691 additions and 824 deletions

View File

@@ -87,12 +87,15 @@ const handleLogin = async () => {
loading.value = true;
const res = await userApi.login(loginForm.username, loginForm.password);
// console.log(res)
// 注意:这里由于你之前的封装,可能需要判断 res.data.code 还是 res.code
// 如果用了拦截器,直接判断 res.code
if (res.code === 200) {
const token = res.data.token;
const userInfo = JSON.stringify(res.data.user_info);
const role = res.data.user_info.role;
// console.log(role)
// --- 核心逻辑开始 ---
if (rememberMe.value) {
@@ -108,8 +111,22 @@ const handleLogin = async () => {
ElMessage.success('身份验证通过,方舟系统加载中...');
// 3. 根据角色执行路由跳转
setTimeout(() => {
router.push('/');
switch (role) {
case 'admin':
router.push('/'); // 管理员跳转至主页
break;
case 'user':
router.push('/user'); // 跳转至 UserView (请确保路由配置中有此路径)
break;
case 'client':
router.push('/client'); // 跳转至 ClientView (请确保路由配置中有此路径)
break;
default:
ElMessage.warning('未识别的角色权限,请联系管理员');
break;
}
}, 1000);
} else {
ElMessage.error(res.message || '登录失败');