feat: 同步知识库
This commit is contained in:
parent
47d2ed655c
commit
f1ae5279c4
37
ui/src/components/auto-tooltip/index.vue
Normal file
37
ui/src/components/auto-tooltip/index.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<el-tooltip
|
||||||
|
v-bind="$attrs"
|
||||||
|
:disabled="!(containerWeight > contentWeight)"
|
||||||
|
effect="dark"
|
||||||
|
placement="bottom"
|
||||||
|
>
|
||||||
|
<div ref="tagLabel" class="auto-tooltip">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||||
|
defineOptions({ name: 'AutoTooltip' })
|
||||||
|
const tagLabel = ref()
|
||||||
|
const containerWeight = ref(0)
|
||||||
|
const contentWeight = ref(0)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
nextTick(() => {
|
||||||
|
containerWeight.value = tagLabel.value?.scrollWidth
|
||||||
|
contentWeight.value = tagLabel.value?.clientWidth
|
||||||
|
})
|
||||||
|
window.addEventListener('resize', function () {
|
||||||
|
containerWeight.value = tagLabel.value?.scrollWidth
|
||||||
|
contentWeight.value = tagLabel.value?.clientWidth
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.auto-tooltip {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -17,6 +17,7 @@ import dynamicsForm from './dynamics-form'
|
|||||||
import CardCheckbox from './card-checkbox/index.vue'
|
import CardCheckbox from './card-checkbox/index.vue'
|
||||||
import AiChat from './ai-chat/index.vue'
|
import AiChat from './ai-chat/index.vue'
|
||||||
import InfiniteScroll from './infinite-scroll/index.vue'
|
import InfiniteScroll from './infinite-scroll/index.vue'
|
||||||
|
import AutoTooltip from './auto-tooltip/index.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App) {
|
install(app: App) {
|
||||||
@ -38,5 +39,6 @@ export default {
|
|||||||
app.component(CardCheckbox.name, CardCheckbox)
|
app.component(CardCheckbox.name, CardCheckbox)
|
||||||
app.component(AiChat.name, AiChat)
|
app.component(AiChat.name, AiChat)
|
||||||
app.component(InfiniteScroll.name, InfiniteScroll)
|
app.component(InfiniteScroll.name, InfiniteScroll)
|
||||||
|
app.component(AutoTooltip.name, AutoTooltip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,10 @@
|
|||||||
<div class="cursor">
|
<div class="cursor">
|
||||||
<slot name="read">
|
<slot name="read">
|
||||||
<div class="flex align-center" v-if="!isEdit">
|
<div class="flex align-center" v-if="!isEdit">
|
||||||
<span>{{ data }}</span>
|
<auto-tooltip :content="data">
|
||||||
|
{{ data }}
|
||||||
|
</auto-tooltip>
|
||||||
|
|
||||||
<el-button @click.stop="editNameHandle" text v-if="showEditIcon">
|
<el-button @click.stop="editNameHandle" text v-if="showEditIcon">
|
||||||
<el-icon><Edit /></el-icon>
|
<el-icon><Edit /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|||||||
@ -1,15 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-tag class="tag-ellipsis flex-between mb-8" effect="plain" v-bind="$attrs">
|
<el-tag class="tag-ellipsis flex-between mb-8" effect="plain" v-bind="$attrs">
|
||||||
<el-tooltip
|
<AutoTooltip :content="tooltipContent">
|
||||||
:disabled="!isShowTooltip"
|
<slot></slot>
|
||||||
effect="dark"
|
</AutoTooltip>
|
||||||
:content="tooltipContent"
|
|
||||||
placement="bottom"
|
|
||||||
>
|
|
||||||
<div ref="tagLabel">
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -17,18 +10,6 @@ import { ref, computed, useSlots } from 'vue'
|
|||||||
defineOptions({ name: 'TagEllipsis' })
|
defineOptions({ name: 'TagEllipsis' })
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
const tooltipContent = slots.default?.()?.[0].children || ''
|
const tooltipContent = slots.default?.()?.[0].children || ''
|
||||||
const tagLabel = ref()
|
|
||||||
const isShowTooltip = computed(() => {
|
|
||||||
const containerWeight = tagLabel.value?.scrollWidth
|
|
||||||
const contentWeight = tagLabel.value?.clientWidth
|
|
||||||
if (containerWeight > contentWeight) {
|
|
||||||
/* 实际宽度 > 可视宽度 */
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
/* 否则为不溢出 */
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
/* tag超出省略号 */
|
/* tag超出省略号 */
|
||||||
@ -46,10 +27,10 @@ const isShowTooltip = computed(() => {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
:deep(.el-tooltip__trigger) {
|
// :deep(.el-tooltip__trigger) {
|
||||||
overflow: hidden;
|
// overflow: hidden;
|
||||||
white-space: nowrap;
|
// white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
// text-overflow: ellipsis;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -13,11 +13,12 @@
|
|||||||
<el-button v-if="datasetDetail.type === '1'" type="primary" @click="importDoc"
|
<el-button v-if="datasetDetail.type === '1'" type="primary" @click="importDoc"
|
||||||
>导入文档</el-button
|
>导入文档</el-button
|
||||||
>
|
>
|
||||||
|
<el-button @click="syncDataset" v-if="datasetDetail.type === '1'">同步知识库</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@click="syncMulDocument"
|
@click="syncMulDocument"
|
||||||
:disabled="multipleSelection.length === 0"
|
:disabled="multipleSelection.length === 0"
|
||||||
v-if="datasetDetail.type === '1'"
|
v-if="datasetDetail.type === '1'"
|
||||||
>批量同步</el-button
|
>同步文档</el-button
|
||||||
>
|
>
|
||||||
<el-button @click="deleteMulDocument" :disabled="multipleSelection.length === 0"
|
<el-button @click="deleteMulDocument" :disabled="multipleSelection.length === 0"
|
||||||
>批量删除</el-button
|
>批量删除</el-button
|
||||||
@ -149,6 +150,7 @@
|
|||||||
</app-table>
|
</app-table>
|
||||||
</div>
|
</div>
|
||||||
<ImportDocumentDialog ref="ImportDocumentDialogRef" :title="title" @refresh="refresh" />
|
<ImportDocumentDialog ref="ImportDocumentDialogRef" :title="title" @refresh="refresh" />
|
||||||
|
<SyncWebDialog ref="SyncWebDialogRef" @refresh="refresh" />
|
||||||
</div>
|
</div>
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
@ -158,6 +160,7 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
import { ElTable } from 'element-plus'
|
import { ElTable } from 'element-plus'
|
||||||
import documentApi from '@/api/document'
|
import documentApi from '@/api/document'
|
||||||
import ImportDocumentDialog from './component/ImportDocumentDialog.vue'
|
import ImportDocumentDialog from './component/ImportDocumentDialog.vue'
|
||||||
|
import SyncWebDialog from '@/views/dataset/component/SyncWebDialog.vue'
|
||||||
import { numberFormat } from '@/utils/utils'
|
import { numberFormat } from '@/utils/utils'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
import { datetimeFormat } from '@/utils/time'
|
||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
@ -169,6 +172,8 @@ const {
|
|||||||
} = route as any
|
} = route as any
|
||||||
|
|
||||||
const { dataset } = useStore()
|
const { dataset } = useStore()
|
||||||
|
|
||||||
|
const SyncWebDialogRef = ref()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
let interval: any
|
let interval: any
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
@ -187,6 +192,10 @@ const multipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|||||||
const multipleSelection = ref<any[]>([])
|
const multipleSelection = ref<any[]>([])
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
|
|
||||||
|
function syncDataset() {
|
||||||
|
SyncWebDialogRef.value.open(id)
|
||||||
|
}
|
||||||
|
|
||||||
function importDoc() {
|
function importDoc() {
|
||||||
title.value = '导入文档'
|
title.value = '导入文档'
|
||||||
ImportDocumentDialogRef.value.open()
|
ImportDocumentDialogRef.value.open()
|
||||||
@ -271,7 +280,7 @@ function syncMulDocument() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
documentApi.delMulSyncDocument(id, arr, loading).then(() => {
|
documentApi.delMulSyncDocument(id, arr, loading).then(() => {
|
||||||
MsgSuccess('批量同步成功')
|
MsgSuccess('同步文档成功')
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ const props = withDefaults(
|
|||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
const emit = defineEmits(['update:chartId', 'update:currentAbstract'])
|
const emit = defineEmits(['update:chartId', 'update:currentAbstract', 'refresh'])
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const {
|
const {
|
||||||
@ -106,6 +106,7 @@ watch(visible, (bool) => {
|
|||||||
if (!bool) {
|
if (!bool) {
|
||||||
emit('update:chartId', '')
|
emit('update:chartId', '')
|
||||||
emit('update:currentAbstract', '')
|
emit('update:currentAbstract', '')
|
||||||
|
emit('refresh')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,7 @@
|
|||||||
:application="detail"
|
:application="detail"
|
||||||
:pre_disable="pre_disable"
|
:pre_disable="pre_disable"
|
||||||
:next_disable="next_disable"
|
:next_disable="next_disable"
|
||||||
|
@refresh="refresh"
|
||||||
/>
|
/>
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
@ -248,6 +249,10 @@ function getDetail() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList()
|
getList()
|
||||||
getDetail()
|
getDetail()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user