refactor(frontend): 重构前端第三版
This commit is contained in:
1 parent
bf32f8b954
commit
dc141d19a2
49 files changed
+5333
-4234
No files matched your search
@@ -1,83 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/kb/DifyHealthDialog.vue
|
||||
* 知识库 Dify 健康检查弹窗(KB 暂缓 redesign)。
|
||||
*/
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getKbDifyHealth, type KbDifyHealth } from '@/api/kb';
|
||||
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
const payload = ref<KbDifyHealth | null>(null);
|
||||
|
||||
const close = () => emit('close');
|
||||
|
||||
const loadHealth = async () => {
|
||||
loading.value = true;
|
||||
payload.value = await getKbDifyHealth();
|
||||
loading.value = false;
|
||||
if (!payload.value) emit('error', t('kbDifyHealth.msg.loadFailed'));
|
||||
};
|
||||
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) void loadHealth();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="open" class="dialog-overlay" @click="close">
|
||||
<div class="dialog-panel max-w-4xl p-6" @click.stop>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="section-title text-xl">{{ t('kbDifyHealth.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('kbDifyHealth.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button type="button" class="btn-secondary btn-sm" @click="loadHealth">
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="close">
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-muted">{{ t('kbDifyHealth.loading') }}</div>
|
||||
<div v-else-if="payload" class="mt-6 grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">Dify API</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
|
||||
<div class="mt-2 break-all text-xs text-muted">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.datasetCount') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.dataset_count ?? '--' }}</div>
|
||||
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.boundGroups') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.dataset_bound_groups }}</div>
|
||||
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.syncingVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.syncing_versions }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.syncedVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.synced_versions }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.pending_sync_jobs }}</div>
|
||||
<div v-if="payload.api.error" class="mt-2 text-xs text-rose-500">{{ payload.api.error }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,119 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/kb/DifySettingsDialog.vue
|
||||
* 知识库 Dify 配置弹窗(KB 暂缓 redesign)。
|
||||
*/
|
||||
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getKbDifySettings, updateKbDifySettings } from '@/api/kb';
|
||||
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; saved: [message: string]; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const form = reactive({
|
||||
DIFY_API_BASE: '',
|
||||
DIFY_API_KEY: '',
|
||||
KB_DIFY_PERMISSION: 'only_me',
|
||||
KB_DIFY_INDEXING_TECHNIQUE: 'high_quality',
|
||||
KB_DIFY_SEARCH_METHOD: 'semantic_search',
|
||||
KB_DIFY_DOC_FORM: 'text_model',
|
||||
});
|
||||
|
||||
const close = () => emit('close');
|
||||
|
||||
const loadSettings = async () => {
|
||||
loading.value = true;
|
||||
const settings = await getKbDifySettings();
|
||||
loading.value = false;
|
||||
if (!settings) {
|
||||
emit('error', t('kbDifySettings.msg.loadFailed'));
|
||||
return;
|
||||
}
|
||||
Object.assign(form, settings);
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
saving.value = true;
|
||||
const result = await updateKbDifySettings(form);
|
||||
saving.value = false;
|
||||
if (!result.ok) {
|
||||
emit('error', result.error || t('kbDifySettings.msg.saveFailed'));
|
||||
return;
|
||||
}
|
||||
emit('saved', t('kbDifySettings.msg.saved'));
|
||||
emit('close');
|
||||
};
|
||||
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) void loadSettings();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="open" class="dialog-overlay" @click="close">
|
||||
<div class="dialog-panel max-w-3xl p-6" @click.stop>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="section-title text-xl">{{ t('kbDifySettings.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('kbDifySettings.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="close">
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-muted">{{ t('kbDifySettings.loading') }}</div>
|
||||
<div v-else class="mt-6 grid gap-4 md:grid-cols-2 form-stack">
|
||||
<label class="space-y-2 md:col-span-2">
|
||||
<span class="label-field block">Dify Base URL</span>
|
||||
<input v-model="form.DIFY_API_BASE" class="input-field" placeholder="https://api.dify.ai/v1" />
|
||||
</label>
|
||||
<label class="space-y-2 md:col-span-2">
|
||||
<span class="label-field block">Dify API Key</span>
|
||||
<input v-model="form.DIFY_API_KEY" class="input-field" placeholder="app-..." />
|
||||
</label>
|
||||
<label class="space-y-2">
|
||||
<span class="label-field block">Permission</span>
|
||||
<select v-model="form.KB_DIFY_PERMISSION" class="input-field">
|
||||
<option value="only_me">only_me</option>
|
||||
<option value="all_team_members">all_team_members</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-2">
|
||||
<span class="label-field block">Indexing Technique</span>
|
||||
<select v-model="form.KB_DIFY_INDEXING_TECHNIQUE" class="input-field">
|
||||
<option value="high_quality">high_quality</option>
|
||||
<option value="economy">economy</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-2">
|
||||
<span class="label-field block">Search Method</span>
|
||||
<select v-model="form.KB_DIFY_SEARCH_METHOD" class="input-field">
|
||||
<option value="semantic_search">semantic_search</option>
|
||||
<option value="hybrid_search">hybrid_search</option>
|
||||
<option value="full_text_search">full_text_search</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-2">
|
||||
<span class="label-field block">Doc Form</span>
|
||||
<select v-model="form.KB_DIFY_DOC_FORM" class="input-field">
|
||||
<option value="text_model">text_model</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button type="button" class="btn-secondary" @click="close">
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="save">
|
||||
{{ saving ? t('kbDifySettings.saving') : t('kbDifySettings.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,379 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/kb/KbAdminPanel.vue
|
||||
* 知识库管理面板(KB 暂缓 redesign)。
|
||||
*/
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Activity, FolderPlus, Pencil, Play, Settings, Trash2, Wrench, X } from 'lucide-vue-next';
|
||||
import DifyHealthDialog from './DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from './DifySettingsDialog.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import {
|
||||
createKbGroup,
|
||||
deleteKbGroup,
|
||||
getKbGroupsSafe,
|
||||
getKbJobsSafe,
|
||||
runKbJob,
|
||||
updateKbGroup,
|
||||
type KbGroup,
|
||||
type KbJob,
|
||||
} from '@/api/kb';
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
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 deleteDialogOpen = ref(false);
|
||||
const deletingGroup = ref<KbGroup | null>(null);
|
||||
|
||||
const formTitle = computed(() => editingGroupId.value ? t('kbAdmin.form.editTitle') : t('kbAdmin.form.createTitle'));
|
||||
const formDescription = computed(() => editingGroupId.value
|
||||
? t('kbAdmin.form.editDesc')
|
||||
: t('kbAdmin.form.createDesc'));
|
||||
const submitText = computed(() => {
|
||||
if (isSubmitting.value) return editingGroupId.value ? t('kbAdmin.form.saving') : t('kbAdmin.form.submitting');
|
||||
return editingGroupId.value ? t('kbAdmin.form.saveChanges') : t('kbAdmin.form.create');
|
||||
});
|
||||
|
||||
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 || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
if (jobsResult.ok) {
|
||||
jobs.value = jobsResult.data;
|
||||
} else {
|
||||
feedback.value = jobsResult.error || t('kbAdmin.msg.loadJobsFailed');
|
||||
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 = t('kbAdmin.msg.nameRequired');
|
||||
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 || t('kbAdmin.msg.createFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = editingGroupId.value ? t('kbAdmin.msg.updated') : t('kbAdmin.msg.created');
|
||||
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) => {
|
||||
deletingGroup.value = group;
|
||||
deleteDialogOpen.value = true;
|
||||
};
|
||||
|
||||
const handleDeleteGroupConfirm = async () => {
|
||||
if (!deletingGroup.value) return;
|
||||
const result = await deleteKbGroup(deletingGroup.value.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || t('kbAdmin.msg.deleteFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingGroupId.value === deletingGroup.value.id) {
|
||||
resetForm();
|
||||
}
|
||||
feedback.value = t('kbAdmin.msg.deleted');
|
||||
feedbackType.value = 'success';
|
||||
deleteDialogOpen.value = false;
|
||||
deletingGroup.value = null;
|
||||
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 || t('kbAdmin.msg.runFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.run_result || t('kbAdmin.msg.runDone');
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadData();
|
||||
});
|
||||
|
||||
defineExpose({ loadData });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="animate-fade-in-up">
|
||||
<div class="kb-admin-header">
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="text-xl font-bold text-primary">{{ t('kbAdmin.title') }}</h2>
|
||||
<p class="section-desc mt-1">
|
||||
{{ t('kbAdmin.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:justify-end">
|
||||
<div
|
||||
class="kb-admin-toolbar"
|
||||
role="toolbar"
|
||||
:aria-label="t('kbAdmin.toolbar')"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="kb-admin-toolbar-btn"
|
||||
@click="settingsDialogOpen = true"
|
||||
:title="t('kbAdmin.difySettings')"
|
||||
>
|
||||
<Settings class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.difySettings') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="kb-admin-toolbar-btn"
|
||||
@click="healthDialogOpen = true"
|
||||
:title="t('kbAdmin.healthCheck')"
|
||||
>
|
||||
<Activity class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.healthCheck') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex w-full items-center justify-center gap-2 px-5 py-2.5 text-sm sm:w-auto"
|
||||
@click="router.push('/kb/workspace')"
|
||||
>
|
||||
<Wrench class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.goWorkspace') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kb-admin-body">
|
||||
<section class="kb-admin-section">
|
||||
<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">
|
||||
<FolderPlus class="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="section-title">{{ formTitle }}</h3>
|
||||
<p class="section-desc">{{ formDescription }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupName') }}</label>
|
||||
<input v-model="form.name" class="input-field" :placeholder="t('kbAdmin.form.groupNamePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupDesc') }}</label>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="4"
|
||||
class="input-field"
|
||||
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-end gap-2 border-t border-subtle pt-4">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex items-center gap-1.5 px-5 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-60"
|
||||
@click="handleCreateGroup"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<FolderPlus v-if="!isSubmitting" class="h-4 w-4 shrink-0" />
|
||||
{{ submitText }}
|
||||
</button>
|
||||
<button
|
||||
v-if="editingGroupId"
|
||||
type="button"
|
||||
class="btn-secondary inline-flex items-center gap-1.5 px-4 py-2 text-sm"
|
||||
@click="resetForm"
|
||||
>
|
||||
<X class="h-4 w-4 shrink-0" />
|
||||
{{ t('kbAdmin.form.cancelEdit') }}
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-if="feedback"
|
||||
class="text-sm"
|
||||
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600'"
|
||||
>
|
||||
{{ feedback }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="space-y-6">
|
||||
<section class="kb-admin-section">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="section-title">{{ t('kbAdmin.groupsTitle') }}</h3>
|
||||
<span class="text-xs text-muted">{{ isRefreshing ? t('common.loading') : '/api/kb/groups' }}</span>
|
||||
</div>
|
||||
<div v-if="groups.length === 0" class="kb-admin-empty">
|
||||
{{ t('kbAdmin.groupsEmpty') }}
|
||||
</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="kb-admin-card"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">{{ group.name }}</div>
|
||||
<div class="mt-1 text-sm text-muted">{{ group.description || t('kbAdmin.noDescription') }}</div>
|
||||
</div>
|
||||
<div class="kb-admin-badge">
|
||||
{{ t('kbAdmin.documentCount', { count: group.document_count ?? 0 }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="text-xs text-muted">
|
||||
{{ t('kbAdmin.updatedAt') }}{{ group.updated_at || '--' }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary inline-flex items-center gap-1 px-3 py-2 text-xs"
|
||||
@click="handleEditGroup(group)"
|
||||
>
|
||||
<Pencil class="h-3.5 w-3.5" />
|
||||
{{ t('common.edit') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
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"
|
||||
@click="handleDeleteGroup(group)"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="kb-admin-section">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="section-title">{{ t('kbAdmin.jobsTitle') }}</h3>
|
||||
<span class="text-xs text-muted">/api/kb/jobs</span>
|
||||
</div>
|
||||
<div v-if="jobs.length === 0" class="kb-admin-empty">
|
||||
{{ t('kbAdmin.jobsEmpty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="job in jobs"
|
||||
:key="job.id"
|
||||
class="kb-admin-card"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">{{ job.job_type }}</div>
|
||||
<div class="mt-1 text-sm text-muted">{{ job.created_at || '--' }}</div>
|
||||
<div class="mt-2 text-sm text-muted">
|
||||
{{ job.message || t('kbAdmin.noJobMessage') }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-muted">
|
||||
{{ t('kbAdmin.jobMeta', { docId: job.document_id ?? '--', versionId: job.document_version_id ?? '--', progress: job.progress ?? 0 }) }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="kb-admin-badge">
|
||||
{{ job.status }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="['clean', 'sync_dify'].includes(job.job_type) && job.status !== 'success'" class="mt-3 flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
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"
|
||||
@click="handleRunJob(job)"
|
||||
:disabled="runningJobId === job.id"
|
||||
>
|
||||
<Play class="h-3.5 w-3.5" />
|
||||
{{ runningJobId === job.id ? t('kbAdmin.running') : t('kbAdmin.runJob') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</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'; }"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="deleteDialogOpen"
|
||||
:title="t('kbAdmin.deleteDialog.title')"
|
||||
:message="t('kbAdmin.deleteDialog.message', { name: deletingGroup?.name || '' })"
|
||||
@confirm="handleDeleteGroupConfirm"
|
||||
@cancel="() => { deleteDialogOpen = false; deletingGroup = null; }"
|
||||
/>
|
||||
</template>
|
||||
Reference in new issue
Block a user