fix: 改用hash路由解决SPA回退到首页问题 + 修复登录API响应解析

This commit is contained in:
Agent
2026-07-14 20:10:36 +08:00
parent c469f0a137
commit 9cafd5ca78
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import AdminLayout from '@/views/admin/AdminLayout.vue'
import AdminDashboard from '@/views/admin/Dashboard.vue'
@@ -8,7 +8,7 @@ import AdminSettings from '@/views/admin/Settings.vue'
import AdminLogin from '@/views/admin/Login.vue'
const router = createRouter({
history: createWebHistory(),
history: createWebHashHistory(),
routes: [
{ path: '/', name: 'home', component: Home },
{ path: '/admin/login', name: 'login', component: AdminLogin },
+2 -1
View File
@@ -41,7 +41,8 @@ async function handleLogin() {
loading.value = true
try {
const res = await authApi.login(form.value)
store.setToken(res.data.token)
const token = res.result.token
store.setToken(token)
await store.fetchProfile()
ElMessage.success('登录成功')
router.push('/admin/dashboard')