diff --git a/frontend/src/config/api-config.ts b/frontend/src/config/api-config.ts new file mode 100644 index 0000000..f06e944 --- /dev/null +++ b/frontend/src/config/api-config.ts @@ -0,0 +1,7 @@ +export const API_CONFIG = { + // 优先使用运行时注入的 window.__ENV,其次使用构建时的环境变量,最后回退到默认值 + BASE_URL: + (typeof window !== "undefined" && window.__ENV?.NEXT_PUBLIC_API_BASE_URL) + ? window.__ENV.NEXT_PUBLIC_API_BASE_URL + : (process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8091/api/v1"), +}; diff --git a/frontend/src/types/api.ts b/frontend/src/types/api.ts new file mode 100644 index 0000000..7a92801 --- /dev/null +++ b/frontend/src/types/api.ts @@ -0,0 +1,31 @@ +export interface Response { + code: string; + info: string; + data: T; +} + +export interface AiAgentConfigResponseDTO { + agentId: string; + agentName: string; + agentDesc: string; +} + +export interface CreateSessionRequestDTO { + agentId: string; + userId: string; +} + +export interface CreateSessionResponseDTO { + sessionId: string; +} + +export interface ChatRequestDTO { + agentId: string; + userId: string; + sessionId: string; + message: string; +} + +export interface ChatResponseDTO { + content: string; +} diff --git a/frontend/src/types/env.d.ts b/frontend/src/types/env.d.ts new file mode 100644 index 0000000..759c9bc --- /dev/null +++ b/frontend/src/types/env.d.ts @@ -0,0 +1,9 @@ +declare global { + interface Window { + __ENV?: { + NEXT_PUBLIC_API_BASE_URL: string; + }; + } +} + +export {};