fix: 改用hash路由解决SPA回退到首页问题 + 修复登录API响应解析
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user