UnisKB/ui/src/api/chat/chat.ts

62 lines
1.3 KiB
TypeScript
Raw Normal View History

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'
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
*/
const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<string>> = (
application_id,
loading,
) => {
2025-06-16 11:00:46 +00:00
return get(`${prefix.value}/${application_id}/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) => {
return postStream(`/api/chat_message/${chat_id}`, data)
}
const chatProfile: (assessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
assessToken,
loading,
) => {
return get('/auth/profile', { access_token: assessToken }, loading)
}
const applicationProfile: (assessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
assessToken,
loading,
) => {
return get('/chat/api/profile')
}
export default {
open,
chat,
chatProfile,
}