Skip to content

Commit 6aa3999

Browse files
feat: Cancel the restriction on the number of conversation history records
1 parent 74b7633 commit 6aa3999

File tree

8 files changed

+187
-111
lines changed

8 files changed

+187
-111
lines changed

ui/src/components/ai-chat/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ onMounted(() => {
695695
// 2. 解析当前变换状态
696696
const currentTransform = target.style.transform
697697
const transformValues = parseTransform(currentTransform)
698-
let { scale, translateX, translateY } = transformValues
698+
const { scale, translateX, translateY } = transformValues
699699
// 确保scale是数值类型
700700
const currentScale = Array.isArray(scale) ? scale[0] : scale
701701

ui/src/components/infinite-scroll/index.vue

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<div v-infinite-scroll="loadData" :infinite-scroll-disabled="disabledScroll">
33
<slot />
44
</div>
5-
<div style="padding: 0 10px 16px">
6-
<el-divider v-if="size > 0 && loading" style="background: none">
7-
<el-text type="info"> {{ $t('components.loading') }}...</el-text>
8-
</el-divider>
9-
<el-divider v-if="noMore" style="background: none !important">
10-
<el-text type="info"> {{ $t('components.noMore') }}</el-text>
11-
</el-divider>
5+
<div style="padding: 0 10px 16px" class="text-center lighter color-secondary">
6+
<el-text class="text-with-lines" type="info" v-if="size > 0 && loading">
7+
{{ $t('components.loading') }}...</el-text
8+
>
9+
<el-text class="text-with-lines" v-if="noMore" type="info">
10+
{{ $t('components.noMore') }}</el-text
11+
>
1212
</div>
1313
</template>
1414
<script setup lang="ts">
@@ -61,7 +61,9 @@ const noMore = computed(
6161
props.size > 0 && props.size === props.total && props.total > props.page_size && !props.loading,
6262
)
6363
const disabledScroll = computed(() => props.size > 0 && (props.loading || noMore.value))
64-
64+
console.log(props.size)
65+
console.log(props.total)
66+
console.log(props.page_size)
6567
function loadData() {
6668
if (props.total > props.page_size) {
6769
current.value += 1
@@ -70,4 +72,26 @@ function loadData() {
7072
}
7173
}
7274
</script>
73-
<style lang="scss" scoped></style>
75+
<style lang="scss" scoped>
76+
.text-with-lines {
77+
position: relative;
78+
display: inline-block;
79+
}
80+
81+
.text-with-lines::before,
82+
.text-with-lines::after {
83+
content: '';
84+
position: absolute;
85+
width: 80px;
86+
border-bottom: 1px solid var(--el-border-color);
87+
top: 10px;
88+
}
89+
90+
.text-with-lines::before {
91+
left: -88px; /* 左侧线条位置 */
92+
}
93+
94+
.text-with-lines::after {
95+
right: -82px; /* 右侧线条位置 */
96+
}
97+
</style>

ui/src/views/application/index.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,6 @@ function getFolder(bool?: boolean) {
662662
})
663663
}
664664
665-
function clickFolder(item: any) {
666-
folder.setCurrentFolder(item)
667-
paginationConfig.current_page = 1
668-
applicationList.value = []
669-
getList()
670-
}
671665
672666
function folderClickHandle(row: any) {
673667
if (row.id === folder.currentFolder?.id) {

ui/src/views/chat/component/HistoryPanel.vue

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -52,54 +52,63 @@
5252
</div>
5353
<div v-show="!isPcCollapse" class="left-height" v-if="showHistory">
5454
<el-scrollbar>
55-
<div class="p-16 pt-0">
56-
<common-list
57-
:data="chatLogData"
58-
class="mt-8"
59-
v-loading="leftLoading"
60-
:defaultActive="currentChatId"
61-
@click="handleClickList"
62-
@mouseenter="mouseenter"
63-
@mouseleave="mouseId = ''"
64-
>
65-
<template #default="{ row }">
66-
<div class="flex-between">
67-
<span :title="row.abstract" class="ellipsis" style="max-width: 180px">
68-
{{ row.abstract }}
69-
</span>
70-
<div @click.stop v-show="mouseId === row.id && row.id !== 'new'">
71-
<el-dropdown trigger="click" :teleported="false">
72-
<el-button text>
73-
<AppIcon iconName="app-more"></AppIcon>
74-
</el-button>
55+
<InfiniteScroll
56+
:size="chatLogData.length"
57+
:total="_chatLogPagination?.total || 0"
58+
:page_size="_chatLogPagination?.page_size || 20"
59+
v-model:current_page="_chatLogPagination.current_page"
60+
@load="scrollData"
61+
:loading="leftLoading"
62+
>
63+
<div class="p-16 pt-0">
64+
<common-list
65+
:data="chatLogData"
66+
class="mt-8"
67+
v-loading="leftLoading"
68+
:defaultActive="currentChatId"
69+
@click="handleClickList"
70+
@mouseenter="mouseenter"
71+
@mouseleave="mouseId = ''"
72+
>
73+
<template #default="{ row }">
74+
<div class="flex-between">
75+
<span :title="row.abstract" class="ellipsis" style="max-width: 180px">
76+
{{ row.abstract }}
77+
</span>
78+
<div @click.stop v-show="mouseId === row.id && row.id !== 'new'">
79+
<el-dropdown trigger="click" :teleported="false">
80+
<el-button text>
81+
<AppIcon iconName="app-more"></AppIcon>
82+
</el-button>
7583

76-
<template #dropdown>
77-
<el-dropdown-menu>
78-
<el-dropdown-item @click.stop="editLogTitle(row)">
79-
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
80-
{{ $t('common.edit') }}
81-
</el-dropdown-item>
82-
<el-dropdown-item @click.stop="deleteChatLog(row)">
83-
<AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
84-
{{ $t('common.delete') }}
85-
</el-dropdown-item>
86-
</el-dropdown-menu>
87-
</template>
88-
</el-dropdown>
84+
<template #dropdown>
85+
<el-dropdown-menu>
86+
<el-dropdown-item @click.stop="editLogTitle(row)">
87+
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
88+
{{ $t('common.edit') }}
89+
</el-dropdown-item>
90+
<el-dropdown-item @click.stop="deleteChatLog(row)">
91+
<AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
92+
{{ $t('common.delete') }}
93+
</el-dropdown-item>
94+
</el-dropdown-menu>
95+
</template>
96+
</el-dropdown>
97+
</div>
8998
</div>
90-
</div>
91-
</template>
99+
</template>
92100

93-
<template #empty>
94-
<div class="text-center">
95-
<el-text type="info">{{ $t('chat.noHistory') }}</el-text>
96-
</div>
97-
</template>
98-
</common-list>
99-
</div>
100-
<div v-if="chatLogData?.length" class="text-center lighter color-secondary">
101+
<template #empty>
102+
<div class="text-center">
103+
<el-text type="info">{{ $t('chat.noHistory') }}</el-text>
104+
</div>
105+
</template>
106+
</common-list>
107+
</div>
108+
</InfiniteScroll>
109+
<!-- <div v-if="chatLogData?.length" class="text-center lighter color-secondary">
101110
<span>{{ $t('chat.only20history') }}</span>
102-
</div>
111+
</div> -->
103112
</el-scrollbar>
104113
</div>
105114
<el-menu-item index="1" v-show="isPcCollapse" @click="newChat">
@@ -164,12 +173,15 @@
164173
</div>
165174
</template>
166175
<script setup lang="ts">
167-
import { ref, computed } from 'vue'
176+
import { ref, computed, inject, type Ref } from 'vue'
168177
import { isAppIcon } from '@/utils/common'
169178
import EditTitleDialog from './EditTitleDialog.vue'
170-
import useStore from '@/stores'
171179
172-
const { user } = useStore()
180+
const scrollData = inject('scrollData') as any
181+
// 子组件
182+
const chatLogPagination = inject('chatLogPagination') as any
183+
const _chatLogPagination = chatLogPagination()
184+
173185
const props = defineProps<{
174186
applicationDetail: any
175187
chatLogData: any[]
@@ -180,19 +192,26 @@ const props = defineProps<{
180192
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle', 'clearChat'])
181193
182194
const showHistory = computed(() => {
183-
console.log(props.applicationDetail?.show_history)
184195
return props.applicationDetail?.show_history != null || undefined
185196
? props.applicationDetail?.show_history
186197
: true
187198
})
188199
200+
// 更新页码的方法
201+
const updateCurrentPage = (page: number) => {
202+
if (chatLogPagination) {
203+
chatLogPagination.current_page = page
204+
}
205+
}
206+
189207
const EditTitleDialogRef = ref()
190208
191209
const mouseId = ref('')
192210
193211
function mouseenter(row: any) {
194212
mouseId.value = row.id
195213
}
214+
196215
const newChat = () => {
197216
emit('newChat')
198217
}

ui/src/views/chat/embed/index.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,16 @@
8787
</div>
8888
</template>
8989
<script setup lang="ts">
90-
import { ref, onMounted, reactive, nextTick, computed } from 'vue'
90+
import { ref, onMounted, reactive, nextTick, computed, provide } from 'vue'
9191
import { isAppIcon } from '@/utils/common'
9292
import { hexToRgba } from '@/utils/theme'
9393
import { t } from '@/locales'
9494
import ChatHistoryDrawer from './component/ChatHistoryDrawer.vue'
9595
import chatAPI from '@/api/chat/chat'
9696
97+
provide('scrollData', loadInfiniteScroll)
98+
provide('chatLogPagination', () => chatLogPagination)
99+
97100
const AiChatRef = ref()
98101
const loading = ref(false)
99102
const left_loading = ref(false)
@@ -176,21 +179,28 @@ function newChat() {
176179
show.value = false
177180
}
178181
182+
const chatLogPagination = ref({
183+
total: 0,
184+
page_size: 20,
185+
current_page: 1,
186+
})
179187
function getChatLog(refresh?: boolean) {
180-
const page = {
181-
current_page: 1,
182-
page_size: 20,
183-
}
188+
chatAPI
189+
.pageChat(chatLogPagination.value.current_page, chatLogPagination.value.page_size, left_loading)
190+
.then((res: any) => {
191+
chatLogPagination.value.total = res.data.total
192+
chatLogData.value = [...chatLogData.value, ...res.data.records]
193+
if (!refresh) {
194+
paginationConfig.current_page = 1
195+
paginationConfig.total = 0
196+
currentRecordList.value = []
197+
currentChatId.value = 'new'
198+
}
199+
})
200+
}
184201
185-
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
186-
chatLogData.value = res.data.records
187-
if (!refresh) {
188-
paginationConfig.current_page = 1
189-
paginationConfig.total = 0
190-
currentRecordList.value = []
191-
currentChatId.value = 'new'
192-
}
193-
})
202+
function loadInfiniteScroll() {
203+
getChatLog(true)
194204
}
195205
196206
function getChatRecord() {
@@ -241,6 +251,8 @@ function refreshFieldTitle(chatId: string, abstract: string) {
241251
242252
function refresh(id: string) {
243253
currentChatId.value = id
254+
chatLogPagination.value.current_page = 1
255+
chatLogData.value = []
244256
getChatLog(true)
245257
}
246258
/**

ui/src/views/chat/mobile/component/ChatHistoryDrawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</template>
3939

4040
<script setup lang="ts">
41-
import { ref, computed, defineModel } from 'vue'
41+
import { ref, computed } from 'vue'
4242
import useStore from '@/stores'
4343
import UserCenterDrawer from './UserCenterDrawer.vue'
4444
import HistoryPanel from '@/views/chat/component/HistoryPanel.vue'

ui/src/views/chat/mobile/index.vue

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,17 @@
8686
</div>
8787
</template>
8888
<script setup lang="ts">
89-
import { ref, onMounted, reactive, nextTick, computed } from 'vue'
89+
import { ref, onMounted, reactive, nextTick, computed, provide } from 'vue'
9090
import { isAppIcon } from '@/utils/common'
9191
import { hexToRgba } from '@/utils/theme'
9292
import useStore from '@/stores'
9393
import { t } from '@/locales'
9494
import ChatHistoryDrawer from './component/ChatHistoryDrawer.vue'
9595
import chatAPI from '@/api/chat/chat'
9696
97+
provide('scrollData', loadInfiniteScroll)
98+
provide('chatLogPagination', () => chatLogPagination)
99+
97100
const { common } = useStore()
98101
99102
const AiChatRef = ref()
@@ -139,6 +142,8 @@ function clearChat() {
139142
paginationConfig.current_page = 1
140143
paginationConfig.total = 0
141144
currentRecordList.value = []
145+
chatLogPagination.value.current_page = 1
146+
chatLogData.value = []
142147
getChatLog()
143148
})
144149
}
@@ -182,21 +187,27 @@ function newChat() {
182187
show.value = false
183188
}
184189
190+
const chatLogPagination = ref({
191+
total: 0,
192+
page_size: 20,
193+
current_page: 1,
194+
})
185195
function getChatLog(refresh?: boolean) {
186-
const page = {
187-
current_page: 1,
188-
page_size: 20,
189-
}
190-
191-
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
192-
chatLogData.value = res.data.records
193-
if (!refresh) {
194-
paginationConfig.current_page = 1
195-
paginationConfig.total = 0
196-
currentRecordList.value = []
197-
currentChatId.value = 'new'
198-
}
199-
})
196+
chatAPI
197+
.pageChat(chatLogPagination.value.current_page, chatLogPagination.value.page_size, left_loading)
198+
.then((res: any) => {
199+
chatLogPagination.value.total = res.data.total
200+
chatLogData.value = [...chatLogData.value, ...res.data.records]
201+
if (!refresh) {
202+
paginationConfig.current_page = 1
203+
paginationConfig.total = 0
204+
currentRecordList.value = []
205+
currentChatId.value = 'new'
206+
}
207+
})
208+
}
209+
function loadInfiniteScroll() {
210+
getChatLog(true)
200211
}
201212
202213
function getChatRecord() {
@@ -247,6 +258,8 @@ function refreshFieldTitle(chatId: string, abstract: string) {
247258
248259
function refresh(id: string) {
249260
currentChatId.value = id
261+
chatLogPagination.value.current_page = 1
262+
chatLogData.value = []
250263
getChatLog(true)
251264
}
252265
/**

0 commit comments

Comments
 (0)