2025-06-16 04:08:09 +00:00
|
|
|
import { Result } from '@/request/Result'
|
|
|
|
|
import {
|
|
|
|
|
get,
|
|
|
|
|
post,
|
|
|
|
|
postStream,
|
|
|
|
|
del,
|
|
|
|
|
put,
|
|
|
|
|
request,
|
|
|
|
|
download,
|
|
|
|
|
exportFile,
|
|
|
|
|
} from '@/request/chat/index'
|
2025-06-17 03:58:35 +00:00
|
|
|
import { type ChatProfile } from '@/api/type/chat'
|
2025-06-16 04:08:09 +00:00
|
|
|
import { type Ref } from 'vue'
|
|
|
|
|
|
2025-06-16 11:00:46 +00:00
|
|
|
import useStore from '@/stores'
|
|
|
|
|
const prefix: any = { _value: '/workspace/' }
|
|
|
|
|
Object.defineProperty(prefix, 'value', {
|
|
|
|
|
get: function () {
|
|
|
|
|
const { user } = useStore()
|
|
|
|
|
return this._value + user.getWorkspaceId() + '/application'
|
|
|
|
|
},
|
|
|
|
|
})
|
2025-06-16 04:08:09 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 打开调试对话id
|
|
|
|
|
* @param application_id 应用id
|
|
|
|
|
* @param loading 加载器
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
2025-06-17 03:58:35 +00:00
|
|
|
const open: (loading?: Ref<boolean>) => Promise<Result<string>> = (loading) => {
|
|
|
|
|
return get('/open', {}, loading)
|
|
|
|
|
|
2025-06-16 04:08:09 +00:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 对话
|
|
|
|
|
* @param 参数
|
|
|
|
|
* chat_id: string
|
|
|
|
|
* data
|
|
|
|
|
*/
|
|
|
|
|
const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
|
2025-06-17 03:58:35 +00:00
|
|
|
return postStream(`/chat/api/chat_message/${chat_id}`, data)
|
2025-06-16 04:08:09 +00:00
|
|
|
}
|
2025-06-17 03:58:35 +00:00
|
|
|
const chatProfile: (assessToken: string, loading?: Ref<boolean>) => Promise<Result<ChatProfile>> = (
|
2025-06-16 04:08:09 +00:00
|
|
|
assessToken,
|
|
|
|
|
loading,
|
|
|
|
|
) => {
|
2025-06-17 03:58:35 +00:00
|
|
|
return get('/profile', { access_token: assessToken }, loading)
|
2025-06-16 04:08:09 +00:00
|
|
|
}
|
2025-06-17 03:58:35 +00:00
|
|
|
/**
|
|
|
|
|
* 匿名认证
|
|
|
|
|
* @param assessToken
|
|
|
|
|
* @param loading
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
const anonymousAuthentication: (
|
|
|
|
|
assessToken: string,
|
|
|
|
|
loading?: Ref<boolean>,
|
|
|
|
|
) => Promise<Result<any>> = (assessToken, loading) => {
|
|
|
|
|
return post('/auth/anonymous', { access_token: assessToken }, {}, loading)
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 获取应用相关信息
|
|
|
|
|
* @param loading
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
const applicationProfile: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
|
|
|
|
|
return get('/application/profile', {}, loading)
|
2025-06-16 04:08:09 +00:00
|
|
|
}
|
|
|
|
|
export default {
|
|
|
|
|
open,
|
|
|
|
|
chat,
|
|
|
|
|
chatProfile,
|
2025-06-17 03:58:35 +00:00
|
|
|
anonymousAuthentication,
|
|
|
|
|
applicationProfile,
|
2025-06-16 04:08:09 +00:00
|
|
|
}
|