/** * API 使用示例 * 此文件仅作为参考,展示如何使用统一的 API 管理 */ // ========== 方式一:从统一入口导入(推荐) ========== import { ChatMessageApi, CommonService, TikhubService, API_BASE, getApiUrl, http } from '@/api' // 使用示例 async function example1() { // 使用 ChatMessageApi const conversationId = await ChatMessageApi.createChatConversationMy({ roleId: 1 }) // 使用 CommonService const result = await CommonService.videoToCharacters({ videoUrl: 'xxx' }) // 使用 TikhubService await TikhubService.postTikHup({ type: 'DOUYIN_WEB_HOT_SEARCH', methodType: 'GET', urlParams: { keyword: '测试' } }) // 使用配置 const baseUrl = API_BASE.ADMIN_AI const fullUrl = getApiUrl('ADMIN_AI', '/chat/conversation/create-my') // 直接使用 http 实例 await http.get('/some-endpoint') } // ========== 方式二:从具体文件导入(兼容旧代码) ========== import { ChatMessageApi } from '@/api/chat' import { CommonService } from '@/api/common' // 使用公共配置 import { API_BASE } from '@gold/config/api' async function example2() { // 原有方式仍然可用 await ChatMessageApi.createChatConversationMy({ roleId: 1 }) } // ========== 方式三:按需导入认证 API ========== import { loginBySms, sendSmsCode, SMS_SCENE } from '@/api' async function example3() { // 发送验证码 await sendSmsCode('13800138000', SMS_SCENE.MEMBER_LOGIN) // 短信登录 await loginBySms('13800138000', '123456') } export default { example1, example2, example3 }