feat: 修改端口
This commit is contained in:
71
frontend/app/web-gold/src/api/example.js
Normal file
71
frontend/app/web-gold/src/api/example.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 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 '@/api/config'
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user