Merge branch 'main' of github.com:maxkb-dev/maxkb

This commit is contained in:
shaohuzhang1 2023-12-14 12:13:26 +08:00
commit 72880448dd
5 changed files with 71 additions and 20 deletions

View File

@ -121,6 +121,28 @@ const getDocumentDetail: (dataset_id: string, document_id: string) => Promise<Re
return get(`${prefix}/${dataset_id}/document/${document_id}`)
}
/**
*
* @param
* dataset_id, document_id,
* {
"name": "string",
"is_active": true
}
*/
const putDocumentRefresh: (
dataset_id: string,
document_id: string,
loading?: Ref<boolean>
) => Promise<Result<any>> = (dataset_id, document_id, loading) => {
return put(
`${prefix}/${dataset_id}/document/${document_id}/refresh`,
undefined,
undefined,
loading
)
}
export default {
postSplitDocument,
getDocument,
@ -129,5 +151,6 @@ export default {
putDocument,
delDocument,
getDocumentDetail,
listSplitPattern
listSplitPattern,
putDocumentRefresh
}

View File

@ -6,20 +6,27 @@
</el-text>
</div>
<div>
<el-tooltip effect="dark" content="复制" placement="top">
<el-button text @click="copyClick(data?.answer_text)">
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
<el-tooltip effect="dark" content="修改内容" placement="top">
<el-button text @click="editContent(data)">
<el-icon><EditPen /></el-icon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
<el-tooltip effect="dark" content="复制" placement="top">
<el-button text @click="copyClick(data?.answer_text)">
<AppIcon iconName="app-copy"></AppIcon>
<el-tooltip effect="dark" content="修改历史" placement="top">
<el-button text @click="editContent(data)">
<el-icon><Document /></el-icon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" v-if="buttonData?.vote_status !== '-1'" />
<el-button text disabled v-if="buttonData?.vote_status === '0'">
<AppIcon iconName="app-like-color"></AppIcon>
<AppIcon iconName="app-like-color" class="primary"></AppIcon>
</el-button>
<el-button text disabled v-if="buttonData?.vote_status === '1'">

View File

@ -427,11 +427,11 @@ export const iconMap: any = {
[
h('path', {
d: 'M2.00497 14.6608H2.00518C2.00511 14.6609 2.00504 14.6609 2.00497 14.6608H0.666612C0.666097 14.6874 0.666707 5.33317 0.666612 5.29087H2.00518C2.00006 5.33305 1.98026 14.6344 2.00497 14.6608Z',
fill: '#FFC60A'
fill: 'currentColor'
}),
h('path', {
d: 'M12.5717 5.28984H9.70096C10.1486 4.45673 10.3724 3.78809 10.3724 3.28394C10.3724 1.94718 9.40089 1.14037 8.5893 0.770777C8.04824 0.52438 7.5406 0.753754 7.35254 1.05296L4.5741 5.00545C4.44877 5.18374 4.24449 5.28984 4.02656 5.28984H3.33882C3.154 5.28984 3.00418 5.43966 3.00418 5.62448V14.3319C3.00418 14.5167 3.154 14.6665 3.33882 14.6665H11.1995C11.8409 14.6665 12.4029 14.2423 12.5717 13.6308L14.5687 8.37353C15.0274 7.05264 14.5687 5.28984 12.5717 5.28984Z',
fill: '#FFC60A'
fill: 'currentColor'
})
]
)

View File

@ -1,11 +1,15 @@
<template>
<div class="flex align-center ml-8 mt-8 mb-16">
<back-button :to="activeMenu"></back-button>
<el-dropdown placement="bottom-start" trigger="click" @command="changeMenu">
<span class="el-dropdown-link flex">
<span class="ellipsis-1"> {{ currentName }}</span>
<el-icon class="el-icon--right"><arrow-down /></el-icon>
</span>
<div class="flex-between align-center ml-8 mt-8 mb-16">
<div class="flex align-center">
<back-button :to="activeMenu"></back-button>
<span class="ellipsis-1"> {{ currentName }}</span>
</div>
<el-dropdown placement="top" trigger="click" @command="changeMenu">
<div class="el-dropdown-link">
<el-button text>
<el-icon><CaretBottom /></el-icon>
</el-button>
</div>
<template #dropdown>
<el-dropdown-menu>
<template v-for="(item, index) in list" :key="index">

View File

@ -80,14 +80,14 @@
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="{ row }">
<span v-if="row.status === 2">
<span v-if="row.status === '2'" class="mr-4">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-button type="primary" text>
<el-button type="primary" text @click.stop="refreshDocument(row)">
<el-icon><RefreshRight /></el-icon>
</el-button>
</el-tooltip>
</span>
<span class="ml-4">
<span>
<el-tooltip effect="dark" content="删除" placement="top">
<el-button type="primary" text @click.stop="deleteDocument(row)">
<el-icon><Delete /></el-icon>
@ -102,7 +102,7 @@
</LayoutContainer>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, computed } from 'vue'
import { ref, onMounted, reactive, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import documentApi from '@/api/document'
import { numberFormat } from '@/utils/utils'
@ -125,6 +125,23 @@ const paginationConfig = reactive({
total: 0
})
watch(documentData, (list) => {
let interval
if (list.every((item) => item.status === '0')) {
interval = setInterval(() => {
getList(true)
}, 6000)
} else {
clearInterval(interval)
}
})
function refreshDocument(row: any) {
documentApi.putDocumentRefresh(row.dataset_id, row.id).then((res) => {
getList()
})
}
function rowClickHandle(row: any) {
router.push({ path: `/dataset/${id}/${row.id}` })
}
@ -215,13 +232,13 @@ function handleSizeChange() {
getList()
}
function getList() {
function getList(bool?: boolean) {
documentApi
.getDocument(
id as string,
paginationConfig,
filterText.value && { name: filterText.value },
loading
bool ? undefined : loading
)
.then((res) => {
documentData.value = res.data.records