fix: 修复对话相关问题

fix: 修复对话相关问题
This commit is contained in:
wangdan-fit2cloud 2024-05-22 18:02:41 +08:00 committed by GitHub
commit ca9cb9e355
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 76 additions and 38 deletions

View File

@ -3,8 +3,12 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta
<base target=_blank> name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,
viewport-fit=cover"
/>
<base target="_blank" />
<title>%VITE_APP_TITLE%</title> <title>%VITE_APP_TITLE%</title>
</head> </head>
<body> <body>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="application-list-container p-24" style="padding-top: 16px"> <div class="application-list-container p-24" style="padding-top: 16px">
<div class="flex-between mb-16"> <div class="flex-between mb-16">
<h3>{{$t('views.application.applicationList.title')}}</h3> <h3>{{ $t('views.application.applicationList.title') }}</h3>
<el-input <el-input
v-model="searchValue" v-model="searchValue"
@change="searchHandle" @change="searchHandle"
@ -22,7 +22,10 @@
> >
<el-row :gutter="15"> <el-row :gutter="15">
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb-16"> <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb-16">
<CardAdd :title="$t('views.application.applicationList.card.createApplication')" @click="router.push({ path: '/application/create' })" /> <CardAdd
:title="$t('views.application.applicationList.card.createApplication')"
@click="router.push({ path: '/application/create' })"
/>
</el-col> </el-col>
<el-col <el-col
:xs="24" :xs="24"
@ -62,13 +65,21 @@
<template #footer> <template #footer>
<div class="footer-content"> <div class="footer-content">
<el-tooltip effect="dark" :content="$t('views.application.applicationList.card.demo')" placement="top"> <el-tooltip
effect="dark"
:content="$t('views.application.applicationList.card.demo')"
placement="top"
>
<el-button text @click.stop @click="getAccessToken(item.id)"> <el-button text @click.stop @click="getAccessToken(item.id)">
<AppIcon iconName="app-view"></AppIcon> <AppIcon iconName="app-view"></AppIcon>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<el-tooltip effect="dark" :content="$t('views.application.applicationList.card.setting')" placement="top"> <el-tooltip
effect="dark"
:content="$t('views.application.applicationList.card.setting')"
placement="top"
>
<el-button <el-button
text text
@click.stop="router.push({ path: `/application/${item.id}/setting` })" @click.stop="router.push({ path: `/application/${item.id}/setting` })"
@ -77,7 +88,11 @@
</el-button> </el-button>
</el-tooltip> </el-tooltip>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<el-tooltip effect="dark" :content="$t('views.application.applicationList.card.delete.tooltip')" placement="top"> <el-tooltip
effect="dark"
:content="$t('views.application.applicationList.card.delete.tooltip')"
placement="top"
>
<el-button text @click.stop="deleteApplication(item)"> <el-button text @click.stop="deleteApplication(item)">
<el-icon><Delete /></el-icon> <el-icon><Delete /></el-icon>
</el-button> </el-button>
@ -122,7 +137,7 @@ function searchHandle() {
} }
function getAccessToken(id: string) { function getAccessToken(id: string) {
application.asyncGetAccessToken(id, loading).then((res: any) => { application.asyncGetAccessToken(id, loading).then((res: any) => {
window.open(application.location + res?.data?.access_token + '?mode=pc') window.open(application.location + res?.data?.access_token)
}) })
} }
@ -130,11 +145,13 @@ function deleteApplication(row: any) {
MsgConfirm( MsgConfirm(
// @ts-ignore // @ts-ignore
`${t('views.application.applicationList.card.delete.confirmTitle')}${row.name} ?`, `${t('views.application.applicationList.card.delete.confirmTitle')}${row.name} ?`,
t('views.application.applicationList.card.delete.confirmMessage'), { t('views.application.applicationList.card.delete.confirmMessage'),
{
confirmButtonText: t('views.application.applicationList.card.delete.confirmButton'), confirmButtonText: t('views.application.applicationList.card.delete.confirmButton'),
cancelButtonText: t('views.application.applicationList.card.delete.cancelButton'), cancelButtonText: t('views.application.applicationList.card.delete.cancelButton'),
confirmButtonClass: 'danger' confirmButtonClass: 'danger'
}) }
)
.then(() => { .then(() => {
applicationApi.delApplication(row.id, loading).then(() => { applicationApi.delApplication(row.id, loading).then(() => {
const index = applicationList.value.findIndex((v) => v.id === row.id) const index = applicationList.value.findIndex((v) => v.id === row.id)

View File

@ -48,7 +48,7 @@
{{ currentChatName }} {{ currentChatName }}
</h4> </h4>
<span v-if="currentRecordList.length" class="flex align-center"> <span class="flex align-center" v-if="currentRecordList.length">
<el-dropdown class="mr-8"> <el-dropdown class="mr-8">
<AppIcon <AppIcon
iconName="takeaway-box" iconName="takeaway-box"
@ -63,8 +63,15 @@
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<AppIcon iconName="app-chat-record" class="info mr-8" style="font-size: 16px"></AppIcon> <AppIcon
<span class="lighter"> {{ paginationConfig.total }} 条提问 </span> v-if="paginationConfig.total"
iconName="app-chat-record"
class="info mr-8"
style="font-size: 16px"
></AppIcon>
<span v-if="paginationConfig.total" class="lighter">
{{ paginationConfig.total }} 条提问
</span>
</span> </span>
</div> </div>
<div class="right-height chat-width"> <div class="right-height chat-width">
@ -84,7 +91,7 @@
</div> </div>
<div class="collapse"> <div class="collapse">
<el-button size="small" @click="isCollapse = !isCollapse"> <el-button @click="isCollapse = !isCollapse">
<el-icon> <component :is="isCollapse ? 'Fold' : 'Expand'" /></el-icon> <el-icon> <component :is="isCollapse ? 'Fold' : 'Expand'" /></el-icon>
</el-button> </el-button>
</div> </div>
@ -131,7 +138,7 @@ const applicationDetail = ref<any>({})
const applicationAvailable = ref<boolean>(true) const applicationAvailable = ref<boolean>(true)
const chatLogeData = ref<any[]>([]) const chatLogeData = ref<any[]>([])
const paginationConfig = reactive({ const paginationConfig = ref({
current_page: 1, current_page: 1,
page_size: 20, page_size: 20,
total: 0 total: 0
@ -145,10 +152,10 @@ function handleScroll(event: any) {
if ( if (
currentChatId.value !== 'new' && currentChatId.value !== 'new' &&
event.scrollTop === 0 && event.scrollTop === 0 &&
paginationConfig.total > currentRecordList.value.length paginationConfig.value.total > currentRecordList.value.length
) { ) {
const history_height = event.dialogScrollbar.offsetHeight const history_height = event.dialogScrollbar.offsetHeight
paginationConfig.current_page += 1 paginationConfig.value.current_page += 1
getChatRecord().then(() => { getChatRecord().then(() => {
event.scrollDiv.setScrollTop(event.dialogScrollbar.offsetHeight - history_height) event.scrollDiv.setScrollTop(event.dialogScrollbar.offsetHeight - history_height)
}) })
@ -180,11 +187,13 @@ function getProfile() {
function newChat() { function newChat() {
if (!chatLogeData.value.some((v) => v.id === 'new')) { if (!chatLogeData.value.some((v) => v.id === 'new')) {
paginationConfig.current_page = 1 paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = [] currentRecordList.value = []
chatLogeData.value.unshift(newObj) chatLogeData.value.unshift(newObj)
} else { } else {
paginationConfig.current_page = 1 paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = [] currentRecordList.value = []
} }
currentChatId.value = 'new' currentChatId.value = 'new'
@ -194,7 +203,7 @@ function newChat() {
} }
} }
function getChatLog(id: string) { function getChatLog(id: string, refresh?: boolean) {
const page = { const page = {
current_page: 1, current_page: 1,
page_size: 20 page_size: 20
@ -202,6 +211,9 @@ function getChatLog(id: string) {
log.asyncGetChatLogClient(id, page, left_loading).then((res: any) => { log.asyncGetChatLogClient(id, page, left_loading).then((res: any) => {
chatLogeData.value = res.data.records chatLogeData.value = res.data.records
if (refresh) {
currentChatName.value = chatLogeData.value[0].abstract
}
}) })
} }
@ -210,12 +222,12 @@ function getChatRecord() {
.asyncChatRecordLog( .asyncChatRecordLog(
applicationDetail.value.id, applicationDetail.value.id,
currentChatId.value, currentChatId.value,
paginationConfig, paginationConfig.value,
loading, loading,
false false
) )
.then((res: any) => { .then((res: any) => {
paginationConfig.total = res.data.total paginationConfig.value.total = res.data.total
const list = res.data.records const list = res.data.records
list.map((v: any) => { list.map((v: any) => {
v['write_ed'] = true v['write_ed'] = true
@ -224,7 +236,7 @@ function getChatRecord() {
currentRecordList.value = [...list, ...currentRecordList.value].sort((a, b) => currentRecordList.value = [...list, ...currentRecordList.value].sort((a, b) =>
a.create_time.localeCompare(b.create_time) a.create_time.localeCompare(b.create_time)
) )
if (paginationConfig.current_page === 1) { if (paginationConfig.value.current_page === 1) {
nextTick(() => { nextTick(() => {
// //
AiChatRef.value.setScrollBottom() AiChatRef.value.setScrollBottom()
@ -235,7 +247,8 @@ function getChatRecord() {
const clickListHandle = (item: any) => { const clickListHandle = (item: any) => {
if (item.id !== currentChatId.value) { if (item.id !== currentChatId.value) {
paginationConfig.current_page = 1 paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = [] currentRecordList.value = []
currentChatId.value = item.id currentChatId.value = item.id
currentChatName.value = item.abstract currentChatName.value = item.abstract
@ -249,15 +262,15 @@ const clickListHandle = (item: any) => {
} }
function refresh(id: string) { function refresh(id: string) {
getChatLog(applicationDetail.value.id) getChatLog(applicationDetail.value.id, true)
currentChatId.value = id currentChatId.value = id
} }
async function exportMarkdown(): Promise<void> { async function exportMarkdown(): Promise<void> {
const suggestedName: string = `${currentChatId.value}.md` const suggestedName: string = `${currentChatId.value}.md`
const markdownContent: string = currentRecordList.value.map((record: any) => const markdownContent: string = currentRecordList.value
`# ${record.problem_text}\n\n${record.answer_text}\n\n` .map((record: any) => `# ${record.problem_text}\n\n${record.answer_text}\n\n`)
).join('\n') .join('\n')
const blob: Blob = new Blob([markdownContent], { type: 'text/markdown;charset=utf-8' }) const blob: Blob = new Blob([markdownContent], { type: 'text/markdown;charset=utf-8' })
saveAs(blob, suggestedName) saveAs(blob, suggestedName)
@ -265,16 +278,15 @@ async function exportMarkdown(): Promise<void> {
async function exportHTML(): Promise<void> { async function exportHTML(): Promise<void> {
const suggestedName: string = `${currentChatId.value}.html` const suggestedName: string = `${currentChatId.value}.html`
const markdownContent: string = currentRecordList.value.map((record: any) => const markdownContent: string = currentRecordList.value
`# ${record.problem_text}\n\n${record.answer_text}\n\n` .map((record: any) => `# ${record.problem_text}\n\n${record.answer_text}\n\n`)
).join('\n') .join('\n')
const htmlContent: any = marked(markdownContent) const htmlContent: any = marked(markdownContent)
const blob: Blob = new Blob([htmlContent], { type: 'text/html;charset=utf-8' }) const blob: Blob = new Blob([htmlContent], { type: 'text/html;charset=utf-8' })
saveAs(blob, suggestedName) saveAs(blob, suggestedName)
} }
onMounted(() => { onMounted(() => {
user.changeUserType(2) user.changeUserType(2)
getAccessToken(accessToken) getAccessToken(accessToken)
@ -317,9 +329,11 @@ onMounted(() => {
padding-top: calc(var(--app-header-height)); padding-top: calc(var(--app-header-height));
overflow: hidden; overflow: hidden;
position: relative; position: relative;
box-sizing: border-box;
.right-header { .right-header {
background: #ffffff; background: #ffffff;
box-sizing: border-box;
} }
.right-height { .right-height {
@ -366,6 +380,9 @@ onMounted(() => {
.chat-pc { .chat-pc {
&__right { &__right {
width: 100%; width: 100%;
.right-height {
height: calc(100vh - var(--app-header-height) * 2 - 24px - env(safe-area-inset-bottom));
}
} }
&__left { &__left {
display: none; display: none;