Merge branch 'runny&xinxin' into dev
This commit is contained in:
commit
8d73343bd8
77 files changed
+17955
-274
No files matched your search
@@ -2544,6 +2544,13 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<button
|
||||
@click="router.push('/kb/admin')"
|
||||
class="hidden md:inline-flex items-center gap-2 rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-50 hover:text-slate-900 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-slate-100"
|
||||
>
|
||||
<Settings2 class="w-4 h-4" />
|
||||
<span>知识库管理</span>
|
||||
</button>
|
||||
<ThemeToggleButton />
|
||||
<!-- Language Selector -->
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
@@ -628,26 +628,10 @@ const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\
|
||||
|
||||
const isStrongLeaveIntent = (content: string) => {
|
||||
const normalized = getLeaveIntentNormalized(content);
|
||||
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|我要走请假流程)/.test(normalized);
|
||||
};
|
||||
|
||||
const startLocalLeaveFlow = (content: string) => {
|
||||
const formId = newLocalMessageId('leave-form');
|
||||
const payload: LeaveFormPayload = {
|
||||
formId,
|
||||
form: createLeaveFormData(),
|
||||
submitting: false,
|
||||
confirmationGenerated: false,
|
||||
};
|
||||
messages.value.push({ role: 'user', content, type: 'text' });
|
||||
messages.value.push({
|
||||
role: 'assistant',
|
||||
type: 'leave-form',
|
||||
content: '已为你生成请假申请表,请直接在下方填写并提交。或登录OA系统直接申请',
|
||||
payload,
|
||||
local_id: formId,
|
||||
local_only: true,
|
||||
});
|
||||
// 弱意图(咨询流程/步骤)应走正常问答,不触发表单分流。
|
||||
const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定)/;
|
||||
if (weakConsultationIntent.test(normalized)) return false;
|
||||
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|帮我请假|代我请假|提交请假)/.test(normalized);
|
||||
};
|
||||
|
||||
const getLeaveFormPayload = (msg: any): LeaveFormPayload | null => (
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ArrowLeft, FolderPlus, Pencil, Play, RefreshCw, Settings, Trash2, Wrench, X } from 'lucide-vue-next';
|
||||
import DifyHealthDialog from '../components/kb/DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from '../components/kb/DifySettingsDialog.vue';
|
||||
import {
|
||||
createKbGroup,
|
||||
deleteKbGroup,
|
||||
getKbGroupsSafe,
|
||||
getKbJobsSafe,
|
||||
runKbJob,
|
||||
updateKbGroup,
|
||||
type KbGroup,
|
||||
type KbJob,
|
||||
} from '../api/kb';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const groups = ref<KbGroup[]>([]);
|
||||
const jobs = ref<KbJob[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const isRefreshing = ref(false);
|
||||
const editingGroupId = ref<number | null>(null);
|
||||
const form = ref({
|
||||
name: '',
|
||||
description: '',
|
||||
});
|
||||
const feedback = ref('');
|
||||
const feedbackType = ref<'success' | 'error' | ''>('');
|
||||
const runningJobId = ref<number | string | null>(null);
|
||||
const settingsDialogOpen = ref(false);
|
||||
const healthDialogOpen = ref(false);
|
||||
|
||||
const formTitle = computed(() => editingGroupId.value ? '编辑知识库分组' : '新建知识库分组');
|
||||
const formDescription = computed(() => editingGroupId.value
|
||||
? '修改知识库分组名称和描述,保存后会立即刷新列表。'
|
||||
: '用于验证主平台里的知识库管理入口和基础接口壳。');
|
||||
const submitText = computed(() => {
|
||||
if (isSubmitting.value) return editingGroupId.value ? '保存中...' : '提交中...';
|
||||
return editingGroupId.value ? '保存修改' : '创建分组';
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
isRefreshing.value = true;
|
||||
const [groupsResult, jobsResult] = await Promise.all([getKbGroupsSafe(), getKbJobsSafe()]);
|
||||
if (groupsResult.ok) {
|
||||
groups.value = groupsResult.data;
|
||||
} else {
|
||||
feedback.value = groupsResult.error || '加载知识库分组失败';
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
if (jobsResult.ok) {
|
||||
jobs.value = jobsResult.data;
|
||||
} else {
|
||||
feedback.value = jobsResult.error || '加载任务列表失败';
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
isRefreshing.value = false;
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
editingGroupId.value = null;
|
||||
form.value = { name: '', description: '' };
|
||||
};
|
||||
|
||||
const handleCreateGroup = async () => {
|
||||
if (!form.value.name.trim()) {
|
||||
feedback.value = '请输入知识库分组名称';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
isSubmitting.value = true;
|
||||
const payload = {
|
||||
name: form.value.name.trim(),
|
||||
description: form.value.description.trim(),
|
||||
};
|
||||
const result = editingGroupId.value
|
||||
? await updateKbGroup(editingGroupId.value, payload)
|
||||
: await createKbGroup(payload);
|
||||
isSubmitting.value = false;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '创建失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = editingGroupId.value ? '知识库分组已更新' : '知识库分组创建成功';
|
||||
feedbackType.value = 'success';
|
||||
resetForm();
|
||||
await loadData();
|
||||
};
|
||||
|
||||
const handleEditGroup = (group: KbGroup) => {
|
||||
editingGroupId.value = group.id;
|
||||
form.value = {
|
||||
name: group.name,
|
||||
description: group.description || '',
|
||||
};
|
||||
feedback.value = '';
|
||||
feedbackType.value = '';
|
||||
};
|
||||
|
||||
const handleDeleteGroup = async (group: KbGroup) => {
|
||||
const confirmed = window.confirm(`确认删除知识库分组「${group.name}」吗?`);
|
||||
if (!confirmed) return;
|
||||
|
||||
const result = await deleteKbGroup(group.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingGroupId.value === group.id) {
|
||||
resetForm();
|
||||
}
|
||||
feedback.value = '知识库分组已删除';
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
|
||||
const handleRunJob = async (job: KbJob) => {
|
||||
runningJobId.value = job.id;
|
||||
const result = await runKbJob(job.id);
|
||||
runningJobId.value = null;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '任务执行失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.run_result || '任务已执行';
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 dark:bg-slate-950 text-slate-800 dark:text-slate-200">
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 md:px-6 lg:px-8">
|
||||
<div class="mb-6 flex flex-col gap-4 rounded-3xl border border-slate-200 bg-white p-6 shadow-sm md:flex-row md:items-center md:justify-between dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-start gap-4">
|
||||
<button
|
||||
@click="router.push('/admin')"
|
||||
class="rounded-2xl border border-slate-200 p-3 text-slate-500 transition-colors hover:bg-slate-50 hover:text-slate-900 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white"
|
||||
title="返回管理后台"
|
||||
>
|
||||
<ArrowLeft class="h-5 w-5" />
|
||||
</button>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex h-12 w-12 items-center justify-center rounded-2xl bg-brand-50 text-brand-600 dark:bg-brand-500/10">
|
||||
<Settings class="h-6 w-6" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-slate-900 dark:text-slate-100">知识库管理台</h1>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">
|
||||
第一阶段先承接分组、任务和 Dify 管理入口,后续再接入清洗链路。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
@click="loadData"
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
刷新数据
|
||||
</button>
|
||||
<button
|
||||
@click="settingsDialogOpen = true"
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<Settings class="h-4 w-4" />
|
||||
Dify 设置
|
||||
</button>
|
||||
<button
|
||||
@click="healthDialogOpen = true"
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
健康检查
|
||||
</button>
|
||||
<button
|
||||
@click="router.push('/kb/workspace')"
|
||||
class="inline-flex items-center gap-2 rounded-2xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition-colors hover:bg-brand-700"
|
||||
>
|
||||
<Wrench class="h-4 w-4" />
|
||||
前往工作台
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-[420px_minmax(0,1fr)]">
|
||||
<section class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="mb-5 flex items-center gap-3">
|
||||
<div class="flex h-10 w-10 items-center justify-center rounded-2xl bg-brand-50 text-brand-600 dark:bg-brand-500/10">
|
||||
<FolderPlus class="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ formTitle }}</h2>
|
||||
<p class="text-sm text-slate-500 dark:text-slate-400">{{ formDescription }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">分组名称</label>
|
||||
<input v-model="form.name" class="input-field" placeholder="例如:财务制度库" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">分组描述</label>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="4"
|
||||
class="input-field"
|
||||
placeholder="描述该知识库分组的业务范围或清洗目标"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
@click="handleCreateGroup"
|
||||
:disabled="isSubmitting"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-2xl bg-brand-600 px-4 py-3 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<FolderPlus class="h-4 w-4" />
|
||||
{{ submitText }}
|
||||
</button>
|
||||
<button
|
||||
v-if="editingGroupId"
|
||||
@click="resetForm"
|
||||
type="button"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-2xl border border-slate-200 px-4 py-3 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
取消编辑
|
||||
</button>
|
||||
<p
|
||||
v-if="feedback"
|
||||
class="text-sm"
|
||||
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600 dark:text-emerald-400'"
|
||||
>
|
||||
{{ feedback }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="space-y-6">
|
||||
<section class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-slate-900 dark:text-slate-100">知识库分组概览</h2>
|
||||
<span class="text-xs text-slate-400">{{ isRefreshing ? '加载中...' : '`/api/kb/groups`' }}</span>
|
||||
</div>
|
||||
<div v-if="groups.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
|
||||
当前暂无分组,或知识库接口尚未联调完成。
|
||||
</div>
|
||||
<div v-else class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<div
|
||||
v-for="group in groups"
|
||||
:key="group.id"
|
||||
class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ group.name }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ group.description || '暂无描述' }}</div>
|
||||
</div>
|
||||
<div class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
|
||||
{{ group.document_count ?? 0 }} 文档
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="text-xs text-slate-400">
|
||||
更新时间:{{ group.updated_at || '--' }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="handleEditGroup(group)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-slate-200 px-3 py-2 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<Pencil class="h-3.5 w-3.5" />
|
||||
编辑
|
||||
</button>
|
||||
<button
|
||||
@click="handleDeleteGroup(group)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 dark:border-rose-500/30 dark:text-rose-400 dark:hover:bg-rose-500/10"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-slate-900 dark:text-slate-100">任务队列占位</h2>
|
||||
<span class="text-xs text-slate-400">`/api/kb/jobs`</span>
|
||||
</div>
|
||||
<div v-if="jobs.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
|
||||
暂无任务。第二阶段会在这里接入清洗、同步和重试任务。
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="job in jobs"
|
||||
:key="job.id"
|
||||
class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ job.job_type }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ job.created_at || '--' }}</div>
|
||||
<div class="mt-2 text-sm text-slate-500 dark:text-slate-400">
|
||||
{{ job.message || '暂无任务说明' }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-slate-400">
|
||||
文档:{{ job.document_id ?? '--' }} · 版本:{{ job.document_version_id ?? '--' }} · 进度:{{ job.progress ?? 0 }}%
|
||||
</div>
|
||||
</div>
|
||||
<span class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
|
||||
{{ job.status }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3 flex justify-end" v-if="['clean', 'sync_dify'].includes(job.job_type) && job.status !== 'success'">
|
||||
<button
|
||||
@click="handleRunJob(job)"
|
||||
:disabled="runningJobId === job.id"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-brand-500/30 dark:text-brand-300 dark:hover:bg-brand-500/10"
|
||||
>
|
||||
<Play class="h-3.5 w-3.5" />
|
||||
{{ runningJobId === job.id ? '执行中...' : '执行任务' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DifySettingsDialog
|
||||
:open="settingsDialogOpen"
|
||||
@close="settingsDialogOpen = false"
|
||||
@saved="(message) => { feedback = message; feedbackType = 'success'; void loadData(); }"
|
||||
@error="(message) => { feedback = message; feedbackType = 'error'; }"
|
||||
/>
|
||||
<DifyHealthDialog
|
||||
:open="healthDialogOpen"
|
||||
@close="healthDialogOpen = false"
|
||||
@error="(message) => { feedback = message; feedbackType = 'error'; }"
|
||||
/>
|
||||
</template>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -33,6 +33,7 @@ import {
|
||||
Edit,
|
||||
ExternalLink,
|
||||
Bot,
|
||||
FileText,
|
||||
Lock,
|
||||
User,
|
||||
Mail,
|
||||
@@ -48,6 +49,8 @@ import {
|
||||
ChevronUp
|
||||
} from 'lucide-vue-next';
|
||||
|
||||
import KbWorkspaceView from './KbWorkspaceView.vue';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { showMessageDialog } = useGlobalMessageDialog();
|
||||
const router = useRouter();
|
||||
@@ -755,7 +758,7 @@ const handleRegister = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const activeSidebarItem = ref<'profile' | 'applications' | 'feedback' | 'updates'>('applications');
|
||||
const activeSidebarItem = ref<'profile' | 'applications' | 'feedback' | 'updates' | 'knowledge_base'>('applications');
|
||||
const isProfileLoading = ref(false);
|
||||
const isProfileSaving = ref(false);
|
||||
const isProfileEditing = ref(false);
|
||||
@@ -971,6 +974,10 @@ const navigateToApplications = () => openWorkspaceSection('favorites', 'applicat
|
||||
|
||||
const navigateToUpdates = () => openWorkspaceSection('announcements', 'updates');
|
||||
|
||||
const navigateToKnowledgeBase = () => {
|
||||
activeSidebarItem.value = 'knowledge_base';
|
||||
};
|
||||
|
||||
const navigateToGeneralChat = () => {
|
||||
router.push(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`);
|
||||
};
|
||||
@@ -1378,6 +1385,14 @@ onMounted(async () => {
|
||||
<LayoutGrid class="h-4 w-4" />
|
||||
<span>应用管理</span>
|
||||
</button>
|
||||
<button
|
||||
@click="navigateToKnowledgeBase"
|
||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium transition-all"
|
||||
:class="activeSidebarItem === 'knowledge_base' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
<span>知识库管理</span>
|
||||
</button>
|
||||
<button
|
||||
@click="openGeneralFeedback"
|
||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium transition-all"
|
||||
@@ -1593,6 +1608,10 @@ onMounted(async () => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeSidebarItem === 'knowledge_base'">
|
||||
<KbWorkspaceView :embedded="true" />
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="wecomEntryHint" class="rounded-2xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700">
|
||||
{{ wecomEntryHint }}
|
||||
|
||||
Reference in new issue
Block a user