Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ui/src/api/admin/workspace/knowledge/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ const putQuickCreateDocuments = (knowledgeId: string, documents: DocumentQuickCr
const putDocumentActive = (knowledgeId: string, documentId: string, isActive: boolean) =>
put(`${getPrefix(knowledgeId)}/${documentId}`, { is_active: isActive })



/** 删除单个文档。 */
const deleteDocument = (knowledgeId: string, documentId: string) => del(`${getPrefix(knowledgeId)}/${documentId}`)

/** 批量删除文档。 */
const putBatchDeleteDocuments = (knowledgeId: string, documentIds: string[]) =>
put(`${getPrefix(knowledgeId)}/batch_delete`, { id_list: documentIds })


/** 批量提交文档向量化。 */
const putBatchRefreshDocuments = (knowledgeId: string, documentIds: string[], stateList: DocumentTaskState[]) =>
put(`${getPrefix(knowledgeId)}/batch_refresh`, { id_list: documentIds, state_list: stateList })
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/global/mk-source-card/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function handleSelectedChange(selected: boolean | string | number) {
<el-checkbox :model-value="props.selected" @change="handleSelectedChange" />
</div>

<header class="flex-between items-start gap-2" :class="{ 'pr-7': props.selectable }">
<header class="flex-between items-start gap-2">
<div class="flex-align-center min-w-0 flex-1 gap-3">
<div v-if="slots.icon" class="flex shrink-0">
<slot name="icon" />
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/global/mk-table/MkAction.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
defineOptions({ name: 'MkAction', inheritAttrs: false })
withDefaults(defineProps<{ display?: 'menu' | 'button'; label: string; icon: string; disabled?: boolean; divided?: boolean }>(), { display: 'menu' })
withDefaults(defineProps<{ display?: 'menu' | 'button'; label: string; icon?: string; disabled?: boolean; divided?: boolean }>(), { display: 'menu' })
const emit = defineEmits<{ click: [event: MouseEvent] }>()
</script>

<template>
<!-- 菜单操作 -->
<MkDropdownItem v-if="display === 'menu'" v-bind="$attrs" :disabled="disabled" :divided="divided" @click.stop="emit('click', $event)">
<template #icon><MkIcon :name="icon" /></template>
<template #icon v-if="icon"><MkIcon :name="icon" /></template>
{{ label }}
</MkDropdownItem>
<MkTooltip v-else :content="label" placement="top">
Expand Down
4 changes: 3 additions & 1 deletion ui/src/views/VIEW_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,9 @@ Workspace API 内部通过 `getWorkspaceId()` 读取当前路由工作空间。
接口成功后刷新列表回显,不在请求前切换状态,不单独封装 Action。
页面保留列表、多选、任务状态展示判断与刷新方法,不维护各 Action 的请求流程。
`DocumentStatus`、`DocumentTags` 等纯展示组件继续留在 `document/components/`。
页面不再维护这些弹窗 Ref 和打开方法;承载入口的 `MkTableMoreDropdown` 使用 `persistent`,避免菜单收起时卸载弹窗。
页面不再维护这些弹窗 Ref 和打开方法。行内更多菜单使用 `MkTableMoreDropdown`;批量操作栏使用
`MkDropdown` 搭配非 text 的“更多操作 + 下箭头”按钮和 `MkDropdownMenu`,点击展开。
两种菜单均保留 `persistent`,避免菜单收起时卸载 Action 内的弹窗。
不新增前端权限判断;共享文档不展示选择列及操作入口。
文档分页接口维护在 `workspace/knowledge/document.ts`,页面管理 loading。文件状态表头使用
`MkDropdown` 单选筛选全部、成功、失败、索引中、分词索引中、排队中和生成中;查询组合
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ function handleDelete() {

<template>
<!-- 删除单个或选中文档 -->
<MkAction label="删除" icon="icon_delete-trash_outlined" divided :disabled="loading || !documentIds.length" @click="handleDelete" />
<MkAction label="删除" :disabled="loading || !documentIds.length" @click="handleDelete" />
</template>
177 changes: 94 additions & 83 deletions ui/src/views/knowledge-detail/document/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ onMounted(() => {
</template>
<!-- 删除文档 -->
<DeleteDocumentAction
divided
icon="icon_delete-trash_outlined"
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
Expand Down Expand Up @@ -509,89 +511,98 @@ onMounted(() => {
@refresh="refreshAfterOperation"
/>
<!-- 更多批量操作 -->
<MkTableMoreDropdown persistent>
<!-- 批量文档设置 -->
<SettingDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:documents="selectedDocuments"
batch
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量迁移文档 -->
<MigrateDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:document-ids="selectedDocumentIds"
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量添加标签 -->
<DocumentTagsAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:document-ids="selectedDocumentIds"
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量同步文档 -->
<SyncDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:documents="selectedDocuments"
:knowledge-type="knowledge?.type"
batch
@refresh="refreshAfterOperation"
/>
<!-- 批量导出 Excel -->
<ExportDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
format="excel"
/>
<!-- 批量导出 ZIP -->
<ExportDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
format="zip"
/>
<!-- 批量取消向量化 -->
<CancelDocumentTaskAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
:task-type="DOCUMENT_TASK_TYPE.EMBEDDING"
label="取消向量化"
divided
@refresh="refreshAfterOperation"
/>
<!-- 批量取消生成问题 -->
<CancelDocumentTaskAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
:task-type="DOCUMENT_TASK_TYPE.GENERATE_PROBLEM"
label="取消生成问题"
@refresh="refreshAfterOperation"
/>
<!-- 批量删除文档 -->
<DeleteDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
batch
@refresh="refreshAfterOperation"
/>
</MkTableMoreDropdown>
<MkDropdown class="ml-3" trigger="click" placement="bottom-end" persistent :disabled="operationLoading">
<!-- 展开更多批量操作 -->
<el-button :disabled="operationLoading">
更多操作
<MkIcon name="icon_down_outlined" class="ml-1" />
</el-button>
<template #dropdown>
<MkDropdownMenu>
<!-- 批量文档设置 -->
<SettingDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:documents="selectedDocuments"
batch
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量迁移文档 -->
<MigrateDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:document-ids="selectedDocumentIds"
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量添加标签 -->
<DocumentTagsAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
:document-ids="selectedDocumentIds"
:disabled="operationLoading"
@refresh="refreshAfterOperation"
/>
<!-- 批量同步文档 -->
<SyncDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:documents="selectedDocuments"
:knowledge-type="knowledge?.type"
batch
@refresh="refreshAfterOperation"
/>
<!-- 批量导出 Excel -->
<ExportDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
format="excel"
/>
<!-- 批量导出 ZIP -->
<ExportDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
format="zip"
/>
<!-- 批量取消向量化 -->
<CancelDocumentTaskAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
:task-type="DOCUMENT_TASK_TYPE.EMBEDDING"
label="取消向量化"
divided
@refresh="refreshAfterOperation"
/>
<!-- 批量取消生成问题 -->
<CancelDocumentTaskAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
:task-type="DOCUMENT_TASK_TYPE.GENERATE_PROBLEM"
label="取消生成问题"
@refresh="refreshAfterOperation"
/>
<!-- 批量删除文档 -->
<DeleteDocumentAction
:api="DocumentApi"
:knowledge-id="knowledgeId"
v-model:loading="operationLoading"
:document-ids="selectedDocumentIds"
batch
@refresh="refreshAfterOperation"
/>
</MkDropdownMenu>
</template>
</MkDropdown>
</template>
</MkTable>
</template>
2 changes: 1 addition & 1 deletion ui/src/views/system/resource-management/tool/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ onMounted(() => {
<template #icon><MkIcon name="icon_setting" /></template>
工作流
</MkDropdownItem>
<!-- 配置启动参数 -->
<!-- 启动参数 -->
<InitParamAction
v-if="row.init_field_list?.length"
v-model:loading="operationLoading"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/system/shared-resources/tool/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function handleOpenWorkflow(tool: ToolItem, event: MouseEvent) {
<template #icon><MkIcon name="icon_setting" /></template>
工作流
</MkDropdownItem>
<!-- 配置启动参数 -->
<!-- 启动参数 -->
<InitParamAction
v-if="(tool.init_field_list?.length ?? 0) > 0"
v-model:loading="toolOperationLoading"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Dict, ToolItem } from '@/api/types'
import { MkDynamicsForm, type DynamicFormValue } from '@/components/mk-dynamics-form'
import { MsgSuccess } from '@/utils/message'

defineOptions({ name: 'InitParamDialog' })
defineOptions({ name: 'InitParamDrawer' })

const props = defineProps<{ api: typeof ToolApi | typeof SystemSharedToolApi | typeof SystemResourceToolApi }>()

Expand Down Expand Up @@ -67,7 +67,7 @@ defineExpose({ open })
</script>

<template>
<MkDialog v-model="visible" title="配置启动参数" @closed="handleClosed">
<MkDrawer v-model="visible" title="启动参数" @closed="handleClosed">
<MkDynamicsForm v-if="toolDetail" ref="dynamicsFormRef" v-model="initParams" :render-data="toolDetail.init_field_list ?? []" />

<template #footer>
Expand All @@ -76,5 +76,5 @@ defineExpose({ open })
{{ enableAfterSave ? '保存并启用' : '保存' }}
</el-button>
</template>
</MkDialog>
</MkDrawer>
</template>
8 changes: 4 additions & 4 deletions ui/src/views/tool/tool-card/ToolStatusSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type SystemSharedToolApi from '@/api/admin/system/shared-resources/tool/t
import { TOOL_TYPE } from '@/api/enums'
import type { ToolItem } from '@/api/types'
import { MsgConfirm, MsgError, MsgSuccess } from '@/utils/message'
import InitParamDialog from './InitParamDialog.vue'
import InitParamDrawer from './InitParamDrawer.vue'

defineOptions({ name: 'ToolStatusSwitch', inheritAttrs: false })

Expand All @@ -16,7 +16,7 @@ const loading = defineModel<boolean>('loading', { default: false })

const emit = defineEmits<{ update: [tool: ToolItem] }>()

const initParamDialogRef = useTemplateRef<InstanceType<typeof InitParamDialog>>('initParamDialogRef')
const initParamDrawerRef = useTemplateRef<InstanceType<typeof InitParamDrawer>>('initParamDrawerRef')

function handleToolStatusChange() {
if (loading.value) return false
Expand All @@ -36,7 +36,7 @@ function handleToolStatusChange() {
}

if (hasMissingInitParams(toolDetail)) {
initParamDialogRef.value?.open(toolDetail, true, true)
initParamDrawerRef.value?.open(toolDetail, true, true)
return false
}

Expand Down Expand Up @@ -75,5 +75,5 @@ function updateToolStatus(active: boolean) {
<template>
<el-switch :disabled="loading" :model-value="tool.is_active" size="small" :before-change="handleToolStatusChange" v-bind="$attrs" />

<InitParamDialog ref="initParamDialogRef" :api="api" @update="emit('update', $event)" />
<InitParamDrawer ref="initParamDrawerRef" :api="api" @update="emit('update', $event)" />
</template>
10 changes: 5 additions & 5 deletions ui/src/views/tool/tool-card/action-dropdown/InitParamAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type ToolApi from '@/api/admin/workspace/tool/tool'
import type SystemResourceToolApi from '@/api/admin/system/resource-management/tool/tool'
import type SystemSharedToolApi from '@/api/admin/system/shared-resources/tool/tool'
import type { ToolItem } from '@/api/types'
import InitParamDialog from '../InitParamDialog.vue'
import InitParamDrawer from '../InitParamDrawer.vue'

defineOptions({ name: 'InitParamAction' })

Expand All @@ -15,15 +15,15 @@ const loading = defineModel<boolean>('loading', { default: false })
const emit = defineEmits<{ update: [tool: ToolItem] }>()

const dialogMounted = ref(false)
const initParamDialogRef = useTemplateRef<InstanceType<typeof InitParamDialog>>('initParamDialogRef')
const initParamDrawerRef = useTemplateRef<InstanceType<typeof InitParamDrawer>>('initParamDrawerRef')

function handleOpenInitParam() {
loading.value = true
return props.api
.getToolDetail(props.tool.id)
.then((toolDetail) => {
dialogMounted.value = true
return nextTick(() => initParamDialogRef.value?.open(toolDetail))
return nextTick(() => initParamDrawerRef.value?.open(toolDetail))
})
.finally(() => {
loading.value = false
Expand All @@ -36,11 +36,11 @@ function handleDialogClosed() {
</script>

<template>
<!-- 配置启动参数 -->
<!-- 启动参数 -->
<MkDropdownItem @click="handleOpenInitParam">
<template #icon><MkIcon name="icon_preferences_outlined" /></template>
<span>{{ label }}</span>
</MkDropdownItem>

<InitParamDialog v-if="dialogMounted" ref="initParamDialogRef" :api="api" @closed="handleDialogClosed" @update="emit('update', $event)" />
<InitParamDrawer v-if="dialogMounted" ref="initParamDrawerRef" :api="api" @closed="handleDialogClosed" @update="emit('update', $event)" />
</template>
Loading