Skip to content

Commit f926de4

Browse files
fix: user language
1 parent 12feaac commit f926de4

File tree

27 files changed

+178
-204
lines changed

27 files changed

+178
-204
lines changed

ui/src/api/application/application.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ const getMcpTools: (
301301
* 上传文件
302302
* @param 参数 file:file
303303
*/
304-
const uploadFile: (
304+
const postUploadFile: (
305305
file: any,
306306
sourceId: string,
307307
resourceType:
@@ -313,12 +313,13 @@ const uploadFile: (
313313
| 'TEMPORARY_30_MINUTE'
314314
| 'TEMPORARY_120_MINUTE'
315315
| 'TEMPORARY_1_DAY',
316-
) => Promise<Result<any>> = (file, sourceId, resourceType) => {
316+
loading?: Ref<boolean>,
317+
) => Promise<Result<any>> = (file, sourceId, resourceType, loading) => {
317318
const fd = new FormData()
318319
fd.append('file', file)
319320
fd.append('source_id', sourceId)
320321
fd.append('source_type', resourceType)
321-
return post(`/oss/file`, fd)
322+
return post(`/oss/file`, fd, undefined, loading)
322323
}
323324

324325
export default {
@@ -346,5 +347,5 @@ export default {
346347
postTextToSpeech,
347348
speechToText,
348349
getMcpTools,
349-
uploadFile,
350+
postUploadFile,
350351
}

ui/src/api/chat/chat.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const modifyChat: (chat_id: string, data: any, loading?: Ref<boolean>) => Promis
297297
* @param resourceType 资源类型
298298
* @returns
299299
*/
300-
const uploadFile: (
300+
const postUploadFile: (
301301
file: any,
302302
sourceId: string,
303303
resourceType:
@@ -309,12 +309,13 @@ const uploadFile: (
309309
| 'TEMPORARY_30_MINUTE'
310310
| 'TEMPORARY_120_MINUTE'
311311
| 'TEMPORARY_1_DAY',
312-
) => Promise<Result<any>> = (file, sourceId, sourceType) => {
312+
loading?: Ref<boolean>,
313+
) => Promise<Result<any>> = (file, sourceId, sourceType, loading) => {
313314
const fd = new FormData()
314315
fd.append('file', file)
315316
fd.append('source_id', sourceId)
316317
fd.append('source_type', sourceType)
317-
return post(`/oss/file`, fd)
318+
return post(`/oss/file`, fd, undefined, loading)
318319
}
319320
export default {
320321
open,
@@ -344,5 +345,5 @@ export default {
344345
speechToText,
345346
deleteChat,
346347
modifyChat,
347-
uploadFile,
348+
postUploadFile,
348349
}

ui/src/components/ai-chat/component/answer-content/index.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@
7373
</div>
7474
</template>
7575
<script setup lang="ts">
76+
import { computed, onMounted } from 'vue'
7677
import KnowledgeSourceComponent from '@/components/ai-chat/component/knowledge-source-component/index.vue'
7778
import MdRenderer from '@/components/markdown/MdRenderer.vue'
7879
import OperationButton from '@/components/ai-chat/component/operation-button/index.vue'
7980
import { type chatType } from '@/api/type/application'
80-
import { computed } from 'vue'
8181
import bus from '@/bus'
8282
import useStore from '@/stores'
8383
const props = defineProps<{
@@ -100,7 +100,7 @@ const emit = defineEmits([
100100
])
101101
102102
const showAvatar = computed(() => {
103-
return (user.isEE() || user.isPE())? props.application.show_avatar : true
103+
return user.isEE() || user.isPE() ? props.application.show_avatar : true
104104
})
105105
const showUserAvatar = computed(() => {
106106
return user.isEE() || user.isPE() ? props.application.show_user_avatar : true
@@ -165,5 +165,11 @@ const stopChat = (chat: chatType) => {
165165
const startChat = (chat: chatType) => {
166166
props.chatManagement.write(chat.id)
167167
}
168+
169+
onMounted(() => {
170+
bus.on('chat:stop', () => {
171+
stopChat(props.chatRecord)
172+
})
173+
})
168174
</script>
169175
<style lang="scss" scoped></style>

ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
</el-button>
1515
<!-- 使用 custom-class 自定义样式 -->
1616
<transition name="el-fade-in-linear">
17-
<el-card class="custom-speech-card" :class="isTouching ? '' : 'active'" v-if="dialogVisible">
17+
<el-card
18+
class="custom-speech-card white-bg"
19+
:class="isTouching ? '' : 'active'"
20+
v-if="dialogVisible"
21+
>
1822
<p>
1923
<el-text type="info" v-if="isTouching"
2024
>00:{{ props.time < 10 ? `0${props.time}` : props.time }}</el-text
@@ -43,16 +47,16 @@ import { ref, watch } from 'vue'
4347
const props = defineProps({
4448
time: {
4549
type: Number,
46-
default: 0
50+
default: 0,
4751
},
4852
start: {
4953
type: Boolean,
50-
default: false
54+
default: false,
5155
},
5256
disabled: {
5357
type: Boolean,
54-
default: false
55-
}
58+
default: false,
59+
},
5660
})
5761
const emit = defineEmits(['TouchStart', 'TouchEnd'])
5862
// 移动端语音
@@ -77,7 +81,7 @@ watch(
7781
dialogVisible.value = false
7882
isTouching.value = false
7983
}
80-
}
84+
},
8185
)
8286
watch(
8387
() => props.start,
@@ -90,7 +94,7 @@ watch(
9094
dialogVisible.value = false
9195
isTouching.value = false
9296
}
93-
}
97+
},
9498
)
9599
96100
function onTouchStart(event: any) {
@@ -127,7 +131,6 @@ function onTouchEnd() {
127131
left: 50%; /* 水平居中 */
128132
transform: translateX(-50%);
129133
width: 92%;
130-
background: #ffffff;
131134
border: 1px solid #ffffff;
132135
box-shadow: 0px 6px 24px 0px rgba(31, 35, 41, 0.08);
133136
z-index: 999;

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<template>
22
<div class="ai-chat__operate p-16">
3+
<div class="text-center mb-8" v-if="loading">
4+
<el-button class="border-primary video-stop-button" @click="stopChat">
5+
<app-icon iconName="app-video-stop" class="mr-8"></app-icon>
6+
{{ $t('chat.operation.stopChat') }}</el-button
7+
>
8+
</div>
39
<div class="operate-textarea">
410
<el-scrollbar max-height="136">
511
<div
612
class="p-8-12"
7-
v-loading="localLoading"
13+
v-loading="uploadLoading"
814
v-if="
915
uploadDocumentList.length ||
1016
uploadImageList.length ||
@@ -143,6 +149,7 @@
143149
</el-icon>
144150
</div>
145151
<el-image
152+
v-if="item.url"
146153
:src="item.url"
147154
alt=""
148155
fit="cover"
@@ -299,7 +306,6 @@ import bus from '@/bus'
299306
import 'recorder-core/src/engine/mp3'
300307
import 'recorder-core/src/engine/mp3-engine'
301308
import { MsgWarning } from '@/utils/message'
302-
import { debounce } from 'lodash'
303309
import chatAPI from '@/api/chat/chat'
304310
const router = useRouter()
305311
const route = useRoute()
@@ -347,6 +353,8 @@ const localLoading = computed({
347353
},
348354
})
349355
356+
const uploadLoading = ref(false)
357+
350358
const inputPlaceholder = computed(() => {
351359
return recorderStatus.value === 'START'
352360
? `${t('chat.inputPlaceholder.speaking')}...`
@@ -430,8 +438,13 @@ const uploadFile = async (file: any, fileList: any) => {
430438
}
431439
const api =
432440
props.type === 'debug-ai-chat'
433-
? applicationApi.uploadFile(file.raw, 'TEMPORARY_120_MINUTE', 'TEMPORARY_120_MINUTE')
434-
: chatAPI.uploadFile(file.raw, chatId_context.value, 'CHAT')
441+
? applicationApi.postUploadFile(
442+
file.raw,
443+
'TEMPORARY_120_MINUTE',
444+
'TEMPORARY_120_MINUTE',
445+
uploadLoading,
446+
)
447+
: chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT', uploadLoading)
435448
api.then((ok) => {
436449
file.url = ok.data
437450
const split_path = ok.data.split('/')
@@ -639,7 +652,7 @@ class RecorderManage {
639652
}
640653
const getSpeechToTextAPI = () => {
641654
if (props.type === 'ai-chat') {
642-
return (application_id?: string, data?: any, loading?: Ref<boolean>) => {
655+
return (data?: any, loading?: Ref<boolean>) => {
643656
return chatAPI.speechToText(data, loading)
644657
}
645658
} else {
@@ -802,6 +815,10 @@ function mouseenter(row: any) {
802815
function mouseleave() {
803816
showDelete.value = ''
804817
}
818+
819+
function stopChat() {
820+
bus.emit('chat:stop')
821+
}
805822
onMounted(() => {
806823
bus.on('chat-input', (message: string) => {
807824
inputValue.value = message

ui/src/components/ai-chat/component/operation-button/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
link
2121
>{{ $t('chat.operation.continue') }}
2222
</el-button>
23-
<el-button type="primary" v-else-if="!chatRecord.write_ed" @click="stopChat(chatRecord)" link
23+
<!-- <el-button type="primary" v-else-if="!chatRecord.write_ed" @click="stopChat(chatRecord)" link
2424
>{{ $t('chat.operation.stopChat') }}
25-
</el-button>
25+
</el-button> -->
2626
</div>
2727

2828
<ChatOperationButton

ui/src/components/ai-chat/index.vue

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
:executionIsRightPanel="props.executionIsRightPanel"
5252
@open-execution-detail="emit('openExecutionDetail', chatList[index])"
5353
@openParagraph="emit('openParagraph', chatList[index])"
54-
@openParagraphDocument="(val: any)=>emit('openParagraphDocument', chatList[index], val)"
54+
@openParagraphDocument="
55+
(val: any) => emit('openParagraphDocument', chatList[index], val)
56+
"
5557
></AnswerContent>
5658
</template>
5759
<TransitionContent
@@ -77,9 +79,6 @@
7779
v-model:show-user-input="showUserInput"
7880
v-if="type !== 'log'"
7981
>
80-
<template #operateBefore>
81-
<slot name="operateBefore"> </slot>
82-
</template>
8382
<template #userInput>
8483
<el-button
8584
v-if="isUserInput || isAPIInput"
@@ -105,7 +104,6 @@ import chatLogApi from '@/api/application/chat-log'
105104
import { ChatManagement, type chatType } from '@/api/type/application'
106105
import { randomId } from '@/utils/common'
107106
import useStore from '@/stores'
108-
import { isWorkFlow } from '@/utils/application'
109107
import { debounce } from 'lodash'
110108
import AnswerContent from '@/components/ai-chat/component/answer-content/index.vue'
111109
import QuestionContent from '@/components/ai-chat/component/question-content/index.vue'
@@ -139,7 +137,13 @@ const props = withDefaults(
139137
type: 'ai-chat',
140138
},
141139
)
142-
const emit = defineEmits(['refresh', 'scroll', 'openExecutionDetail', 'openParagraph','openParagraphDocument'])
140+
const emit = defineEmits([
141+
'refresh',
142+
'scroll',
143+
'openExecutionDetail',
144+
'openParagraph',
145+
'openParagraphDocument',
146+
])
143147
const { application, common } = useStore()
144148
const isMobile = computed(() => {
145149
return common.isMobile() || mode === 'embed' || mode === 'mobile'
@@ -246,14 +250,18 @@ function sendMessage(val: string, other_params_data?: any, chat?: chatType): Pro
246250
return userFormRef.value
247251
?.validate()
248252
.then((ok) => {
249-
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
253+
let userFormData = accessToken
254+
? JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
255+
: {}
250256
const newData = Object.keys(form_data.value).reduce((result: any, key: string) => {
251257
result[key] = Object.prototype.hasOwnProperty.call(userFormData, key)
252258
? userFormData[key]
253259
: form_data.value[key]
254260
return result
255261
}, {})
256-
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
262+
if (accessToken) {
263+
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
264+
}
257265
258266
showUserInput.value = false
259267
@@ -300,11 +308,11 @@ const openChatId: () => Promise<string> = () => {
300308
return res.data
301309
})
302310
.catch((res) => {
303-
if (res.response.status === 403) {
304-
return application.asyncAppAuthentication(accessToken).then(() => {
305-
return openChatId()
306-
})
307-
}
311+
// if (res.response.status === 403) {
312+
// return application.asyncAppAuthentication(accessToken).then(() => {
313+
// return openChatId()
314+
// })
315+
// }
308316
return Promise.reject(res)
309317
})
310318
}
@@ -512,16 +520,7 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean, other_para
512520
// 对话
513521
getChatMessageAPI()(chartOpenId.value, obj)
514522
.then((response) => {
515-
if (response.status === 401) {
516-
application
517-
.asyncAppAuthentication(accessToken)
518-
.then(() => {
519-
chatMessage(chat, problem)
520-
})
521-
.catch(() => {
522-
errorWrite(chat)
523-
})
524-
} else if (response.status === 460) {
523+
if (response.status === 460) {
525524
return Promise.reject(t('chat.tip.errorIdentifyMessage'))
526525
} else if (response.status === 461) {
527526
return Promise.reject(t('chat.tip.errorLimitMessage'))
@@ -661,6 +660,13 @@ defineExpose({
661660
width: calc(100% - 50px);
662661
max-width: 400px;
663662
}
663+
664+
.video-stop-button {
665+
box-shadow: 0px 6px 24px 0px rgba(31, 35, 41, 0.08);
666+
&:hover {
667+
background: #ffffff;
668+
}
669+
}
664670
@media only screen and (max-width: 768px) {
665671
.firstUserInput {
666672
.user-form-container {

ui/src/components/app-icon/AppIcon.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:is="
55
Object.keys(iconMap).includes(iconName)
66
? iconMap[iconName].iconReader()
7-
: iconMap['404'].iconReader()
7+
: iconMap['app-404'].iconReader()
88
"
99
class="el-icon app-icon"
1010
>
@@ -22,7 +22,7 @@ const props = withDefaults(
2222
iconName?: string
2323
}>(),
2424
{
25-
iconName: '404',
25+
iconName: 'app-404',
2626
},
2727
)
2828

ui/src/components/app-icon/icons/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export default {
292292
])
293293
},
294294
},
295-
'app-play-outlined': {
295+
'app-debug-outlined': {
296296
iconReader: () => {
297297
return h('i', [
298298
h(

0 commit comments

Comments
 (0)