PayrollManagementSystem/frontend/vite.config.ts
liuwenxin 273ebf4657 chore: 初始化项目结构与登录鉴权模块
后端 FastAPI 六层结构(api/services/repositories/models/schemas/core),
统一响应信封、全局异常、日志脱敏;6 张表经 Alembic 迁移建库,SQL 留存
db/migration;登录鉴权含图形验证码(Redis GETDEL 防重放)、JWT、登录限流、
登出黑名单(TTL=令牌剩余有效期)、登录日志。

前端 Vue3 + TS + Element Plus 骨架,含登录页、路由守卫、请求封装与 Vite 代理。

工程配置:uv 锁定 Python 3.12、ruff 检查与格式化、editorconfig、gitattributes。

测试 184 项(单元 155 / 集成 29)全绿,浏览器端到端 8 项通过。

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-09 18:46:36 +08:00

38 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv } from 'vite'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: Number(env.VITE_PORT ?? 5173),
// 显式绑定 IPv4 回环。不指定时 Vite 在本机只监听 [::1]:5173,
// 于是 localhost:5173 能开、127.0.0.1:5173 却连不上 ——
// 这种"换个写法就坏"的差异排查起来很费时间。
host: '127.0.0.1',
proxy: {
// 后端路由本身带 /api 前缀,因此不做 rewrite
//
// 目标地址用 127.0.0.1 而非 localhost:Node 17+ 对 localhost 优先解析
// IPv6 的 ::1,而 uvicorn 默认只监听 127.0.0.1,用 localhost 会连不上。
//
// 开发期走代理而非后端 CORS,符合规范「跨域在网关统一处理」;
// 副作用是 /api/docs(Swagger)也能从 5173 端口打开,联调期只用一个域名。
'/api': {
target: 'http://127.0.0.1:8000',
changeOrigin: true,
},
},
},
}
})