Commit d59b11d4 authored by shirlyn.guo's avatar shirlyn.guo 🤡

Merge branch 'master' of https://gitlab.gsstcloud.com/poc/poc-fe into shirlyn

parents 76d094c0 f7c6a93c
...@@ -94,15 +94,17 @@ function handleConfirm() { ...@@ -94,15 +94,17 @@ function handleConfirm() {
<slot v-if="slots.footer" name="footer" /> <slot v-if="slots.footer" name="footer" />
<div v-else class="flex w-full items-center justify-end"> <div v-else class="flex w-full items-center justify-end">
<NButton class="h-[34px]! rounded-full! px-6! min-w-[96px]!" @click="handleCloseModal"> <NButton color="#F5F5F5" round class="h-[34px]! px-6! min-w-[96px]! text-font-color!" @click="handleCloseModal">
{{ t(cancelBtnText) }} {{ t(cancelBtnText) }}
</NButton> </NButton>
<NButton <NButton
:loading="btnLoading" :loading="btnLoading"
type="primary" type="primary"
color="#6F77FF"
round
:bordered="false" :bordered="false"
:disabled="btnDisabled" :disabled="btnDisabled"
class="h-[34px]! px-6! rounded-full! ml-4! min-w-[96px]!" class="h-[34px]! px-6! ml-4! min-w-[96px]!"
@click="handleConfirm" @click="handleConfirm"
> >
{{ t(confirmBtnText) }} {{ t(confirmBtnText) }}
......
...@@ -31,7 +31,7 @@ function handleConfirm() { ...@@ -31,7 +31,7 @@ function handleConfirm() {
} }
function handleShowModal(content: string, title?: string) { function handleShowModal(content: string, title?: string) {
content && (modalOptions.content = content) modalOptions.content = content
title && (modalOptions.title = title) title && (modalOptions.title = title)
isShowModal.value = true isShowModal.value = true
......
import { reactive } from 'vue'
export interface DefaultPaginationData {
pageNo: number
pageSize: number
totalPages: number
totalRows: number
}
interface PaginationData {
pageNo?: number
pageSize?: number
totalPages?: number
totalRows?: number
}
/** 默认的分页参数 */
const defaultPaginationData: DefaultPaginationData = {
pageNo: 1,
pageSize: 10,
totalPages: 0,
totalRows: 0,
}
export function usePagination(initialPaginationData: PaginationData = {}) {
/** 合并分页参数 */
const paginationData = reactive({ ...defaultPaginationData, ...initialPaginationData })
/** 改变当前页码 */
const handlePageNoChange = (pageNo: number) => {
paginationData.pageNo = pageNo
}
/** 改变页面大小 */
const handlePageSizeChange = (pageSize: number) => {
paginationData.pageNo = 1
paginationData.pageSize = pageSize
}
return { paginationData, handlePageNoChange, handlePageSizeChange }
}
...@@ -122,6 +122,7 @@ home_module: ...@@ -122,6 +122,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: '登录'
...@@ -308,7 +309,7 @@ personal_space_module: ...@@ -308,7 +309,7 @@ personal_space_module:
search_knowledge_placeholder: '请输入知识库名称' search_knowledge_placeholder: '请输入知识库名称'
knowledge_name: '知识库名称' knowledge_name: '知识库名称'
knowledge_desc: '知识库描述' knowledge_desc: '知识库描述'
delete_knowledge_dialog_content: '删除后将无法恢复, 是否确认删除?' delete_knowledge_dialog_content: '删除后将无法恢复'
not_find_knowledge_message: '未找到知识库' not_find_knowledge_message: '未找到知识库'
search_knowledge_document_placeholder: '请输入文件名称' search_knowledge_document_placeholder: '请输入文件名称'
...@@ -342,7 +343,7 @@ personal_space_module: ...@@ -342,7 +343,7 @@ personal_space_module:
add_knowledge_chunk_modal_title: '新增切片' add_knowledge_chunk_modal_title: '新增切片'
knowledge_chunk_content_input_placeholder: '请输入内容' knowledge_chunk_content_input_placeholder: '请输入内容'
knowledge_chunk_content_input_rule: '内容不能为空' knowledge_chunk_content_input_rule: '内容不能为空'
delete_knowledge_chunk_content_message: '确认删除该切片' delete_knowledge_chunk_content_message: '确认删除该切片'
upload_document_module: upload_document_module:
segment_setting: '分段处理' segment_setting: '分段处理'
......
...@@ -106,6 +106,7 @@ login_module: ...@@ -106,6 +106,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'
...@@ -308,7 +309,7 @@ personal_space_module: ...@@ -308,7 +309,7 @@ personal_space_module:
search_knowledge_placeholder: '請輸入知識庫名稱' search_knowledge_placeholder: '請輸入知識庫名稱'
knowledge_name: '知識庫名稱' knowledge_name: '知識庫名稱'
knowledge_desc: '知識庫描述' knowledge_desc: '知識庫描述'
delete_knowledge_dialog_content: '刪除後將無法恢復, 是否確認刪除?' delete_knowledge_dialog_content: '刪除後將無法恢復'
not_find_knowledge_message: '未找到知識庫' not_find_knowledge_message: '未找到知識庫'
search_knowledge_document_placeholder: '請輸入文件名稱' search_knowledge_document_placeholder: '請輸入文件名稱'
...@@ -342,7 +343,7 @@ personal_space_module: ...@@ -342,7 +343,7 @@ personal_space_module:
add_knowledge_chunk_modal_title: '新增切片' add_knowledge_chunk_modal_title: '新增切片'
knowledge_chunk_content_input_placeholder: '請輸入內容' knowledge_chunk_content_input_placeholder: '請輸入內容'
knowledge_chunk_content_input_rule: '內容不能為空' knowledge_chunk_content_input_rule: '內容不能為空'
delete_knowledge_chunk_content_message: '確認刪除該切片' delete_knowledge_chunk_content_message: '確認刪除該切片'
upload_document_module: upload_document_module:
segment_setting: '分段處理' segment_setting: '分段處理'
......
...@@ -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>
......
...@@ -408,7 +408,7 @@ function handleAIGenerateAgentSystem() { ...@@ -408,7 +408,7 @@ function handleAIGenerateAgentSystem() {
fetchCustomEventSource({ fetchCustomEventSource({
path: '/api/rest/agentApplicationInfoRest/createAgentSystem.json', path: '/api/rest/agentApplicationInfoRest/createAgentSystem.json',
payload: { payload: {
input: personalAppConfigStore.baseInfo.agentSystem, input: personalAppConfigStore.baseInfo.agentTitle || personalAppConfigStore.baseInfo.agentSystem,
}, },
controller: generateAgentSystemController, controller: generateAgentSystemController,
onMessage: (data: any) => { onMessage: (data: any) => {
...@@ -1335,7 +1335,7 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) { ...@@ -1335,7 +1335,7 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
} }
:deep(.prompt-input .n-input-word-count) { :deep(.prompt-input .n-input-word-count) {
bottom: -10px !important; bottom: -12px !important;
background: white !important; background: white !important;
} }
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, h, onMounted, readonly, ref, watch } from 'vue' import { computed, h, onMounted, readonly, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { DropdownOption } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { sidebarMenus } from '@/router/index'
import CustomIcon from '@/components/custom-icon/custom-icon.vue' import CustomIcon from '@/components/custom-icon/custom-icon.vue'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { usePersonalAppConfigStore } from '@/store/modules/personal-app-config' import { usePersonalAppConfigStore } from '@/store/modules/personal-app-config'
...@@ -56,17 +54,6 @@ const agentAppOptionList = [ ...@@ -56,17 +54,6 @@ const agentAppOptionList = [
const personalAppConfig = computed(() => personalAppConfigStore.$state) const personalAppConfig = computed(() => personalAppConfigStore.$state)
const menuOptions = computed(() => {
return sidebarMenus.map((item) => {
return {
label: () => h('span', {}, t(item.label)),
key: item.key,
routeName: item.routeName,
icon: () => h(CustomIcon, { icon: item.icon || 'icon-home' }),
}
})
})
const isShowModifiedTime = computed(() => { const isShowModifiedTime = computed(() => {
return isUpdateAgentAppConfig.value && personalAppConfigStore.baseInfo.agentId return isUpdateAgentAppConfig.value && personalAppConfigStore.baseInfo.agentId
}) })
...@@ -109,12 +96,8 @@ onMounted(() => { ...@@ -109,12 +96,8 @@ onMounted(() => {
} }
}) })
function handleMenuSelect(_key: number, option: DropdownOption) {
router.replace({ name: option.routeName as string })
}
function handleBackPreviousPage() { function handleBackPreviousPage() {
router.go(-1) router.replace({ name: 'PersonalSpaceApp' })
} }
function handleDropdownSelect(key: string) { function handleDropdownSelect(key: string) {
...@@ -171,13 +154,11 @@ async function handlePublishApplication() { ...@@ -171,13 +154,11 @@ async function handlePublishApplication() {
<template> <template>
<header class="h-navbar flex w-full items-center justify-between bg-[#f2f5f9] px-5 shadow-[inset_0_-1px_#e8e9eb]"> <header class="h-navbar flex w-full items-center justify-between bg-[#f2f5f9] px-5 shadow-[inset_0_-1px_#e8e9eb]">
<div class="flex flex-1 items-center"> <div class="flex flex-1 items-center">
<NDropdown trigger="hover" :options="menuOptions" @select="handleMenuSelect">
<CustomIcon <CustomIcon
icon="weui:back-outlined" icon="weui:back-outlined"
class="hover:text-theme-color mr-5 outline-none" class="hover:text-theme-color mr-5 cursor-pointer outline-none"
@click="handleBackPreviousPage" @click="handleBackPreviousPage"
/> />
</NDropdown>
<div class="flex flex-col items-start justify-center"> <div class="flex flex-col items-start justify-center">
<NPopover trigger="hover"> <NPopover trigger="hover">
......
import { NSwitch, NPopconfirm } from 'naive-ui' import { NSwitch } from 'naive-ui'
import { KnowledgeDocumentItem, KnowledgeItem } from './knowledge-type' import { KnowledgeDocumentItem, KnowledgeItem } from './knowledge-type'
import { formatDateTime } from '@/utils/date-formatter' import { formatDateTime } from '@/utils/date-formatter'
import i18n from '@/locales' import i18n from '@/locales'
...@@ -81,26 +81,12 @@ export function createKnowledgeColumn( ...@@ -81,26 +81,12 @@ export function createKnowledgeColumn(
> >
{t('common_module.data_table_module.view')} {t('common_module.data_table_module.view')}
</span> </span>
<NPopconfirm <span
negative-text={t('common_module.cancel_btn_text')} className='text-error-font-color mr-5 cursor-pointer hover:opacity-80'
positive-text={t('common_module.confirm_btn_text')} onClick={() => handleKnowledgeTableAction('delete', row.id)}
onNegativeClick={() => {}}
onPositiveClick={() => handleKnowledgeTableAction('delete', row.id)}
> >
{{
trigger: () => (
<span className='text-error-font-color mr-5 cursor-pointer hover:opacity-80'>
{t('common_module.data_table_module.delete')} {t('common_module.data_table_module.delete')}
</span> </span>
),
default: () => (
<span> {t('personal_space_module.knowledge_module.delete_knowledge_dialog_content')}</span>
),
icon: () => (
<div class='bg-background-color h-4 w-4 rounded-full bg-[url(@/assets/svgs/warning.svg)] bg-contain' />
),
}}
</NPopconfirm>
</div> </div>
) )
}, },
...@@ -152,7 +138,7 @@ export function createKnowledgeDocumentColumn( ...@@ -152,7 +138,7 @@ export function createKnowledgeDocumentColumn(
}, },
width: 236, width: 236,
render(row: KnowledgeDocumentItem) { render(row: KnowledgeDocumentItem) {
return row.documentName.split('.')[1].toUpperCase() || '--' return row.documentName.split('.')?.pop()?.toLowerCase() || '--'
}, },
}, },
{ {
...@@ -228,32 +214,16 @@ export function createKnowledgeDocumentColumn( ...@@ -228,32 +214,16 @@ export function createKnowledgeDocumentColumn(
</span> </span>
)} )}
<NPopconfirm
negative-text={t('common_module.cancel_btn_text')}
positive-text={t('common_module.confirm_btn_text')}
onNegativeClick={() => {}}
onPositiveClick={() => handleKnowledgeDocumentTableAction('delete', row)}
>
{{
trigger: () => (
<span <span
class={[ class={[
['Complete', 'Fail'].includes(row.trainStatus) ['Complete', 'Fail'].includes(row.trainStatus)
? 'text-error-font-color mr-5 cursor-pointer hover:opacity-80' ? 'text-error-font-color mr-5 cursor-pointer hover:opacity-80'
: 'text-gray-font-color pointer-events-none mr-5 cursor-not-allowed', : 'text-gray-font-color pointer-events-none mr-5 cursor-not-allowed',
]} ]}
onClick={() => handleKnowledgeDocumentTableAction('delete', row)}
> >
{t('common_module.data_table_module.delete')} {t('common_module.data_table_module.delete')}
</span> </span>
),
default: () => (
<span> {t('personal_space_module.knowledge_module.delete_knowledge_dialog_content')}</span>
),
icon: () => (
<div class='bg-background-color h-4 w-4 rounded-full bg-[url(@/assets/svgs/warning.svg)] bg-contain' />
),
}}
</NPopconfirm>
</div> </div>
) )
}, },
......
...@@ -64,29 +64,15 @@ const isShowKnowledgeChunkAction = ref(false) ...@@ -64,29 +64,15 @@ const isShowKnowledgeChunkAction = ref(false)
<span> {{ t('personal_space_module.knowledge_module.add_chunk_down_message') }} </span> <span> {{ t('personal_space_module.knowledge_module.add_chunk_down_message') }} </span>
</n-popover> </n-popover>
<n-popconfirm
placement="bottom"
:negative-text="t('common_module.cancel_btn_text')"
:positive-text="t('common_module.confirm_btn_text')"
@negative-click="() => {}"
@positive-click="emit('delete', chunkItem.chunkRelationId)"
@mouseenter="isShowKnowledgeChunkAction = true"
>
<template #icon>
<div class="bg-background-color h-4 w-4 rounded-full bg-[url(@/assets/svgs/warning.svg)] bg-contain" />
</template>
<template #trigger>
<n-popover trigger="hover"> <n-popover trigger="hover">
<template #trigger> <template #trigger>
<i <i
class="iconfont icon-delete hover:text-font-color hover:bg-background-color flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-sm" class="iconfont icon-delete hover:text-font-color hover:bg-background-color flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-sm"
@click="emit('delete', chunkItem.chunkRelationId)"
/> />
</template> </template>
<span> {{ t('common_module.data_table_module.delete') }}</span> <span> {{ t('common_module.data_table_module.delete') }}</span>
</n-popover> </n-popover>
</template>
{{ t('personal_space_module.knowledge_module.delete_knowledge_chunk_content_message') }}
</n-popconfirm>
<n-switch :value="chunkItem.isOpen === 'Y'" @update:value="emit('updateOpen', chunkItem)" /> <n-switch :value="chunkItem.isOpen === 'Y'" @update:value="emit('updateOpen', chunkItem)" />
</div> </div>
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { ScrollbarInst } from 'naive-ui' import { ScrollbarInst } from 'naive-ui'
...@@ -14,7 +14,8 @@ import { ...@@ -14,7 +14,8 @@ import {
fetchOpenKnowledgeChunk, fetchOpenKnowledgeChunk,
fetchUpdateKnowledgeChunk, fetchUpdateKnowledgeChunk,
} from '@/apis/knowledge' } from '@/apis/knowledge'
import CustomPagination, { PaginationInfo } from '@/components/custom-pagination/custom-pagination.vue' import CustomPagination from '@/components/custom-pagination/custom-pagination.vue'
import { usePagination } from '@/composables/usePagination.ts'
import EditKnowledgeChunkModal from './components/edit-knowledge-chunk-modal.vue' import EditKnowledgeChunkModal from './components/edit-knowledge-chunk-modal.vue'
import AddKnowledgeChunkModal from './components/add-knowledge-chunk-modal.vue' import AddKnowledgeChunkModal from './components/add-knowledge-chunk-modal.vue'
...@@ -22,6 +23,8 @@ const { t } = useI18n() ...@@ -22,6 +23,8 @@ const { t } = useI18n()
const router = useRouter() const router = useRouter()
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
const currentKdId = ref(0) const currentKdId = ref(0)
const currentKnowledgeDocumentName = ref('') const currentKnowledgeDocumentName = ref('')
const currentKnowledgeDocumentUrl = ref('') const currentKnowledgeDocumentUrl = ref('')
...@@ -34,13 +37,6 @@ const totalChunk = ref(0) ...@@ -34,13 +37,6 @@ const totalChunk = ref(0)
const knowledgeChunkList = ref<KnowledgeChunkItem[]>([]) const knowledgeChunkList = ref<KnowledgeChunkItem[]>([])
const knowledgeChunkListLoading = ref(false) const knowledgeChunkListLoading = ref(false)
const pagingInfo = ref<PaginationInfo>({
pageNo: 1,
pageSize: 10,
totalPages: 0,
totalRows: 0,
})
const defaultKnowledgeChunkData: KnowledgeChunkItem = { const defaultKnowledgeChunkData: KnowledgeChunkItem = {
knowledgeId: '', knowledgeId: '',
chunkContent: '', chunkContent: '',
...@@ -65,6 +61,11 @@ const emptyKnowledgeChunkListText = computed(() => { ...@@ -65,6 +61,11 @@ const emptyKnowledgeChunkListText = computed(() => {
return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data') return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data')
}) })
watch([() => paginationData.pageNo, () => paginationData.pageSize], async () => {
await handleGetKnowledgeChunkList()
scrollBarRef.value?.scrollTo({ top: 0 })
})
onMounted(async () => { onMounted(async () => {
if (!router.currentRoute.value.params.kdId) { if (!router.currentRoute.value.params.kdId) {
window.$message.warning(t('personal_space_module.knowledge_module.not_find_knowledge_document_message')) window.$message.warning(t('personal_space_module.knowledge_module.not_find_knowledge_document_message'))
...@@ -98,16 +99,17 @@ async function handleGetKnowledgeChunkList() { ...@@ -98,16 +99,17 @@ async function handleGetKnowledgeChunkList() {
searchKnowledgeChunkValue.value, searchKnowledgeChunkValue.value,
currentKdId.value, currentKdId.value,
{ {
pagingInfo: pagingInfo.value, pagingInfo: paginationData,
}, },
) )
if (res.code === 0) { if (res.code === 0) {
totalChunk.value = res.data.totalChunk totalChunk.value = res.data.totalChunk
knowledgeChunkList.value = res.data.chunkInfos || [] knowledgeChunkList.value = res.data.chunkInfos || []
pagingInfo.value = res.pagingInfo as PaginationInfo paginationData.totalRows = res.pagingInfo?.totalPages || 0
paginationData.totalPages = res.pagingInfo?.totalPages || 0
knowledgeChunkListLoading.value = false knowledgeChunkListLoading.value = false
isSearchEmptyList.value = !!searchKnowledgeChunkValue.value && pagingInfo.value.totalRows === 0 isSearchEmptyList.value = !!searchKnowledgeChunkValue.value && paginationData.totalRows === 0
} }
} }
...@@ -115,21 +117,8 @@ function handleBackKnowledgeDocumentList() { ...@@ -115,21 +117,8 @@ function handleBackKnowledgeDocumentList() {
router.back() router.back()
} }
async function handleGetKnowledgeChunkListUpdatePageNo(pageNo: number) {
pagingInfo.value.pageNo = pageNo
await handleGetKnowledgeChunkList()
scrollBarRef.value?.scrollTo({ top: 0 })
}
async function handleGetKnowledgeChunkListUpdatePageSize(pageSize: number) {
pagingInfo.value.pageNo = 1
pagingInfo.value.pageSize = pageSize
await handleGetKnowledgeChunkList()
scrollBarRef.value?.scrollTo({ top: 0 })
}
async function handleSearchKnowledgeChunkList() { async function handleSearchKnowledgeChunkList() {
pagingInfo.value.pageNo = 1 paginationData.pageNo = 1
await handleGetKnowledgeChunkList() await handleGetKnowledgeChunkList()
scrollBarRef.value?.scrollTo({ top: 0 }) scrollBarRef.value?.scrollTo({ top: 0 })
} }
...@@ -184,6 +173,9 @@ async function handleAddKnowledgeChunk(chunkContent: string, chunkSort: number) ...@@ -184,6 +173,9 @@ async function handleAddKnowledgeChunk(chunkContent: string, chunkSort: number)
} }
async function handleDeleteKnowledgeChunk(chunkRelationId: string) { async function handleDeleteKnowledgeChunk(chunkRelationId: string) {
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_chunk_content_message'))
.then(async () => {
const res = await fetchDeleteKnowledgeChunk({ const res = await fetchDeleteKnowledgeChunk({
kdId: currentKdId.value, kdId: currentKdId.value,
chunkRelationId, chunkRelationId,
...@@ -193,6 +185,7 @@ async function handleDeleteKnowledgeChunk(chunkRelationId: string) { ...@@ -193,6 +185,7 @@ async function handleDeleteKnowledgeChunk(chunkRelationId: string) {
window.$message.success(t('common_module.delete_success_message')) window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeChunkList() await handleGetKnowledgeChunkList()
} }
})
} }
async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) { async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) {
...@@ -288,9 +281,9 @@ async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) { ...@@ -288,9 +281,9 @@ async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) {
<div class="mt-4 flex justify-end"> <div class="mt-4 flex justify-end">
<CustomPagination <CustomPagination
:paging-info="pagingInfo" :paging-info="paginationData"
@update-page-no="handleGetKnowledgeChunkListUpdatePageNo" @update-page-no="handlePageNoChange"
@update-page-size="handleGetKnowledgeChunkListUpdatePageSize" @update-page-size="handlePageSizeChange"
/> />
</div> </div>
......
...@@ -139,12 +139,16 @@ function handleToViewDocumentDetail(kdId: number) { ...@@ -139,12 +139,16 @@ function handleToViewDocumentDetail(kdId: number) {
} }
async function handleDeleteKnowledgeDocument(kdId: number) { async function handleDeleteKnowledgeDocument(kdId: number) {
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchDelKnowledgeDocument(currentKnowledgeId.value, kdId) const res = await fetchDelKnowledgeDocument(currentKnowledgeId.value, kdId)
if (res.code === 0) { if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message')) window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList() await handleGetKnowledgeDocumentList()
} }
})
} }
async function handleTrainKnowledgeDocument(knowledgeDocumentItem: KnowledgeDocumentItem) { async function handleTrainKnowledgeDocument(knowledgeDocumentItem: KnowledgeDocumentItem) {
...@@ -181,12 +185,16 @@ function handleUpdateCheckedKdId(kdIdList: number[]) { ...@@ -181,12 +185,16 @@ function handleUpdateCheckedKdId(kdIdList: number[]) {
} }
async function handleBatchDelDocument() { async function handleBatchDelDocument() {
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchBatchDelKnowledgeDocument(currentKnowledgeId.value, checkedKdIdList.value) const res = await fetchBatchDelKnowledgeDocument(currentKnowledgeId.value, checkedKdIdList.value)
if (res.code === 0) { if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message')) window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList() await handleGetKnowledgeDocumentList()
} }
})
} }
function handleToUploadDocument() { function handleToUploadDocument() {
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { Search } from '@icon-park/vue-next' import { Search } from '@icon-park/vue-next'
import { createKnowledgeColumn } from './columns.tsx' import { createKnowledgeColumn } from './columns.tsx'
import { KnowledgeItem } from './knowledge-type.ts' import { KnowledgeItem } from './knowledge-type.ts'
import CustomPagination, { PaginationInfo } from '@/components/custom-pagination/custom-pagination.vue' import CustomPagination from '@/components/custom-pagination/custom-pagination.vue'
import useTableScrollY from '@/composables/useTableScrollY.ts' import useTableScrollY from '@/composables/useTableScrollY.ts'
import { usePagination } from '@/composables/usePagination.ts'
import { fetchDelKnowledgeById, fetchEnableKnowledgeInfo, fetchGetKnowledgeList } from '@/apis/knowledge.ts' import { fetchDelKnowledgeById, fetchEnableKnowledgeInfo, fetchGetKnowledgeList } from '@/apis/knowledge.ts'
const { t } = useI18n() const { t } = useI18n()
...@@ -14,16 +15,10 @@ const { t } = useI18n() ...@@ -14,16 +15,10 @@ const { t } = useI18n()
const router = useRouter() const router = useRouter()
const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28) const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28)
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
const knowledgeColumns = createKnowledgeColumn(handleClickKnowledgeTableAction) const knowledgeColumns = createKnowledgeColumn(handleClickKnowledgeTableAction)
const pagingInfo = ref<PaginationInfo>({
pageNo: 1,
pageSize: 10,
totalPages: 0,
totalRows: 0,
})
const knowledgeListTableLoading = ref(false) const knowledgeListTableLoading = ref(false)
const knowledgeList = ref<KnowledgeItem[]>([]) const knowledgeList = ref<KnowledgeItem[]>([])
...@@ -38,6 +33,8 @@ const emptyTableDataText = computed(() => { ...@@ -38,6 +33,8 @@ const emptyTableDataText = computed(() => {
return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data') return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data')
}) })
watch([() => paginationData.pageNo, () => paginationData.pageSize], handleGetKnowledgeList)
onMounted(async () => { onMounted(async () => {
await handleGetKnowledgeList() await handleGetKnowledgeList()
}) })
...@@ -46,14 +43,15 @@ async function handleGetKnowledgeList() { ...@@ -46,14 +43,15 @@ async function handleGetKnowledgeList() {
knowledgeListTableLoading.value = true knowledgeListTableLoading.value = true
const res = await fetchGetKnowledgeList<KnowledgeItem[]>('', searchKnowledgeInputValue.value, { const res = await fetchGetKnowledgeList<KnowledgeItem[]>('', searchKnowledgeInputValue.value, {
pagingInfo: pagingInfo.value, pagingInfo: paginationData,
}) })
if (res.code === 0) { if (res.code === 0) {
knowledgeList.value = res.data knowledgeList.value = res.data
pagingInfo.value = res.pagingInfo as PaginationInfo paginationData.totalRows = res.pagingInfo?.totalPages || 0
paginationData.totalPages = res.pagingInfo?.totalPages || 0
knowledgeListTableLoading.value = false knowledgeListTableLoading.value = false
isSearchEmptyList.value = !!searchKnowledgeInputValue.value && pagingInfo.value.totalRows === 0 isSearchEmptyList.value = !!searchKnowledgeInputValue.value && paginationData.totalRows === 0
} }
} }
...@@ -88,28 +86,21 @@ function handleViewDocumentList(knowledgeId: number) { ...@@ -88,28 +86,21 @@ function handleViewDocumentList(knowledgeId: number) {
} }
async function handleDeleteKnowledge(knowledgeId: number) { async function handleDeleteKnowledge(knowledgeId: number) {
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchDelKnowledgeById(knowledgeId) const res = await fetchDelKnowledgeById(knowledgeId)
if (res.code === 0) { if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message')) window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeList() await handleGetKnowledgeList()
} }
})
} }
function handleSearchKnowledge() { function handleSearchKnowledge() {
pagingInfo.value.pageNo = 1 paginationData.pageNo = 1
handleGetKnowledgeList() handleGetKnowledgeList()
} }
async function handleGetKnowledgeListUpdatePageNo(pageNo: number) {
pagingInfo.value.pageNo = pageNo
await handleGetKnowledgeList()
}
async function handleGetKnowledgeListUpdatePageSize(pageSize: number) {
pagingInfo.value.pageNo = 1
pagingInfo.value.pageSize = pageSize
await handleGetKnowledgeList()
}
</script> </script>
<template> <template>
...@@ -154,9 +145,9 @@ async function handleGetKnowledgeListUpdatePageSize(pageSize: number) { ...@@ -154,9 +145,9 @@ async function handleGetKnowledgeListUpdatePageSize(pageSize: number) {
<footer v-show="isLoadingPagination" class="flex justify-end"> <footer v-show="isLoadingPagination" class="flex justify-end">
<CustomPagination <CustomPagination
:paging-info="pagingInfo" :paging-info="paginationData"
@update-page-no="handleGetKnowledgeListUpdatePageNo" @update-page-no="handlePageNoChange"
@update-page-size="handleGetKnowledgeListUpdatePageSize" @update-page-size="handlePageSizeChange"
/> />
</footer> </footer>
</div> </div>
......
...@@ -5,6 +5,7 @@ import CustomLoading from './custom-loading.vue' ...@@ -5,6 +5,7 @@ import CustomLoading from './custom-loading.vue'
import MarkdownRender from '@/components/markdown-render/markdown-render.vue' import MarkdownRender from '@/components/markdown-render/markdown-render.vue'
import { PersonalAppConfigState } from '@/store/types/personal-app-config' import { PersonalAppConfigState } from '@/store/types/personal-app-config'
import { useLayoutConfig } from '@/composables/useLayoutConfig' import { useLayoutConfig } from '@/composables/useLayoutConfig'
import { useUserStore } from '@/store/modules/user'
interface Props { interface Props {
role: 'user' | 'assistant' role: 'user' | 'assistant'
...@@ -16,9 +17,13 @@ const { t } = useI18n() ...@@ -16,9 +17,13 @@ const { t } = useI18n()
const props = defineProps<Props>() const props = defineProps<Props>()
const userStore = useUserStore()
const { isMobile } = useLayoutConfig() const { isMobile } = useLayoutConfig()
const useAvatar = 'https://mkp-dev.oss-cn-shenzhen.aliyuncs.com/data/upload/20240827/1724728478476.png' const useAvatar = computed(() => {
return userStore.userInfo.avatarUrl || 'https://gsst-poe-sit.gz.bcebos.com/data/20240910/1725952917468.png'
})
const assistantAvatar = computed(() => { const assistantAvatar = computed(() => {
return ( return (
......
...@@ -33,7 +33,7 @@ function handleToLogin() { ...@@ -33,7 +33,7 @@ function handleToLogin() {
<template> <template>
<header class="flex h-[48px] w-full items-center justify-between border-b border-[#e8e9eb] bg-white px-4"> <header class="flex h-[48px] w-full items-center justify-between border-b border-[#e8e9eb] bg-white px-4">
<div class="bg-px-page_logo-png h-[23px] w-[90px] bg-contain bg-center bg-no-repeat" /> <div class="bg-px-logo-png h-[24px] w-[100px] bg-center bg-no-repeat" />
<div> <div>
<NButton <NButton
v-show="isLogin" v-show="isLogin"
......
...@@ -130,6 +130,7 @@ declare namespace I18n { ...@@ -130,6 +130,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