refactor(admin): 合并管理后台并移除 apps/agent

- 平台与代理共用 apps/admin,统一登录 manage/auth/login
- 按 userType 展示菜单,修复 token 循环跳转
- 删除独立 apps/agent 前端工程

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 17:50:58 +08:00
parent b5dca1bfb1
commit 31737286b9
34 changed files with 363 additions and 255 deletions

View File

@@ -1,9 +1,30 @@
import axios from 'axios';
import router from './router';
import { clearStaffSession } from './stores/auth';
const api = axios.create({ baseURL: '/api' });
api.interceptors.request.use((c) => {
const t = localStorage.getItem('admin_token');
if (t) c.headers.Authorization = `Bearer ${t}`;
return c;
let handling401 = false;
api.interceptors.request.use((config) => {
const t = localStorage.getItem('manage_token');
if (t) config.headers.Authorization = `Bearer ${t}`;
return config;
});
api.interceptors.response.use(
(res) => res,
async (err) => {
if (err.response?.status === 401 && !handling401) {
handling401 = true;
clearStaffSession();
if (router.currentRoute.value.path !== '/login') {
await router.replace('/login');
}
handling401 = false;
}
return Promise.reject(err);
},
);
export default api;