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() {
<slot v-if="slots.footer" name="footer" />
<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) }}
</NButton>
<NButton
:loading="btnLoading"
type="primary"
color="#6F77FF"
round
:bordered="false"
: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"
>
{{ t(confirmBtnText) }}
......
......@@ -31,7 +31,7 @@ function handleConfirm() {
}
function handleShowModal(content: string, title?: string) {
content && (modalOptions.content = content)
modalOptions.content = content
title && (modalOptions.title = title)
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:
history_record_item_apply_tip: '是否确定应用此会话记录?'
historical_record: '历史记录'
interrupt_dialogue_prompt: '当前回复尚未完成,是否确定打断发起新会话?'
interrupt_the_conversation_and_apply_the_history_prompt: '当前回复尚未完成,是否确定打断对话应用其它记录?'
router_title_module:
login: '登录'
......@@ -308,7 +309,7 @@ personal_space_module:
search_knowledge_placeholder: '请输入知识库名称'
knowledge_name: '知识库名称'
knowledge_desc: '知识库描述'
delete_knowledge_dialog_content: '删除后将无法恢复, 是否确认删除?'
delete_knowledge_dialog_content: '删除后将无法恢复'
not_find_knowledge_message: '未找到知识库'
search_knowledge_document_placeholder: '请输入文件名称'
......@@ -342,7 +343,7 @@ personal_space_module:
add_knowledge_chunk_modal_title: '新增切片'
knowledge_chunk_content_input_placeholder: '请输入内容'
knowledge_chunk_content_input_rule: '内容不能为空'
delete_knowledge_chunk_content_message: '确认删除该切片'
delete_knowledge_chunk_content_message: '确认删除该切片'
upload_document_module:
segment_setting: '分段处理'
......
......@@ -106,6 +106,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'
......@@ -308,7 +309,7 @@ personal_space_module:
search_knowledge_placeholder: '請輸入知識庫名稱'
knowledge_name: '知識庫名稱'
knowledge_desc: '知識庫描述'
delete_knowledge_dialog_content: '刪除後將無法恢復, 是否確認刪除?'
delete_knowledge_dialog_content: '刪除後將無法恢復'
not_find_knowledge_message: '未找到知識庫'
search_knowledge_document_placeholder: '請輸入文件名稱'
......@@ -342,7 +343,7 @@ personal_space_module:
add_knowledge_chunk_modal_title: '新增切片'
knowledge_chunk_content_input_placeholder: '請輸入內容'
knowledge_chunk_content_input_rule: '內容不能為空'
delete_knowledge_chunk_content_message: '確認刪除該切片'
delete_knowledge_chunk_content_message: '確認刪除該切片'
upload_document_module:
segment_setting: '分段處理'
......
......@@ -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>
......
......@@ -408,7 +408,7 @@ function handleAIGenerateAgentSystem() {
fetchCustomEventSource({
path: '/api/rest/agentApplicationInfoRest/createAgentSystem.json',
payload: {
input: personalAppConfigStore.baseInfo.agentSystem,
input: personalAppConfigStore.baseInfo.agentTitle || personalAppConfigStore.baseInfo.agentSystem,
},
controller: generateAgentSystemController,
onMessage: (data: any) => {
......@@ -1335,7 +1335,7 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
}
:deep(.prompt-input .n-input-word-count) {
bottom: -10px !important;
bottom: -12px !important;
background: white !important;
}
......
<script setup lang="ts">
import { computed, h, onMounted, readonly, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { DropdownOption } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { sidebarMenus } from '@/router/index'
import CustomIcon from '@/components/custom-icon/custom-icon.vue'
import { useUserStore } from '@/store/modules/user'
import { usePersonalAppConfigStore } from '@/store/modules/personal-app-config'
......@@ -56,17 +54,6 @@ const agentAppOptionList = [
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(() => {
return isUpdateAgentAppConfig.value && personalAppConfigStore.baseInfo.agentId
})
......@@ -109,12 +96,8 @@ onMounted(() => {
}
})
function handleMenuSelect(_key: number, option: DropdownOption) {
router.replace({ name: option.routeName as string })
}
function handleBackPreviousPage() {
router.go(-1)
router.replace({ name: 'PersonalSpaceApp' })
}
function handleDropdownSelect(key: string) {
......@@ -171,13 +154,11 @@ async function handlePublishApplication() {
<template>
<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">
<NDropdown trigger="hover" :options="menuOptions" @select="handleMenuSelect">
<CustomIcon
icon="weui:back-outlined"
class="hover:text-theme-color mr-5 outline-none"
@click="handleBackPreviousPage"
/>
</NDropdown>
<CustomIcon
icon="weui:back-outlined"
class="hover:text-theme-color mr-5 cursor-pointer outline-none"
@click="handleBackPreviousPage"
/>
<div class="flex flex-col items-start justify-center">
<NPopover trigger="hover">
......
import { NSwitch, NPopconfirm } from 'naive-ui'
import { NSwitch } from 'naive-ui'
import { KnowledgeDocumentItem, KnowledgeItem } from './knowledge-type'
import { formatDateTime } from '@/utils/date-formatter'
import i18n from '@/locales'
......@@ -81,26 +81,12 @@ export function createKnowledgeColumn(
>
{t('common_module.data_table_module.view')}
</span>
<NPopconfirm
negative-text={t('common_module.cancel_btn_text')}
positive-text={t('common_module.confirm_btn_text')}
onNegativeClick={() => {}}
onPositiveClick={() => handleKnowledgeTableAction('delete', row.id)}
<span
className='text-error-font-color mr-5 cursor-pointer hover:opacity-80'
onClick={() => 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')}
</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>
{t('common_module.data_table_module.delete')}
</span>
</div>
)
},
......@@ -152,7 +138,7 @@ export function createKnowledgeDocumentColumn(
},
width: 236,
render(row: KnowledgeDocumentItem) {
return row.documentName.split('.')[1].toUpperCase() || '--'
return row.documentName.split('.')?.pop()?.toLowerCase() || '--'
},
},
{
......@@ -228,32 +214,16 @@ export function createKnowledgeDocumentColumn(
</span>
)}
<NPopconfirm
negative-text={t('common_module.cancel_btn_text')}
positive-text={t('common_module.confirm_btn_text')}
onNegativeClick={() => {}}
onPositiveClick={() => handleKnowledgeDocumentTableAction('delete', row)}
<span
class={[
['Complete', 'Fail'].includes(row.trainStatus)
? 'text-error-font-color mr-5 cursor-pointer hover:opacity-80'
: 'text-gray-font-color pointer-events-none mr-5 cursor-not-allowed',
]}
onClick={() => handleKnowledgeDocumentTableAction('delete', row)}
>
{{
trigger: () => (
<span
class={[
['Complete', 'Fail'].includes(row.trainStatus)
? 'text-error-font-color mr-5 cursor-pointer hover:opacity-80'
: 'text-gray-font-color pointer-events-none mr-5 cursor-not-allowed',
]}
>
{t('common_module.data_table_module.delete')}
</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>
{t('common_module.data_table_module.delete')}
</span>
</div>
)
},
......
......@@ -64,29 +64,15 @@ const isShowKnowledgeChunkAction = ref(false)
<span> {{ t('personal_space_module.knowledge_module.add_chunk_down_message') }} </span>
</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>
<n-popover trigger="hover">
<template #trigger>
<n-popover trigger="hover">
<template #trigger>
<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"
/>
</template>
<span> {{ t('common_module.data_table_module.delete') }}</span>
</n-popover>
<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"
@click="emit('delete', chunkItem.chunkRelationId)"
/>
</template>
{{ t('personal_space_module.knowledge_module.delete_knowledge_chunk_content_message') }}
</n-popconfirm>
<span> {{ t('common_module.data_table_module.delete') }}</span>
</n-popover>
<n-switch :value="chunkItem.isOpen === 'Y'" @update:value="emit('updateOpen', chunkItem)" />
</div>
......
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { ScrollbarInst } from 'naive-ui'
......@@ -14,7 +14,8 @@ import {
fetchOpenKnowledgeChunk,
fetchUpdateKnowledgeChunk,
} 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 AddKnowledgeChunkModal from './components/add-knowledge-chunk-modal.vue'
......@@ -22,6 +23,8 @@ const { t } = useI18n()
const router = useRouter()
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
const currentKdId = ref(0)
const currentKnowledgeDocumentName = ref('')
const currentKnowledgeDocumentUrl = ref('')
......@@ -34,13 +37,6 @@ const totalChunk = ref(0)
const knowledgeChunkList = ref<KnowledgeChunkItem[]>([])
const knowledgeChunkListLoading = ref(false)
const pagingInfo = ref<PaginationInfo>({
pageNo: 1,
pageSize: 10,
totalPages: 0,
totalRows: 0,
})
const defaultKnowledgeChunkData: KnowledgeChunkItem = {
knowledgeId: '',
chunkContent: '',
......@@ -65,6 +61,11 @@ const emptyKnowledgeChunkListText = computed(() => {
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 () => {
if (!router.currentRoute.value.params.kdId) {
window.$message.warning(t('personal_space_module.knowledge_module.not_find_knowledge_document_message'))
......@@ -98,16 +99,17 @@ async function handleGetKnowledgeChunkList() {
searchKnowledgeChunkValue.value,
currentKdId.value,
{
pagingInfo: pagingInfo.value,
pagingInfo: paginationData,
},
)
if (res.code === 0) {
totalChunk.value = res.data.totalChunk
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
isSearchEmptyList.value = !!searchKnowledgeChunkValue.value && pagingInfo.value.totalRows === 0
isSearchEmptyList.value = !!searchKnowledgeChunkValue.value && paginationData.totalRows === 0
}
}
......@@ -115,21 +117,8 @@ function handleBackKnowledgeDocumentList() {
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() {
pagingInfo.value.pageNo = 1
paginationData.pageNo = 1
await handleGetKnowledgeChunkList()
scrollBarRef.value?.scrollTo({ top: 0 })
}
......@@ -184,15 +173,19 @@ async function handleAddKnowledgeChunk(chunkContent: string, chunkSort: number)
}
async function handleDeleteKnowledgeChunk(chunkRelationId: string) {
const res = await fetchDeleteKnowledgeChunk({
kdId: currentKdId.value,
chunkRelationId,
})
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_chunk_content_message'))
.then(async () => {
const res = await fetchDeleteKnowledgeChunk({
kdId: currentKdId.value,
chunkRelationId,
})
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeChunkList()
}
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeChunkList()
}
})
}
async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) {
......@@ -288,9 +281,9 @@ async function handleUpdateOpenKnowledgeChunk(chunkItem: KnowledgeChunkItem) {
<div class="mt-4 flex justify-end">
<CustomPagination
:paging-info="pagingInfo"
@update-page-no="handleGetKnowledgeChunkListUpdatePageNo"
@update-page-size="handleGetKnowledgeChunkListUpdatePageSize"
:paging-info="paginationData"
@update-page-no="handlePageNoChange"
@update-page-size="handlePageSizeChange"
/>
</div>
......
......@@ -139,12 +139,16 @@ function handleToViewDocumentDetail(kdId: number) {
}
async function handleDeleteKnowledgeDocument(kdId: number) {
const res = await fetchDelKnowledgeDocument(currentKnowledgeId.value, kdId)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList()
}
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchDelKnowledgeDocument(currentKnowledgeId.value, kdId)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList()
}
})
}
async function handleTrainKnowledgeDocument(knowledgeDocumentItem: KnowledgeDocumentItem) {
......@@ -181,12 +185,16 @@ function handleUpdateCheckedKdId(kdIdList: number[]) {
}
async function handleBatchDelDocument() {
const res = await fetchBatchDelKnowledgeDocument(currentKnowledgeId.value, checkedKdIdList.value)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList()
}
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchBatchDelKnowledgeDocument(currentKnowledgeId.value, checkedKdIdList.value)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeDocumentList()
}
})
}
function handleToUploadDocument() {
......
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { Search } from '@icon-park/vue-next'
import { createKnowledgeColumn } from './columns.tsx'
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 { usePagination } from '@/composables/usePagination.ts'
import { fetchDelKnowledgeById, fetchEnableKnowledgeInfo, fetchGetKnowledgeList } from '@/apis/knowledge.ts'
const { t } = useI18n()
......@@ -14,16 +15,10 @@ const { t } = useI18n()
const router = useRouter()
const { pageContentWrapRef, tableContentY } = useTableScrollY(48 + 32 + 16 + 16 + 28)
const { paginationData, handlePageNoChange, handlePageSizeChange } = usePagination()
const knowledgeColumns = createKnowledgeColumn(handleClickKnowledgeTableAction)
const pagingInfo = ref<PaginationInfo>({
pageNo: 1,
pageSize: 10,
totalPages: 0,
totalRows: 0,
})
const knowledgeListTableLoading = ref(false)
const knowledgeList = ref<KnowledgeItem[]>([])
......@@ -38,6 +33,8 @@ const emptyTableDataText = computed(() => {
return isSearchEmptyList.value ? t('common_module.search_empty_data') : t('common_module.empty_data')
})
watch([() => paginationData.pageNo, () => paginationData.pageSize], handleGetKnowledgeList)
onMounted(async () => {
await handleGetKnowledgeList()
})
......@@ -46,14 +43,15 @@ async function handleGetKnowledgeList() {
knowledgeListTableLoading.value = true
const res = await fetchGetKnowledgeList<KnowledgeItem[]>('', searchKnowledgeInputValue.value, {
pagingInfo: pagingInfo.value,
pagingInfo: paginationData,
})
if (res.code === 0) {
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
isSearchEmptyList.value = !!searchKnowledgeInputValue.value && pagingInfo.value.totalRows === 0
isSearchEmptyList.value = !!searchKnowledgeInputValue.value && paginationData.totalRows === 0
}
}
......@@ -88,28 +86,21 @@ function handleViewDocumentList(knowledgeId: number) {
}
async function handleDeleteKnowledge(knowledgeId: number) {
const res = await fetchDelKnowledgeById(knowledgeId)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeList()
}
window.$message
.ctWarning('', t('personal_space_module.knowledge_module.delete_knowledge_dialog_content'))
.then(async () => {
const res = await fetchDelKnowledgeById(knowledgeId)
if (res.code === 0) {
window.$message.success(t('common_module.delete_success_message'))
await handleGetKnowledgeList()
}
})
}
function handleSearchKnowledge() {
pagingInfo.value.pageNo = 1
paginationData.pageNo = 1
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>
<template>
......@@ -154,9 +145,9 @@ async function handleGetKnowledgeListUpdatePageSize(pageSize: number) {
<footer v-show="isLoadingPagination" class="flex justify-end">
<CustomPagination
:paging-info="pagingInfo"
@update-page-no="handleGetKnowledgeListUpdatePageNo"
@update-page-size="handleGetKnowledgeListUpdatePageSize"
:paging-info="paginationData"
@update-page-no="handlePageNoChange"
@update-page-size="handlePageSizeChange"
/>
</footer>
</div>
......
......@@ -5,6 +5,7 @@ import CustomLoading from './custom-loading.vue'
import MarkdownRender from '@/components/markdown-render/markdown-render.vue'
import { PersonalAppConfigState } from '@/store/types/personal-app-config'
import { useLayoutConfig } from '@/composables/useLayoutConfig'
import { useUserStore } from '@/store/modules/user'
interface Props {
role: 'user' | 'assistant'
......@@ -16,9 +17,13 @@ const { t } = useI18n()
const props = defineProps<Props>()
const userStore = useUserStore()
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(() => {
return (
......
......@@ -33,7 +33,7 @@ function handleToLogin() {
<template>
<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>
<NButton
v-show="isLogin"
......
......@@ -130,6 +130,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