feat: 添加 API 客户端以处理 basePath 并更新所有 fetch 调用

移除 next.config.js 中的 standalone 输出配置,添加 lib/api-client.ts 封装 fetch 请求,
自动为所有 API 调用添加配置的 basePath。更新所有页面和组件中的 fetch 调用以使用新的 fetchApi 函数,
确保在部署到子路径时 API 请求能正确工作。同时调整 tsconfig.json 的格式并修复项目创建时的字段名。
This commit is contained in:
2026-01-28 15:54:19 +08:00
parent 7948b1afc7
commit fc9cfda29e
21 changed files with 118 additions and 65 deletions

View File

@@ -23,6 +23,7 @@ import {
Legend,
} from 'recharts';
import { BarChart3, PieChart as PieChartIcon, TrendingUp, Users, Target } from 'lucide-react';
import { fetchApi } from '@/lib/api-client';
interface KRWithRelations extends KR {
owner: User | null;
@@ -48,10 +49,10 @@ export default function AnalysisPage() {
async function fetchData() {
try {
const [projectsRes, krsRes, checkinsRes, usersRes] = await Promise.all([
fetch('/api/projects'),
fetch('/api/krs'),
fetch('/api/checkins?limit=100'),
fetch('/api/users'),
fetchApi('/api/projects'),
fetchApi('/api/krs'),
fetchApi('/api/checkins?limit=100'),
fetchApi('/api/users'),
]);
if (projectsRes.ok) setProjects(await projectsRes.json());