diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..40f965b
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,14 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Debug h5",
+ "type": "chrome",
+ "runtimeArgs": ["--remote-debugging-port=9222"],
+ "request": "launch",
+ "url": "http://localhost:5173",
+ "webRoot": "${workspaceFolder}",
+ "preLaunchTask": "uni:h5"
+ }
+ ]
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..e8c343f
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,16 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "uni:h5",
+ "type": "npm",
+ "script": "dev --devtools",
+ "isBackground": true,
+ "problemMatcher": "$vite",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ }
+ ]
+}
diff --git a/env/.env.production b/env/.env.production
index 21207fe..fe4a86a 100644
--- a/env/.env.production
+++ b/env/.env.production
@@ -5,6 +5,6 @@ VITE_DELETE_CONSOLE = true
# 是否开启sourcemap
VITE_SHOW_SOURCEMAP = false
-VITE_SERVER_BASEURL = 'http://114.218.158.24:9020'
+VITE_SERVER_BASEURL = 'https://erpapi.fontree.cn' # 体制外 OA
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index beeaa77..42abd21 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -42,7 +42,7 @@
@@ -181,11 +181,6 @@
{{ msg.content }}
-
- ...
-
+
+
@@ -482,7 +493,7 @@ import {
import 'dayjs/locale/zh-cn'
import { showToastErr, showToastOk, time_format3 } from '@/utils/tools'
import { uploadFileChunk } from './utils/api.js'
-// import { TOKEN, AVATAR } from './utils/test'
+import { TOKEN, AVATAR } from './utils/test'
import { deepClone } from 'wot-design-uni/components/common/util'
import { log } from 'console'
@@ -1545,6 +1556,10 @@ interface EventTargetSendText {
type EventTypeTarget = string | EventTargetSendText
const sendTextLoading = ref(true) // false可以发送消息,true不可以发送,因为上一次发送未结束
const refreshSend = ref(false)
+let stopStreamMsg = false
+const stopMsg = () => {
+ stopStreamMsg = true
+}
async function sendText() {
console.log('uploadList: ', uploadList)
if (uploadList.length > 0) {
@@ -1782,10 +1797,13 @@ async function sendText() {
// aiMsg.content = ''
// 发送问题到后端
inputText.value = ''
+ const controller = new AbortController()
+ const signal = controller.signal
const resp = await fetch(baseUrl + '/chat/app/completion', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: token.value },
body: JSON.stringify(body),
+ signal: signal,
})
const reader = resp.body!.getReader()
@@ -1794,6 +1812,12 @@ async function sendText() {
let done = false
while (!done) {
+ if (stopStreamMsg) {
+ // 立刻停下
+ // reader.cancel();
+ controller.abort()
+ stopStreamMsg = false
+ }
const { value, done: streamDone } = await reader.read()
done = streamDone
if (value) {
@@ -1857,6 +1881,7 @@ async function sendText() {
sendTextLoading.value = true
showActions.value = false
refreshSend.value = false // 重发已经结束 关闭重发
+ msgLoading.value = false
}
}
function copyText(msg: IMessage) {
@@ -1892,11 +1917,17 @@ function refreshText() {
// 2. 提取文本内容和文件列表
let refreshText = null
const refreshFiles: UploadFile[] = []
- if (msg1.type === 'text' && msg2.type !== 'text') {
+ if (msg1 && msg1.type === 'text' && msg2 && msg2.type !== 'text') {
msg1.mask = 'new'
msg2.mask = 'new'
refreshFiles.push(msg1)
refreshFiles.push(msg2)
+ } else if (msg1.type === 'text' && msg1.role === 'user' && !msg2) {
+ msg1.mask = 'new'
+ refreshFiles.push(msg1)
+ } else if (msg2.type === 'text' && msg2.role === 'user' && !msg1) {
+ msg2.mask = 'new'
+ refreshFiles.push(msg2)
} else {
msg2.mask = 'new'
refreshFiles.push(msg2)
diff --git a/src/static/aichat/Back.png b/src/static/aichat/Back.png
deleted file mode 100644
index 09a3e06..0000000
Binary files a/src/static/aichat/Back.png and /dev/null differ
diff --git a/src/static/aichat/enter-no.png b/src/static/aichat/enter-no.png
new file mode 100644
index 0000000..fa768f6
Binary files /dev/null and b/src/static/aichat/enter-no.png differ
diff --git a/src/static/aichat/stop.png b/src/static/aichat/stop.png
new file mode 100644
index 0000000..7259bed
Binary files /dev/null and b/src/static/aichat/stop.png differ