af-mobile-client-vue3 1.4.53 → 1.4.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/vite/optimize.ts +36 -36
- package/package.json +1 -1
- package/public/favicon.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/App.vue +14 -2
- package/src/components/common/MateChat/apiService.ts +285 -0
- package/src/components/common/MateChat/assets/035-avatar-13.svg +1 -0
- package/src/components/common/MateChat/components/MateChatContent.vue +281 -0
- package/src/components/common/MateChat/components/MateChatHeader.vue +298 -0
- package/src/components/common/MateChat/components/PasswordDialog.vue +97 -0
- package/src/components/common/MateChat/components/PromptList/PromptList.vue +189 -0
- package/src/components/common/MateChat/components/PromptList/index.ts +1 -0
- package/src/components/common/MateChat/composables/useChatHistoryCache.ts +117 -0
- package/src/components/common/MateChat/composables/useChatMessagesCache.ts +72 -0
- package/src/components/common/MateChat/composables/useMateChat.ts +372 -0
- package/src/components/common/MateChat/composables/usePasswordManager.ts +38 -0
- package/src/components/common/MateChat/index.vue +429 -0
- package/src/components/common/MateChat/types.ts +236 -0
- package/src/components/common/otherCharge/ChargePrintSelectorAndRemarks.vue +137 -137
- package/src/components/common/otherCharge/CodePayment.vue +357 -357
- package/src/components/common/otherCharge/FileUploader.vue +602 -602
- package/src/components/common/otherCharge/GridFileUploader.vue +846 -846
- package/src/components/common/otherCharge/PaymentMethodSelector.vue +202 -202
- package/src/components/common/otherCharge/PaymentMethodSelectorCard.vue +45 -45
- package/src/components/common/otherCharge/ReceiptModal.vue +273 -273
- package/src/components/common/otherCharge/index.ts +43 -43
- package/src/components/data/OtherCharge/OtherChargeItemModal.vue +547 -547
- package/src/components/data/UserDetail/types.ts +1 -1
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/hooks/useCommon.ts +9 -9
- package/src/plugins/AppData.ts +38 -38
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/MateChat/MateChatView.vue +10 -254
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XCellListView/index.vue +107 -138
- package/src/views/component/XFormGroupView/index.vue +78 -82
- package/src/views/component/XFormView/index.vue +41 -46
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/index.vue +22 -22
- package/vite.config.ts +2 -1
- package/src/views/component/MateChat/apiService.ts +0 -104
package/build/vite/optimize.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const include = [
|
|
2
|
-
'axios',
|
|
3
|
-
'echarts',
|
|
4
|
-
'lodash-es',
|
|
5
|
-
'resize-detector',
|
|
6
|
-
'vant/es',
|
|
7
|
-
'vant/es/cell-group/style/index',
|
|
8
|
-
'vant/es/popup/style/index',
|
|
9
|
-
'vant/es/picker/style/index',
|
|
10
|
-
'vant/es/cell/style/index',
|
|
11
|
-
'vant/es/switch/style/index',
|
|
12
|
-
'vant/es/space/style/index',
|
|
13
|
-
'vant/es/button/style/index',
|
|
14
|
-
'vant/es/empty/style/index',
|
|
15
|
-
'vant/es/icon/style/index',
|
|
16
|
-
'vant/es/stepper/style/index',
|
|
17
|
-
'vant/es/image/style/index',
|
|
18
|
-
'vant/es/form/style/index',
|
|
19
|
-
'vant/es/field/style/index',
|
|
20
|
-
'vant/es/notify/style/index',
|
|
21
|
-
'vant/es/config-provider/style/index',
|
|
22
|
-
'vant/es/nav-bar/style/index',
|
|
23
|
-
'vant/es/tabbar/style/index',
|
|
24
|
-
'vant/es/tabbar-item/style/index',
|
|
25
|
-
'vant/es/list/style/index',
|
|
26
|
-
'vant/es/text-ellipsis/style/index',
|
|
27
|
-
// 确保 @matechat/core 及其依赖 xss 被正确预构建
|
|
28
|
-
'@matechat/core',
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
const exclude = [
|
|
32
|
-
'@iconify/json',
|
|
33
|
-
'@iconify/vue',
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
export { exclude, include }
|
|
1
|
+
const include = [
|
|
2
|
+
'axios',
|
|
3
|
+
'echarts',
|
|
4
|
+
'lodash-es',
|
|
5
|
+
'resize-detector',
|
|
6
|
+
'vant/es',
|
|
7
|
+
'vant/es/cell-group/style/index',
|
|
8
|
+
'vant/es/popup/style/index',
|
|
9
|
+
'vant/es/picker/style/index',
|
|
10
|
+
'vant/es/cell/style/index',
|
|
11
|
+
'vant/es/switch/style/index',
|
|
12
|
+
'vant/es/space/style/index',
|
|
13
|
+
'vant/es/button/style/index',
|
|
14
|
+
'vant/es/empty/style/index',
|
|
15
|
+
'vant/es/icon/style/index',
|
|
16
|
+
'vant/es/stepper/style/index',
|
|
17
|
+
'vant/es/image/style/index',
|
|
18
|
+
'vant/es/form/style/index',
|
|
19
|
+
'vant/es/field/style/index',
|
|
20
|
+
'vant/es/notify/style/index',
|
|
21
|
+
'vant/es/config-provider/style/index',
|
|
22
|
+
'vant/es/nav-bar/style/index',
|
|
23
|
+
'vant/es/tabbar/style/index',
|
|
24
|
+
'vant/es/tabbar-item/style/index',
|
|
25
|
+
'vant/es/list/style/index',
|
|
26
|
+
'vant/es/text-ellipsis/style/index',
|
|
27
|
+
// 确保 @matechat/core 及其依赖 xss 被正确预构建
|
|
28
|
+
'@matechat/core',
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
const exclude = [
|
|
32
|
+
'@iconify/json',
|
|
33
|
+
'@iconify/vue',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
export { exclude, include }
|
package/package.json
CHANGED
package/public/favicon.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg t="1709866807903" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4913" width="32" height="32">
|
|
2
|
-
<path d="M512 598.528a111.232 111.232 0 0 0-111.232 111.2064V870.4h222.464v-160.6656c0-61.44-49.792-111.232-111.232-111.232z m0 58.0608c-30.72 0-55.6032 24.9088-55.6032 55.6288v105.0368h111.2064v-105.0368c0-30.72-24.8832-55.6288-55.6032-55.6288z" fill="#FB4D31" p-id="4914"></path>
|
|
3
|
-
<path d="M542.08 270.208l45.2608-78.5408a24.5248 24.5248 0 0 0 0-25.6A26.4448 26.4448 0 0 0 564.1472 153.6a26.3424 26.3424 0 0 0-22.5792 13.44L512 217.6256l-29.5424-50.5344c-4.5824-8.192-13.184-13.312-22.5536-13.4912a26.4448 26.4448 0 0 0-23.2448 12.4928 24.5248 24.5248 0 0 0 0 25.6l45.2352 78.5152L156.928 832.768a24.4736 24.4736 0 0 0 0.3328 25.088c4.8384 7.8336 13.3888 12.544 22.5792 12.5184h664.3456c9.3184 0 17.92-4.7616 22.6304-12.4672a24.4736 24.4736 0 0 0 0.3072-25.088l-325.0176-562.688v0.0512zM619.52 816.64h-33.3568c-12.3648 0-9.6768 0.1024-65.0496 0H512c-55.3728 0.1024-24.704 0-61.7984 0H225.28L512 322.1248 798.72 816.64h-179.2z" fill="#000000" p-id="4915"></path>
|
|
4
|
-
</svg>
|
|
1
|
+
<svg t="1709866807903" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4913" width="32" height="32">
|
|
2
|
+
<path d="M512 598.528a111.232 111.232 0 0 0-111.232 111.2064V870.4h222.464v-160.6656c0-61.44-49.792-111.232-111.232-111.232z m0 58.0608c-30.72 0-55.6032 24.9088-55.6032 55.6288v105.0368h111.2064v-105.0368c0-30.72-24.8832-55.6288-55.6032-55.6288z" fill="#FB4D31" p-id="4914"></path>
|
|
3
|
+
<path d="M542.08 270.208l45.2608-78.5408a24.5248 24.5248 0 0 0 0-25.6A26.4448 26.4448 0 0 0 564.1472 153.6a26.3424 26.3424 0 0 0-22.5792 13.44L512 217.6256l-29.5424-50.5344c-4.5824-8.192-13.184-13.312-22.5536-13.4912a26.4448 26.4448 0 0 0-23.2448 12.4928 24.5248 24.5248 0 0 0 0 25.6l45.2352 78.5152L156.928 832.768a24.4736 24.4736 0 0 0 0.3328 25.088c4.8384 7.8336 13.3888 12.544 22.5792 12.5184h664.3456c9.3184 0 17.92-4.7616 22.6304-12.4672a24.4736 24.4736 0 0 0 0.3072-25.088l-325.0176-562.688v0.0512zM619.52 816.64h-33.3568c-12.3648 0-9.6768 0.1024-65.0496 0H512c-55.3728 0.1024-24.704 0-61.7984 0H225.28L512 322.1248 798.72 816.64h-179.2z" fill="#000000" p-id="4915"></path>
|
|
4
|
+
</svg>
|
package/scripts/verifyCommit.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
|
|
3
|
-
// import process from 'node:process'
|
|
4
|
-
|
|
5
|
-
const msg = fs.readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
|
|
6
|
-
|
|
7
|
-
const commitRE = /^(?:revert: )?(?:feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(?:\(.+\))?: .{1,50}/
|
|
8
|
-
// const mergeRe = /^(Merge pull request|Merge branch)/
|
|
9
|
-
|
|
10
|
-
if (!commitRE.test(msg)) {
|
|
11
|
-
// if (!mergeRe.test(msg)) {
|
|
12
|
-
// console.log('git commit unpass')
|
|
13
|
-
// console.error('git commit error, needs title(scope): desc')
|
|
14
|
-
// process.exit(1)
|
|
15
|
-
// }
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
console.log('git commit pass')
|
|
19
|
-
}
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
|
|
3
|
+
// import process from 'node:process'
|
|
4
|
+
|
|
5
|
+
const msg = fs.readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
|
|
6
|
+
|
|
7
|
+
const commitRE = /^(?:revert: )?(?:feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(?:\(.+\))?: .{1,50}/
|
|
8
|
+
// const mergeRe = /^(Merge pull request|Merge branch)/
|
|
9
|
+
|
|
10
|
+
if (!commitRE.test(msg)) {
|
|
11
|
+
// if (!mergeRe.test(msg)) {
|
|
12
|
+
// console.log('git commit unpass')
|
|
13
|
+
// console.error('git commit error, needs title(scope): desc')
|
|
14
|
+
// process.exit(1)
|
|
15
|
+
// }
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log('git commit pass')
|
|
19
|
+
}
|
package/src/App.vue
CHANGED
|
@@ -7,9 +7,21 @@ import { useHead } from '@unhead/vue'
|
|
|
7
7
|
import {
|
|
8
8
|
ConfigProvider as VanConfigProvider,
|
|
9
9
|
} from 'vant/es'
|
|
10
|
-
import { computed } from 'vue'
|
|
10
|
+
import { computed, getCurrentInstance } from 'vue'
|
|
11
|
+
import { useRoute } from 'vue-router'
|
|
11
12
|
import { appDescription, appName } from './constants'
|
|
12
13
|
|
|
14
|
+
const instance = getCurrentInstance()
|
|
15
|
+
const route = useRoute()
|
|
16
|
+
|
|
17
|
+
// 是否使用 fullPath 作为 component key
|
|
18
|
+
// 配置:是否使用 fullPath 作为 router-view 的 component key
|
|
19
|
+
// 该配置作用为:区分keep-alive缓存组件,为true时 如果跳转相同的缓存组件但是url携带参数不同 就会进行区分。反之则会只会根据路由名称进行命中
|
|
20
|
+
// 普通走基座的项目无需进行设置,只有特殊的单项目部署的服务 需要固定缓存顶层组件时进行开启,例如微信-开启方式在自己项目的main.ts中增加 app.config.globalProperties.$useFullPathKey = false
|
|
21
|
+
const useFullPathKey = computed(() => {
|
|
22
|
+
return instance?.appContext.config.globalProperties.$useFullPathKey ?? true
|
|
23
|
+
})
|
|
24
|
+
|
|
13
25
|
useHead({
|
|
14
26
|
title: appName,
|
|
15
27
|
meta: [
|
|
@@ -48,7 +60,7 @@ const mode = computed(() => {
|
|
|
48
60
|
<router-view v-slot="{ Component }">
|
|
49
61
|
<section class="app-wrapper">
|
|
50
62
|
<keep-alive :include="keepAliveRouteNames" :max="5">
|
|
51
|
-
<component :is="Component" :key="
|
|
63
|
+
<component :is="Component" :key="useFullPathKey ? route.fullPath : undefined" />
|
|
52
64
|
</keep-alive>
|
|
53
65
|
</section>
|
|
54
66
|
</router-view>
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatBizResult,
|
|
3
|
+
ChatCompletionsRequest,
|
|
4
|
+
ChatCompletionsResponse,
|
|
5
|
+
ChatStreamCallbacks,
|
|
6
|
+
GetHistoriesRequest,
|
|
7
|
+
GetHistoriesResponse,
|
|
8
|
+
GetPaginationRecordsRequest,
|
|
9
|
+
GetPaginationRecordsResponse,
|
|
10
|
+
} from '@af-mobile-client-vue3/components/common/MateChat/types'
|
|
11
|
+
import type { AxiosInstance } from 'axios'
|
|
12
|
+
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
13
|
+
import axios from 'axios'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 创建独立的 axios 实例,不经过拦截器
|
|
17
|
+
*/
|
|
18
|
+
const chatAxiosInstance: AxiosInstance = axios.create({
|
|
19
|
+
baseURL: import.meta.env.VITE_APP_API_BASE_URL || '',
|
|
20
|
+
timeout: 20000,
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 生成 outLinkUid:用户类型 + 用户ID
|
|
28
|
+
* @returns outLinkUid 字符串,格式:用户类型_用户ID
|
|
29
|
+
*/
|
|
30
|
+
export function generateOutLinkUid(): string {
|
|
31
|
+
const userStore = useUserStore()
|
|
32
|
+
const userInfo = userStore.getUserInfo()
|
|
33
|
+
const userType = userStore.getUserType()
|
|
34
|
+
|
|
35
|
+
// 用户类型:SYSTEM 或 EXTERNAL,如果为 null 则默认为 SYSTEM
|
|
36
|
+
const type = userType || 'SYSTEM'
|
|
37
|
+
// 用户ID
|
|
38
|
+
const userId = userInfo?.id || ''
|
|
39
|
+
|
|
40
|
+
return `${type}_${userId}`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 发送聊天请求
|
|
45
|
+
* @param content 用户输入的内容
|
|
46
|
+
* @param appId FastGPT 应用 ID
|
|
47
|
+
* @param appKey FastGPT API Key
|
|
48
|
+
* @param chatId 会话 ID
|
|
49
|
+
* @returns Promise<ChatCompletionsResponse>
|
|
50
|
+
*/
|
|
51
|
+
export function chatCompletions(
|
|
52
|
+
content: string,
|
|
53
|
+
appId: string,
|
|
54
|
+
appKey: string,
|
|
55
|
+
chatId: string,
|
|
56
|
+
): Promise<ChatCompletionsResponse> {
|
|
57
|
+
const requestData: ChatCompletionsRequest = {
|
|
58
|
+
chatId,
|
|
59
|
+
stream: false,
|
|
60
|
+
detail: false,
|
|
61
|
+
messages: [
|
|
62
|
+
{
|
|
63
|
+
role: 'user',
|
|
64
|
+
content,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
customUid: generateOutLinkUid(),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return chatAxiosInstance.post<ChatCompletionsResponse>(
|
|
71
|
+
'/fastApi/v1/chat/completions',
|
|
72
|
+
requestData,
|
|
73
|
+
{
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${appKey}`,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
).then(response => response.data)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 封装后的业务聊天请求
|
|
83
|
+
* - 负责从大模型返回中解析出业务含义(普通回复 / 转人工)
|
|
84
|
+
* - UI 层只需要根据 type 决定渲染哪种气泡
|
|
85
|
+
* @param content 用户输入的内容
|
|
86
|
+
* @param appId FastGPT 应用 ID
|
|
87
|
+
* @param appKey FastGPT API Key
|
|
88
|
+
* @param chatId 会话 ID
|
|
89
|
+
*/
|
|
90
|
+
export async function chatBiz(
|
|
91
|
+
content: string,
|
|
92
|
+
appId: string,
|
|
93
|
+
appKey: string,
|
|
94
|
+
chatId: string,
|
|
95
|
+
): Promise<ChatBizResult> {
|
|
96
|
+
const response = await chatCompletions(content, appId, appKey, chatId)
|
|
97
|
+
|
|
98
|
+
if (!response.choices || response.choices.length === 0) {
|
|
99
|
+
throw new Error('响应数据格式错误')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const text = response.choices[0].message.content
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const parsed = JSON.parse(text) as { msgType?: string }
|
|
106
|
+
if (parsed.msgType === 'transfer') {
|
|
107
|
+
return {
|
|
108
|
+
type: 'transfer',
|
|
109
|
+
content: text,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// 忽略解析错误,按普通文本处理
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
type: 'normal',
|
|
119
|
+
content: text,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 使用 FastGPT /v1/chat/completions 的 stream=true 进行流式对话
|
|
125
|
+
* 参考官方文档: https://doc.fastgpt.io/docs/introduction/development/openapi/chat
|
|
126
|
+
* @param content 用户输入的内容
|
|
127
|
+
* @param appId FastGPT 应用 ID
|
|
128
|
+
* @param appKey FastGPT API Key
|
|
129
|
+
* @param chatId 会话 ID
|
|
130
|
+
* @param callbacks 流式回调函数
|
|
131
|
+
*/
|
|
132
|
+
export async function chatCompletionsStream(
|
|
133
|
+
content: string,
|
|
134
|
+
appId: string,
|
|
135
|
+
appKey: string,
|
|
136
|
+
chatId: string,
|
|
137
|
+
callbacks: ChatStreamCallbacks,
|
|
138
|
+
): Promise<void> {
|
|
139
|
+
const { onMessage, onComplete, onError } = callbacks
|
|
140
|
+
|
|
141
|
+
const requestData: ChatCompletionsRequest = {
|
|
142
|
+
chatId,
|
|
143
|
+
stream: true,
|
|
144
|
+
detail: false,
|
|
145
|
+
messages: [
|
|
146
|
+
{
|
|
147
|
+
role: 'user',
|
|
148
|
+
content,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
customUid: generateOutLinkUid(),
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
const baseUrl = import.meta.env.VITE_APP_API_BASE_URL || ''
|
|
156
|
+
const res = await fetch(`${baseUrl}/fastApi/v1/chat/completions`, {
|
|
157
|
+
method: 'POST',
|
|
158
|
+
headers: {
|
|
159
|
+
'Content-Type': 'application/json',
|
|
160
|
+
'Authorization': `Bearer ${appKey}`,
|
|
161
|
+
},
|
|
162
|
+
body: JSON.stringify(requestData),
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
if (!res.ok || !res.body) {
|
|
166
|
+
throw new Error(`请求失败: ${res.status}`)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const reader = res.body.getReader()
|
|
170
|
+
const decoder = new TextDecoder('utf-8')
|
|
171
|
+
let buffer = ''
|
|
172
|
+
|
|
173
|
+
while (true) {
|
|
174
|
+
const { done, value } = await reader.read()
|
|
175
|
+
if (done)
|
|
176
|
+
break
|
|
177
|
+
|
|
178
|
+
buffer += decoder.decode(value, { stream: true })
|
|
179
|
+
const lines = buffer.split('\n')
|
|
180
|
+
buffer = lines.pop() ?? ''
|
|
181
|
+
|
|
182
|
+
for (const rawLine of lines) {
|
|
183
|
+
const line = rawLine.trim()
|
|
184
|
+
if (!line.startsWith('data:'))
|
|
185
|
+
continue
|
|
186
|
+
|
|
187
|
+
const dataStr = line.slice(5).trim()
|
|
188
|
+
if (!dataStr || dataStr === '[DONE]') {
|
|
189
|
+
onComplete?.()
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const json = JSON.parse(dataStr) as {
|
|
195
|
+
choices?: Array<{ delta?: { content?: string } }>
|
|
196
|
+
}
|
|
197
|
+
const delta = json.choices?.[0]?.delta
|
|
198
|
+
const chunkText = delta?.content || ''
|
|
199
|
+
if (chunkText) {
|
|
200
|
+
onMessage?.(chunkText)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (e) {
|
|
204
|
+
console.error('解析数据失败', e, dataStr)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
onComplete?.()
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
console.error('FastGPT 流式请求异常', error)
|
|
213
|
+
onError?.(error)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 获取历史会话列表
|
|
219
|
+
* @param appId FastGPT 应用 ID
|
|
220
|
+
* @param appKey FastGPT API Key
|
|
221
|
+
* @param offset 偏移量
|
|
222
|
+
* @param pageSize 每页数量
|
|
223
|
+
* @returns Promise<GetHistoriesResponse>
|
|
224
|
+
*/
|
|
225
|
+
export function getHistories(
|
|
226
|
+
appId: string,
|
|
227
|
+
appKey: string,
|
|
228
|
+
offset: number = 0,
|
|
229
|
+
pageSize: number = 5,
|
|
230
|
+
): Promise<GetHistoriesResponse> {
|
|
231
|
+
const requestData: GetHistoriesRequest = {
|
|
232
|
+
appId,
|
|
233
|
+
outLinkUid: generateOutLinkUid(),
|
|
234
|
+
offset,
|
|
235
|
+
pageSize,
|
|
236
|
+
source: 'api',
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return chatAxiosInstance.post<GetHistoriesResponse>(
|
|
240
|
+
'/fastApi/core/chat/getHistories',
|
|
241
|
+
requestData,
|
|
242
|
+
{
|
|
243
|
+
headers: {
|
|
244
|
+
Authorization: `Bearer ${appKey}`,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
).then(response => response.data)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 获取历史会话记录
|
|
252
|
+
* @param appId FastGPT 应用 ID
|
|
253
|
+
* @param appKey FastGPT API Key
|
|
254
|
+
* @param chatId 会话 ID
|
|
255
|
+
* @param offset 偏移量
|
|
256
|
+
* @param pageSize 每页数量
|
|
257
|
+
* @param loadCustomFeedbacks 是否加载自定义反馈
|
|
258
|
+
* @returns Promise<GetPaginationRecordsResponse>
|
|
259
|
+
*/
|
|
260
|
+
export function getPaginationRecords(
|
|
261
|
+
appId: string,
|
|
262
|
+
appKey: string,
|
|
263
|
+
chatId: string,
|
|
264
|
+
offset: number = 0,
|
|
265
|
+
pageSize: number = 10,
|
|
266
|
+
loadCustomFeedbacks: boolean = true,
|
|
267
|
+
): Promise<GetPaginationRecordsResponse> {
|
|
268
|
+
const requestData: GetPaginationRecordsRequest = {
|
|
269
|
+
appId,
|
|
270
|
+
chatId,
|
|
271
|
+
offset,
|
|
272
|
+
pageSize,
|
|
273
|
+
loadCustomFeedbacks,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return chatAxiosInstance.post<GetPaginationRecordsResponse>(
|
|
277
|
+
'/fastApi/core/chat/getPaginationRecords',
|
|
278
|
+
requestData,
|
|
279
|
+
{
|
|
280
|
+
headers: {
|
|
281
|
+
Authorization: `Bearer ${appKey}`,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
).then(response => response.data)
|
|
285
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1764664883478" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="17459" xmlns:xlink="http://www.w3.org/1999/xlink" width="192" height="192"><path d="M896 803.94V992H128v-188.06a128 128 0 0 1 96.96-124.18L384 640a57.878 57.878 0 0 0 32-51.78V480h192v108.22A57.878 57.878 0 0 0 640 640l159.04 39.76A128 128 0 0 1 896 803.94z" fill="#FDC8A2" p-id="17460"></path><path d="M608 480v101.34l-12.8 17.06c-1.02 1.36-2.08 2.66-3.2 3.92A63.984 63.984 0 0 1 544 624h-64a63.984 63.984 0 0 1-48-21.68c-1.12-1.26-2.18-2.56-3.2-3.92l-12.8-17.06V480z" fill="#FDBF92" p-id="17461"></path><path d="M873.72 731.78a128.2 128.2 0 0 0-74.68-52.02L640 640c-23.12 57.76-75.56 86.66-128 86.66s-104.88-28.9-128-86.66l-159.04 39.76A128 128 0 0 0 128 803.94V992h768v-188.06a127.624 127.624 0 0 0-22.28-72.16z" fill="#E9D6BB" p-id="17462"></path><path d="M672 240v186.66a64.034 64.034 0 0 1-12.8 38.4l-64 85.34c-1.02 1.36-2.08 2.66-3.2 3.92A63.984 63.984 0 0 1 544 576h-64a63.984 63.984 0 0 1-48-21.68c-1.12-1.26-2.18-2.56-3.2-3.92l-64-85.34a64.034 64.034 0 0 1-12.8-38.4V240c0-88.36 71.64-144 160-144 44.18 0 84.18 13.92 113.14 38.86S672 195.82 672 240z" fill="#FDC8A2" p-id="17463"></path><path d="M428 336a28 28 0 1 1 28-28 28.03 28.03 0 0 1-28 28zM596 336a28 28 0 1 1 28-28 28.03 28.03 0 0 1-28 28z" fill="#91563A" p-id="17464"></path><path d="M344 368h8v-112h-8a56 56 0 0 0-56 56 56 56 0 0 0 56 56zM680 256h-8v112h8a56 56 0 0 0 56-56 56 56 0 0 0-56-56z" fill="#FDB683" p-id="17465"></path><path d="M608 128l64 128V144a64 64 0 0 0-64-64zM352 256V128h64z" fill="#2B4266" p-id="17466"></path><path d="M608 80v48H352a79.75 79.75 0 0 1 23.44-56.56 81.26 81.26 0 0 1 12.08-9.94 79.324 79.324 0 0 1 29.62-12.12A80.848 80.848 0 0 1 432 48h124.22A57.878 57.878 0 0 1 608 80z" fill="#34507B" p-id="17467"></path><path d="M880 864h32v128h-32zM802.92 664.238l-157.2-39.3A41.854 41.854 0 0 1 624 588.22v-49.554l48-64.012a80.568 80.568 0 0 0 16-48v-43.11a71.988 71.988 0 0 0 0-143.088V144a80.102 80.102 0 0 0-70.528-79.42A73.4 73.4 0 0 0 556.222 32H432c-27.334 0-51.164 14.36-51.164 14.36l6.34 12.662L408.368 112H370a63.432 63.432 0 0 1 10.8-22.4l-25.6-19.22A95.2 95.2 0 0 0 336 128v112.456a71.988 71.988 0 0 0 0 143.088v43.116a80.578 80.578 0 0 0 16 48l48 64v49.56a41.634 41.634 0 0 1-21.718 36.718l-157.2 39.298A143.8 143.8 0 0 0 112 803.94V992h32v-188.06A111.8 111.8 0 0 1 161.366 744l51.32 51.318 22.628-22.628-53.064-53.07a111.828 111.828 0 0 1 46.6-24.338l146.1-36.526c26.208 52.094 77.538 83.904 137.05 83.904s110.842-31.8 137.058-83.904l146.102 36.528a111.8 111.8 0 0 1 46.6 24.336l-53.064 53.066 22.628 22.628L862.634 744A111.8 111.8 0 0 1 880 803.94V830h32v-26.06a143.786 143.786 0 0 0-109.08-139.702zM720 312a40.076 40.076 0 0 1-32 39.2v-78.4a40.076 40.076 0 0 1 32 39.2z m-64-168v44.222l-32-64v-25.48A48.084 48.084 0 0 1 656 144z m-64-59.904V112h-21.168l-19.2-48S577.5 63 592 84.096zM506.832 112l-19.2-48h29.536l19.2 48z m-53.664-48l19.2 48h-29.536l-18.988-47.47c2.688-0.33 29.324-0.53 29.324-0.53z m-63.056 80L368 188.222V144zM304 312a40.076 40.076 0 0 1 32-39.2v78.4a40.076 40.076 0 0 1-32-39.2z m64 114.66v-166.882L425.888 144h172.224L656 259.778v166.882a48.342 48.342 0 0 1-9.6 28.8s-65.536 87.308-66.4 88.286A47.964 47.964 0 0 1 544 560h-64a48 48 0 0 1-36.04-16.306c-0.822-0.926-66.354-88.228-66.354-88.228A48.35 48.35 0 0 1 368 426.66z m144 284c-36.948 0-83.13-17.29-107.694-64.73A73.42 73.42 0 0 0 432 588.22v-12.242A79.974 79.974 0 0 0 480 592h64a80.018 80.018 0 0 0 48-16.014v12.234a73.79 73.79 0 0 0 27.712 57.676C595.152 693.36 548.956 710.66 512 710.66z" p-id="17468"></path><path d="M512 784c-69.65 0-97.6-39.308-98.76-40.982l-26.552 17.858C388.188 763.126 424.444 816 512 816s123.812-52.874 125.312-55.124l-26.624-17.752C610.414 743.534 582.622 784 512 784zM240 899.43c-19.884-20.152-29.754-54.956-32.2-69.98l-31.6 5.078c0.546 3.426 13.22 79.016 63.8 104.214V992h32v-176h-32zM784 899.43V816h-32v176h32v-53.258c50.578-25.2 63.252-100.788 63.8-104.214l-31.6-5.078c-2.446 15.024-12.316 49.828-32.2 69.98zM456 308a28 28 0 1 0-28 28 28.03 28.03 0 0 0 28-28zM596 336a28 28 0 1 0-28-28 28.03 28.03 0 0 0 28 28zM496 320h32v64h-32zM565.738 446.936l-11.476-29.872c-0.364 0.142-36.8 13.942-72.568 10.14l-3.388 31.82a152.936 152.936 0 0 0 16.2 0.834 220.662 220.662 0 0 0 71.232-12.922z" p-id="17469"></path></svg>
|