Commit 65f36f06 authored by tyyin lan's avatar tyyin lan

chore(首页): 打断回答应用历史记录项更新历史列表

parent 024ccbb0
...@@ -108,6 +108,7 @@ home_module: ...@@ -108,6 +108,7 @@ home_module:
history_record_item_apply_tip: '是否确定应用此会话记录?' history_record_item_apply_tip: '是否确定应用此会话记录?'
historical_record: '历史记录' historical_record: '历史记录'
interrupt_dialogue_prompt: '当前回复尚未完成,是否确定打断发起新会话?' interrupt_dialogue_prompt: '当前回复尚未完成,是否确定打断发起新会话?'
interrupt_the_conversation_and_apply_the_history_prompt: '当前回复尚未完成,是否确定打断对话应用其它记录?'
router_title_module: router_title_module:
login: '登录' login: '登录'
......
...@@ -92,6 +92,7 @@ login_module: ...@@ -92,6 +92,7 @@ login_module:
get_verification_code: '獲取驗証碼' get_verification_code: '獲取驗証碼'
other_login_methods: '其他登錄方式' other_login_methods: '其他登錄方式'
interrupt_dialogue_prompt: '當前回復尚未完成,是否確定打斷發起新會話?' interrupt_dialogue_prompt: '當前回復尚未完成,是否確定打斷發起新會話?'
interrupt_the_conversation_and_apply_the_history_prompt: '當前回復尚未完成,是否確定打斷對話應用其它記錄?'
home_module: home_module:
agent_welcome_message: 'Hi, 歡迎使用SuperLink' agent_welcome_message: 'Hi, 歡迎使用SuperLink'
......
...@@ -9,6 +9,7 @@ import { useI18n } from 'vue-i18n' ...@@ -9,6 +9,7 @@ import { useI18n } from 'vue-i18n'
interface Props { interface Props {
currentSessionId: string currentSessionId: string
messageListLength: number
} }
const props = defineProps<Props>() const props = defineProps<Props>()
...@@ -24,11 +25,12 @@ const emit = defineEmits<{ ...@@ -24,11 +25,12 @@ const emit = defineEmits<{
const questionContent = defineModel<string>('questionContent', { required: true }) const questionContent = defineModel<string>('questionContent', { required: true })
const currentAgentApplication = defineModel<AgentApplicationRecordItem>('currentAgentApplication', { required: true }) const currentAgentApplication = defineModel<AgentApplicationRecordItem>('currentAgentApplication', { required: true })
const isAgentResponding = defineModel<boolean>('isAgentResponding', { required: true }) const isAgentResponding = defineModel<boolean>('isAgentResponding', { required: true })
const currentFetchEventSourceController = defineModel<AbortController | null>('currentFetchEventSourceController', {
required: true,
})
const { t } = useI18n() const { t } = useI18n()
let currentFetchEventSourceController: AbortController | null = null
const isShowApplicationSelectMenu = ref(false) const isShowApplicationSelectMenu = ref(false)
const agentApplicationSelectList = ref<AgentApplicationRecordItem[]>([]) const agentApplicationSelectList = ref<AgentApplicationRecordItem[]>([])
...@@ -75,7 +77,7 @@ function handleApplicationChange(agentApplicationItem: AgentApplicationRecordIte ...@@ -75,7 +77,7 @@ function handleApplicationChange(agentApplicationItem: AgentApplicationRecordIte
function handleCreateNewSession() { function handleCreateNewSession() {
if (isAgentResponding.value) { if (isAgentResponding.value) {
window.$message.ctWarning(t('home_module.interrupt_dialogue_prompt')).then(() => { window.$message.ctWarning(t('home_module.interrupt_dialogue_prompt')).then(() => {
currentFetchEventSourceController && currentFetchEventSourceController.abort() currentFetchEventSourceController.value && currentFetchEventSourceController.value.abort()
isAgentResponding.value = false isAgentResponding.value = false
...@@ -87,6 +89,12 @@ function handleCreateNewSession() { ...@@ -87,6 +89,12 @@ function handleCreateNewSession() {
}, 300) }, 300)
}) })
} else { } else {
if (props.messageListLength === 0) {
window.$message.warning(t('home_module.currently_in_the_latest_session'))
return
}
emit('createNewSession') emit('createNewSession')
} }
} }
...@@ -123,7 +131,7 @@ function questionSubmit() { ...@@ -123,7 +131,7 @@ function questionSubmit() {
let isFirstClip = true let isFirstClip = true
let messageContent = '' let messageContent = ''
currentFetchEventSourceController = fetchEventStreamSource( currentFetchEventSourceController.value = fetchEventStreamSource(
'/agentApplicationRest/callAgentApplication.json', '/agentApplicationRest/callAgentApplication.json',
{ {
dialogsId: props.currentSessionId, //会话ID dialogsId: props.currentSessionId, //会话ID
......
...@@ -3,17 +3,25 @@ import { fetchHistoryRecordDelete, fetchSessionHistoryRecordList } from '@/apis/ ...@@ -3,17 +3,25 @@ import { fetchHistoryRecordDelete, fetchSessionHistoryRecordList } from '@/apis/
import { computed, ref, nextTick, toValue } from 'vue' import { computed, ref, nextTick, toValue } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
interface Props {
currentFetchEventSourceController: AbortController | null
}
interface SessionHistoryRecordItem { interface SessionHistoryRecordItem {
content: string content: string
dialogsId: string dialogsId: string
} }
const props = defineProps<Props>()
const emit = defineEmits<{ const emit = defineEmits<{
getMessageRecordList: [recordId: string] getMessageRecordList: [recordId: string]
createNewSession: [] createNewSession: []
historyRecordListUpdate: []
}>() }>()
const isShowHistoryMenu = defineModel<boolean>({ default: true }) const isShowHistoryMenu = defineModel<boolean>({ default: true })
const isAgentResponding = defineModel<boolean>('isAgentResponding', { required: true })
const { t } = useI18n() const { t } = useI18n()
...@@ -117,9 +125,24 @@ function onHistoryRecordListUpdate() { ...@@ -117,9 +125,24 @@ function onHistoryRecordListUpdate() {
} }
function handleRecordItemApply(dialogsId: string) { function handleRecordItemApply(dialogsId: string) {
if (isAgentResponding.value) {
window.$message.ctWarning(t('home_module.interrupt_the_conversation_and_apply_the_history_prompt')).then(() => {
props.currentFetchEventSourceController && props.currentFetchEventSourceController.abort()
isAgentResponding.value = false
emit('getMessageRecordList', dialogsId)
/* 延时,避免页面刷新后,历史记录列表未刷新 */
setTimeout(() => {
emit('historyRecordListUpdate')
}, 300)
})
} else {
window.$message.ctWarning(t('home_module.history_record_item_apply_tip'), t('common_module.tip')).then(() => { window.$message.ctWarning(t('home_module.history_record_item_apply_tip'), t('common_module.tip')).then(() => {
emit('getMessageRecordList', dialogsId) emit('getMessageRecordList', dialogsId)
}) })
}
} }
defineExpose({ defineExpose({
......
...@@ -38,6 +38,7 @@ const messageList = ref(new Map<string, MessageItemInterface>()) ...@@ -38,6 +38,7 @@ const messageList = ref(new Map<string, MessageItemInterface>())
const isAgentResponding = ref(false) const isAgentResponding = ref(false)
const isShowMessageList = ref(false) const isShowMessageList = ref(false)
const isAgentInitLoading = ref(true) const isAgentInitLoading = ref(true)
const currentFetchEventSourceController = ref<AbortController | null>(null)
// messageList.value.set('1', { // messageList.value.set('1', {
// role: 'user', // role: 'user',
...@@ -99,8 +100,6 @@ function createSessionId() { ...@@ -99,8 +100,6 @@ function createSessionId() {
function onCreateNewSession() { function onCreateNewSession() {
if (messageList.value.size === 0) { if (messageList.value.size === 0) {
window.$message.warning(t('home_module.currently_in_the_latest_session'))
return return
} }
...@@ -197,7 +196,9 @@ function onGetMessageRecordList(recordId: string) { ...@@ -197,7 +196,9 @@ function onGetMessageRecordList(recordId: string) {
v-model:current-agent-application="currentAgentApplication" v-model:current-agent-application="currentAgentApplication"
v-model:is-agent-responding="isAgentResponding" v-model:is-agent-responding="isAgentResponding"
v-model:question-content="questionContent" v-model:question-content="questionContent"
v-model:current-fetch-event-source-controller="currentFetchEventSourceController"
:current-session-id="currentSessionId" :current-session-id="currentSessionId"
:message-list-length="messageList.size"
@message-list-scroll-to-bottom="messageListScrollToBottom" @message-list-scroll-to-bottom="messageListScrollToBottom"
@add-message-item="onAddMessageItem" @add-message-item="onAddMessageItem"
@update-specify-message-item="onUpdateSpecifyMessageItem" @update-specify-message-item="onUpdateSpecifyMessageItem"
...@@ -210,8 +211,11 @@ function onGetMessageRecordList(recordId: string) { ...@@ -210,8 +211,11 @@ function onGetMessageRecordList(recordId: string) {
<HistoryMenuSidebar <HistoryMenuSidebar
ref="historyMenuSidebarRef" ref="historyMenuSidebarRef"
v-model="isShowHistoryMenu" v-model="isShowHistoryMenu"
v-model:is-agent-responding="isAgentResponding"
:current-fetch-event-source-controller="currentFetchEventSourceController"
@get-message-record-list="onGetMessageRecordList" @get-message-record-list="onGetMessageRecordList"
@create-new-session="onCreateNewSession" @create-new-session="onCreateNewSession"
@history-record-list-update="onHistoryRecordListUpdate"
/> />
</div> </div>
......
...@@ -113,6 +113,7 @@ declare namespace I18n { ...@@ -113,6 +113,7 @@ declare namespace I18n {
history_record_item_apply_tip: string history_record_item_apply_tip: string
historical_record: string historical_record: string
interrupt_dialogue_prompt: string interrupt_dialogue_prompt: string
interrupt_the_conversation_and_apply_the_history_prompt: string
} }
router_title_module: { router_title_module: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment