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

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

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