|
@@ -51,14 +51,14 @@ export default {
|
|
try {
|
|
try {
|
|
const response = await userLoginPost({ username: username.value, password: password.value });
|
|
const response = await userLoginPost({ username: username.value, password: password.value });
|
|
localStorage.setItem('token', response.token);
|
|
localStorage.setItem('token', response.token);
|
|
- authStore.setUser(response.user);
|
|
|
|
- authStore.login();
|
|
|
|
|
|
+ //authStore.setUser(response.user);
|
|
|
|
+ //authStore.login();
|
|
|
|
|
|
- if (response.user.role === 'admin') {
|
|
|
|
- router.push('/admin');
|
|
|
|
- } else {
|
|
|
|
- router.push('/');
|
|
|
|
- }
|
|
|
|
|
|
+// if (response.user.role === 'admin') {
|
|
|
|
+// router.push('/admin');
|
|
|
|
+// } else {
|
|
|
|
+// router.push('/');
|
|
|
|
+ router.push('/');
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('Login failed:', error);
|
|
console.error('Login failed:', error);
|
|
alert('登录失败:' + (error.response?.data?.message || error.message));
|
|
alert('登录失败:' + (error.response?.data?.message || error.message));
|