From 7c90333fcf5cb616560be48e73b1342bdec9667a Mon Sep 17 00:00:00 2001
From: changDongFang <2628162102@qq.com>
Date: Fri, 6 Jun 2025 13:50:06 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E5=81=9C=E6=AD=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E9=87=8D=E5=8F=91bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.vscode/launch.json | 14 ++++++++++
.vscode/tasks.json | 16 +++++++++++
env/.env.production | 2 +-
src/pages/index/index.vue | 47 +++++++++++++++++++++++++++------
src/static/aichat/Back.png | Bin 478 -> 0 bytes
src/static/aichat/enter-no.png | Bin 0 -> 1274 bytes
src/static/aichat/stop.png | Bin 0 -> 1184 bytes
7 files changed, 70 insertions(+), 9 deletions(-)
create mode 100644 .vscode/launch.json
create mode 100644 .vscode/tasks.json
delete mode 100644 src/static/aichat/Back.png
create mode 100644 src/static/aichat/enter-no.png
create mode 100644 src/static/aichat/stop.png
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 09a3e06ee619170d56471c89ea5d3c5aa98c0914..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 478
zcmV<40U`d0P){Zn00001b5ch_0Itp)
z=>Px$m`OxIR7gv$mdQ%QKoEw%aRCMK4Lo`A;z7ZEnL%+}@Bw@qA4wEZ@Zdp34_-tR
z!GofpxH~QnU<#_BZIVgS(|rp`eW}0d@9M75+L{2?fi<8}X@NBf>;k>ODX8*-wGh~}X4Ipq1T+Vnm4%H1`#`q?nguT8xeRP1$>0F!azG;Y%IaPeCZJ=WLjxO$
z)G^@NZD0|YNIP+YzJOui#&<#X6#YnG%bJlHQra#iZCdOsYe;aPzPtrwMm?9w$lXppOy-o-tMoFNn?R>V
z-z6O#4V5Vj>7)RyZov&OIZMEH3~Ly0L8oZTrZr%+?PS1c8{L4>MvwvhDH}W-vw*>4
z+knvy6c-rfsB*!_7(6JqRJ2tNxfDo6K$M6G$_+YTX(@6uQ%f4GGN4i{AYwr%SG0f?
zl5B#twnBDeK-8ijV1Se(6hhby7>GpVriM)VHq6-0?7sK^-}}D*``+y42L~S4(>2p2
z5D0pHzTTl=cfnsBO|Z@}-VA|l9X0egnQ)(PJ_YK|VE^!A092_|Sy?JJTh-E{qS3n8
z?EZeXic>P&QX}Tx9pgY4QY%5&l150>2#v$FqcD4d%Mdp}V+aFnfG{qEHP(p`XuOdw
zZlI%FI{Ju-!2oAUICWwUkTAwz#&`pBjKe}<2HMEN5ITy0nuT!~D3^sI5C#J>6Xh~d
z7(zMBF$9tzpoJu$1#+B*&y)ZJfdF3ugO&wUzy$+xkO72&nJ5BU0D=}gxC9JT*Xk7~
z00iJ_Bm9U7EN~{y$7A3G+#O%>Td3!Nv1_XTb8z<$+BGIX)=bsY@CpAFYh<+rAghCY
zAgD9oN9tfWQyqKlI_e}`7WN#G3fiX!`EQ4MW<&$CV&NP%JU@voE-fgQ7Zu?%r)_X=P@2&fS^PpQT+i>gKGlDfo8Z=@~Z
zdM?(TQy1)8f>kKfiQ`E}r_&!6r$)H{CJMT{-%3L!%Zol3E|E%+Q3)Uf95;6K!
z^i<8!JRO@qv~J}_zh2&J_wx0Xl@0eU=9R|`)MoVhtB4lJ_d?GH`y(=Z?i3hPtgh~w
z$@(nlhA!!8)gBp8*iuQTZMH{?N7&j=T+F=AgHJ}
zHu7tF(6n&oSr5<2aIV>iluhSZosQY$Q94nRxNvsVnqx~GY`!??x>WdJ{+S@Qfi0Z4)wXL|%yf{mB4id~G|~$YFRmgA%OVdb>-0lSY>AM6blQwwt-gyDyjd
zY>y1Bo}AH(95zW&Qk-Jl+zuy|W~ZiAJB`6o*V^GlX_w
l&xc}uNjwxa#q@Y*5h2L)Jz?@=4*1ate#Zj6?~}jE{uk&k-EIH?
literal 0
HcmV?d00001
diff --git a/src/static/aichat/stop.png b/src/static/aichat/stop.png
new file mode 100644
index 0000000000000000000000000000000000000000..7259bedf6d3d76a56c831b0a33e239575cf1a367
GIT binary patch
literal 1184
zcmeAS@N?(olHy`uVBq!ia0vp^CLqkg3?x4-dwml~F%}28J29*~C-V}>o)q8{;tCXG
zVEE6#(7?d3DwJWB1H*n}hM8Jg4O&{OJXIz+D9m?LpY5bF(?NNTyYd`ojaiQBa~;%X
zx~R@}RGHWwwjTd}ochZW^;()#tdV
z&2>_pr;B5V$MLDt(w&7J1=@~BIHIaAATfN;W>a-`P
zAw5?2g;B!NlgLzQ={n70$AQ3|vK9rs9@A57
z3OqF@@ZOo|-5l6=k7>3o(S{NAPB
zp3K?9_Bxb(mzw(K>-Q$)oDe(7z@@Y~lIt2=Czp*||yQuDJB|ylpZahXUj_RjkuKCYxJ*^#nMYB*^`bSx?XIoBS>{Cs5(y>FVdQ&MBb@0KG5xN&o-=
literal 0
HcmV?d00001