feat: 功能
This commit is contained in:
51
frontend/config/api.js
Normal file
51
frontend/config/api.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 公共 API 基础配置
|
||||
* 统一管理所有 API 的基础 URL
|
||||
* 可在各个应用中通过 @gold/config/api 引用
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取基础 URL(从环境变量读取)
|
||||
* @returns {string}
|
||||
*/
|
||||
function getBaseUrl() {
|
||||
// 支持在浏览器环境和 Node 环境
|
||||
if (typeof import.meta !== 'undefined' && import.meta.env) {
|
||||
return import.meta.env.VITE_BASE_URL || ''
|
||||
}
|
||||
// 如果是在 Node 环境或 SSR,可以从 process.env 读取
|
||||
if (typeof process !== 'undefined' && process.env) {
|
||||
return process.env.VITE_BASE_URL || ''
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
const BASE_URL = getBaseUrl()
|
||||
|
||||
/**
|
||||
* API 基础路径配置
|
||||
*/
|
||||
export const API_BASE = {
|
||||
// 会员端 API
|
||||
APP: `${BASE_URL}`,
|
||||
// 具体模块路径
|
||||
ADMIN_AI: `${BASE_URL}/admin-api/ai`,
|
||||
APP_MEMBER: `${BASE_URL}/app-api/member`,
|
||||
|
||||
// 特殊路径
|
||||
TIKHUB_APP: `${BASE_URL}/api/tikHup`,
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取完整的 API 路径
|
||||
* @param {string} module - 模块名称 (如 'ADMIN_AI', 'APP_MEMBER')
|
||||
* @param {string} path - 接口路径 (如 '/chat/conversation/create-my')
|
||||
* @returns {string} 完整的 API URL
|
||||
*/
|
||||
export function getApiUrl(module, path) {
|
||||
const base = API_BASE[module] || API_BASE.APP
|
||||
return `${base}${path.startsWith('/') ? path : '/' + path}`
|
||||
}
|
||||
|
||||
export default API_BASE
|
||||
|
||||
52
frontend/config/types.ts
Normal file
52
frontend/config/types.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 公共类型定义
|
||||
* 可在 monorepo 各个应用中复用
|
||||
*/
|
||||
|
||||
/**
|
||||
* 音频项接口
|
||||
*/
|
||||
export interface AudioItem {
|
||||
audio_url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 转录结果接口
|
||||
*/
|
||||
export interface TranscriptionResult {
|
||||
key: string
|
||||
audio_url?: string
|
||||
value: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频转字符请求参数
|
||||
*/
|
||||
export interface VideoToCharactersRequest {
|
||||
fileLinkList: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频转字符响应接口
|
||||
*/
|
||||
export interface VideoToCharactersResponse {
|
||||
data: string // JSON 字符串,包含 results 数组
|
||||
}
|
||||
|
||||
/**
|
||||
* 转录响应结果
|
||||
*/
|
||||
export interface TranscriptionResponse {
|
||||
results: Array<{
|
||||
transcription_url: string
|
||||
}>
|
||||
}
|
||||
|
||||
/**
|
||||
* 转录数据接口
|
||||
*/
|
||||
export interface TranscriptionData {
|
||||
file_url?: string
|
||||
transcripts?: Array<{ text: string }>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user