fix: restore reproducible frontend builds

This commit is contained in:
stefanfeng
2026-08-19 14:56:39 +08:00
parent 68ea87e1b2
commit 6bf446f889
8 changed files with 153 additions and 139 deletions
+21 -4
View File
@@ -1,4 +1,11 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'
import axios, { AxiosRequestConfig } from 'axios'
interface ApiClient {
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>
post<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>
put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>
}
// API 基址:优先级 window.__APP_CONFIG__.apiBase > 环境变量 > 默认 '/api'
// - 开发/Vite 代理:'/api'(由 vite.config 代理到后端 :8000)
@@ -22,7 +29,7 @@ export function getAuthToken(): string | null {
}
// 创建 axios 实例(复用现有项目模式)
const createRequest = (config?: AxiosRequestConfig): AxiosInstance => {
const createRequest = (config?: AxiosRequestConfig): ApiClient => {
const request = axios.create({
baseURL: resolveBaseURL(),
timeout: 30000,
@@ -59,7 +66,8 @@ const createRequest = (config?: AxiosRequestConfig): AxiosInstance => {
}
)
return request
// The response interceptor unwraps the API envelope before callers receive it.
return request as unknown as ApiClient
}
// 递归修复时区标识(复用现有项目逻辑)
@@ -162,17 +170,26 @@ export interface Organization {
id: string
name: string
description: string
emoji: string
type: 'team' | 'company' | 'community'
role: 'admin' | 'member' | 'viewer'
memberCount: number
createdAt: string
}
export interface CreateOrganizationInput {
name: string
desc?: string
emoji?: string
type?: 'team' | 'company' | 'community'
}
// 获取组织列表
export const getOrganizationList = (params?: any) =>
request.get<{ data: Organization[]; total: number }>('/organizations', { params })
// 创建组织
export const createOrganization = (data: Partial<Organization>) =>
export const createOrganization = (data: CreateOrganizationInput) =>
request.post<Organization>('/organizations', data)
// ==================== 知识库管理 API ====================