feat: Cancel the restriction on the number of conversation history records

This commit is contained in:
wangdan-fit2cloud 2025-12-23 10:46:13 +08:00
parent 74b7633c2f
commit 6aa3999e05
8 changed files with 187 additions and 111 deletions

View File

@ -695,7 +695,7 @@ onMounted(() => {
// 2.
const currentTransform = target.style.transform
const transformValues = parseTransform(currentTransform)
let { scale, translateX, translateY } = transformValues
const { scale, translateX, translateY } = transformValues
// scale
const currentScale = Array.isArray(scale) ? scale[0] : scale

View File

@ -2,13 +2,13 @@
<div v-infinite-scroll="loadData" :infinite-scroll-disabled="disabledScroll">
<slot />
</div>
<div style="padding: 0 10px 16px">
<el-divider v-if="size > 0 && loading" style="background: none">
<el-text type="info"> {{ $t('components.loading') }}...</el-text>
</el-divider>
<el-divider v-if="noMore" style="background: none !important">
<el-text type="info"> {{ $t('components.noMore') }}</el-text>
</el-divider>
<div style="padding: 0 10px 16px" class="text-center lighter color-secondary">
<el-text class="text-with-lines" type="info" v-if="size > 0 && loading">
{{ $t('components.loading') }}...</el-text
>
<el-text class="text-with-lines" v-if="noMore" type="info">
{{ $t('components.noMore') }}</el-text
>
</div>
</template>
<script setup lang="ts">
@ -61,7 +61,9 @@ const noMore = computed(
props.size > 0 && props.size === props.total && props.total > props.page_size && !props.loading,
)
const disabledScroll = computed(() => props.size > 0 && (props.loading || noMore.value))
console.log(props.size)
console.log(props.total)
console.log(props.page_size)
function loadData() {
if (props.total > props.page_size) {
current.value += 1
@ -70,4 +72,26 @@ function loadData() {
}
}
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.text-with-lines {
position: relative;
display: inline-block;
}
.text-with-lines::before,
.text-with-lines::after {
content: '';
position: absolute;
width: 80px;
border-bottom: 1px solid var(--el-border-color);
top: 10px;
}
.text-with-lines::before {
left: -88px; /* 左侧线条位置 */
}
.text-with-lines::after {
right: -82px; /* 右侧线条位置 */
}
</style>

View File

@ -662,12 +662,6 @@ function getFolder(bool?: boolean) {
})
}
function clickFolder(item: any) {
folder.setCurrentFolder(item)
paginationConfig.current_page = 1
applicationList.value = []
getList()
}
function folderClickHandle(row: any) {
if (row.id === folder.currentFolder?.id) {

View File

@ -52,54 +52,63 @@
</div>
<div v-show="!isPcCollapse" class="left-height" v-if="showHistory">
<el-scrollbar>
<div class="p-16 pt-0">
<common-list
:data="chatLogData"
class="mt-8"
v-loading="leftLoading"
:defaultActive="currentChatId"
@click="handleClickList"
@mouseenter="mouseenter"
@mouseleave="mouseId = ''"
>
<template #default="{ row }">
<div class="flex-between">
<span :title="row.abstract" class="ellipsis" style="max-width: 180px">
{{ row.abstract }}
</span>
<div @click.stop v-show="mouseId === row.id && row.id !== 'new'">
<el-dropdown trigger="click" :teleported="false">
<el-button text>
<AppIcon iconName="app-more"></AppIcon>
</el-button>
<InfiniteScroll
:size="chatLogData.length"
:total="_chatLogPagination?.total || 0"
:page_size="_chatLogPagination?.page_size || 20"
v-model:current_page="_chatLogPagination.current_page"
@load="scrollData"
:loading="leftLoading"
>
<div class="p-16 pt-0">
<common-list
:data="chatLogData"
class="mt-8"
v-loading="leftLoading"
:defaultActive="currentChatId"
@click="handleClickList"
@mouseenter="mouseenter"
@mouseleave="mouseId = ''"
>
<template #default="{ row }">
<div class="flex-between">
<span :title="row.abstract" class="ellipsis" style="max-width: 180px">
{{ row.abstract }}
</span>
<div @click.stop v-show="mouseId === row.id && row.id !== 'new'">
<el-dropdown trigger="click" :teleported="false">
<el-button text>
<AppIcon iconName="app-more"></AppIcon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click.stop="editLogTitle(row)">
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
{{ $t('common.edit') }}
</el-dropdown-item>
<el-dropdown-item @click.stop="deleteChatLog(row)">
<AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
{{ $t('common.delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click.stop="editLogTitle(row)">
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
{{ $t('common.edit') }}
</el-dropdown-item>
<el-dropdown-item @click.stop="deleteChatLog(row)">
<AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
{{ $t('common.delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</div>
</template>
</template>
<template #empty>
<div class="text-center">
<el-text type="info">{{ $t('chat.noHistory') }}</el-text>
</div>
</template>
</common-list>
</div>
<div v-if="chatLogData?.length" class="text-center lighter color-secondary">
<template #empty>
<div class="text-center">
<el-text type="info">{{ $t('chat.noHistory') }}</el-text>
</div>
</template>
</common-list>
</div>
</InfiniteScroll>
<!-- <div v-if="chatLogData?.length" class="text-center lighter color-secondary">
<span>{{ $t('chat.only20history') }}</span>
</div>
</div> -->
</el-scrollbar>
</div>
<el-menu-item index="1" v-show="isPcCollapse" @click="newChat">
@ -164,12 +173,15 @@
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ref, computed, inject, type Ref } from 'vue'
import { isAppIcon } from '@/utils/common'
import EditTitleDialog from './EditTitleDialog.vue'
import useStore from '@/stores'
const { user } = useStore()
const scrollData = inject('scrollData') as any
//
const chatLogPagination = inject('chatLogPagination') as any
const _chatLogPagination = chatLogPagination()
const props = defineProps<{
applicationDetail: any
chatLogData: any[]
@ -180,12 +192,18 @@ const props = defineProps<{
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle', 'clearChat'])
const showHistory = computed(() => {
console.log(props.applicationDetail?.show_history)
return props.applicationDetail?.show_history != null || undefined
? props.applicationDetail?.show_history
: true
})
//
const updateCurrentPage = (page: number) => {
if (chatLogPagination) {
chatLogPagination.current_page = page
}
}
const EditTitleDialogRef = ref()
const mouseId = ref('')
@ -193,6 +211,7 @@ const mouseId = ref('')
function mouseenter(row: any) {
mouseId.value = row.id
}
const newChat = () => {
emit('newChat')
}

View File

@ -87,13 +87,16 @@
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, nextTick, computed } from 'vue'
import { ref, onMounted, reactive, nextTick, computed, provide } from 'vue'
import { isAppIcon } from '@/utils/common'
import { hexToRgba } from '@/utils/theme'
import { t } from '@/locales'
import ChatHistoryDrawer from './component/ChatHistoryDrawer.vue'
import chatAPI from '@/api/chat/chat'
provide('scrollData', loadInfiniteScroll)
provide('chatLogPagination', () => chatLogPagination)
const AiChatRef = ref()
const loading = ref(false)
const left_loading = ref(false)
@ -176,21 +179,28 @@ function newChat() {
show.value = false
}
const chatLogPagination = ref({
total: 0,
page_size: 20,
current_page: 1,
})
function getChatLog(refresh?: boolean) {
const page = {
current_page: 1,
page_size: 20,
}
chatAPI
.pageChat(chatLogPagination.value.current_page, chatLogPagination.value.page_size, left_loading)
.then((res: any) => {
chatLogPagination.value.total = res.data.total
chatLogData.value = [...chatLogData.value, ...res.data.records]
if (!refresh) {
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
}
})
}
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
chatLogData.value = res.data.records
if (!refresh) {
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
}
})
function loadInfiniteScroll() {
getChatLog(true)
}
function getChatRecord() {
@ -241,6 +251,8 @@ function refreshFieldTitle(chatId: string, abstract: string) {
function refresh(id: string) {
currentChatId.value = id
chatLogPagination.value.current_page = 1
chatLogData.value = []
getChatLog(true)
}
/**

View File

@ -38,7 +38,7 @@
</template>
<script setup lang="ts">
import { ref, computed, defineModel } from 'vue'
import { ref, computed } from 'vue'
import useStore from '@/stores'
import UserCenterDrawer from './UserCenterDrawer.vue'
import HistoryPanel from '@/views/chat/component/HistoryPanel.vue'

View File

@ -86,7 +86,7 @@
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, nextTick, computed } from 'vue'
import { ref, onMounted, reactive, nextTick, computed, provide } from 'vue'
import { isAppIcon } from '@/utils/common'
import { hexToRgba } from '@/utils/theme'
import useStore from '@/stores'
@ -94,6 +94,9 @@ import { t } from '@/locales'
import ChatHistoryDrawer from './component/ChatHistoryDrawer.vue'
import chatAPI from '@/api/chat/chat'
provide('scrollData', loadInfiniteScroll)
provide('chatLogPagination', () => chatLogPagination)
const { common } = useStore()
const AiChatRef = ref()
@ -139,6 +142,8 @@ function clearChat() {
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
chatLogPagination.value.current_page = 1
chatLogData.value = []
getChatLog()
})
}
@ -182,21 +187,27 @@ function newChat() {
show.value = false
}
const chatLogPagination = ref({
total: 0,
page_size: 20,
current_page: 1,
})
function getChatLog(refresh?: boolean) {
const page = {
current_page: 1,
page_size: 20,
}
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
chatLogData.value = res.data.records
if (!refresh) {
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
}
})
chatAPI
.pageChat(chatLogPagination.value.current_page, chatLogPagination.value.page_size, left_loading)
.then((res: any) => {
chatLogPagination.value.total = res.data.total
chatLogData.value = [...chatLogData.value, ...res.data.records]
if (!refresh) {
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
}
})
}
function loadInfiniteScroll() {
getChatLog(true)
}
function getChatRecord() {
@ -247,6 +258,8 @@ function refreshFieldTitle(chatId: string, abstract: string) {
function refresh(id: string) {
currentChatId.value = id
chatLogPagination.value.current_page = 1
chatLogData.value = []
getChatLog(true)
}
/**

View File

@ -224,7 +224,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, nextTick, computed, watch } from 'vue'
import { ref, onMounted, nextTick, computed, watch, provide } from 'vue'
import { marked } from 'marked'
import { saveAs } from 'file-saver'
import chatAPI from '@/api/chat/chat'
@ -244,6 +244,9 @@ import { getFileUrl } from '@/utils/common'
import PdfExport from '@/components/pdf-export/index.vue'
useResize()
provide('scrollData', loadInfiniteScroll)
provide('chatLogPagination', () => chatLogPagination)
const pdfExportRef = ref<InstanceType<typeof PdfExport>>()
const { common, chatUser } = useStore()
const router = useRouter()
@ -348,6 +351,8 @@ function clearChat() {
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
chatLogPagination.value.current_page = 1
chatLogData.value = []
getChatLog()
})
}
@ -385,24 +390,31 @@ function newChat() {
}
}
const chatLogPagination = ref({
total: 0,
page_size: 20,
current_page: 1,
})
function getChatLog(refresh?: boolean) {
const page = {
current_page: 1,
page_size: 20,
}
chatAPI
.pageChat(chatLogPagination.value.current_page, chatLogPagination.value.page_size, left_loading)
.then((res: any) => {
chatLogPagination.value.total = res.data.total
chatLogData.value = [...chatLogData.value, ...res.data.records]
if (refresh) {
currentChatName.value = chatLogData.value?.[0]?.abstract
} else {
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
currentChatName.value = t('chat.createChat')
}
})
}
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
chatLogData.value = res.data.records
if (refresh) {
currentChatName.value = chatLogData.value?.[0]?.abstract
} else {
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
currentChatId.value = 'new'
currentChatName.value = t('chat.createChat')
}
})
function loadInfiniteScroll() {
getChatLog(true)
}
function getChatRecord() {
@ -459,6 +471,8 @@ const clickListHandle = (item: any) => {
function refresh(id: string) {
currentChatId.value = id
chatLogPagination.value.current_page = 1
chatLogData.value = []
getChatLog(true)
}