feat(frontend): S0 Vue3 脚手架 + auth + Layout shell(4入口,模拟/实盘灰显)

- Vite+TS+ElementPlus+ECharts+Pinia+Router+Axios
- auth store + JWT axios 拦截器 + 路由守卫
- 登录页 + Layout(侧栏 4 入口,回测/投研 active,模拟/实盘 disabled)
- 占位页(backtest/factor,S1/S2 填充)
- vitest auth store 3 tests passed + build 通过(dist 生成)
This commit is contained in:
2026-07-07 05:56:24 +08:00
parent 22fa87d4ab
commit a5b00c2dea
25 changed files with 837 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import axios, { AxiosError } from 'axios'
import { useAuthStore } from '@/stores/auth'
import { router } from '@/router'
export const apiClient = axios.create({
baseURL: '/api/v1',
timeout: 60000,
})
apiClient.interceptors.request.use((config) => {
const auth = useAuthStore()
if (auth.token) {
config.headers.Authorization = `Bearer ${auth.token}`
}
return config
})
apiClient.interceptors.response.use(
(response) => response,
(error: AxiosError) => {
if (error.response?.status === 401) {
const auth = useAuthStore()
auth.logout()
router.push('/login')
}
return Promise.reject(error)
},
)