refactor: 统一页面样式

This commit is contained in:
sophie committed 2026-05-27 16:06:48 +08:00
1 parent 42908b42f1
commit 0c6f1c0ffc
25 files changed
+3509 -2044

No files matched your search

@@ -3,9 +3,7 @@ import { computed, onBeforeUnmount, watch } from 'vue';
import { useI18n } from 'vue-i18n';
interface Props {
// 由父组件控制显隐,使用 v-model 统一管理弹框状态。
modelValue: boolean;
// title/message 支持外部按场景透传,不传时走 i18n 默认值。
title?: string;
message?: string;
confirmText?: string;
@@ -39,7 +37,6 @@ const closeDialog = () => {
};
const handleCancel = () => {
// 先抛出 cancel 事件,方便父组件做状态回滚,再关闭弹框。
emit('cancel');
closeDialog();
};
@@ -57,7 +54,6 @@ const handleEscKey = (event: KeyboardEvent) => {
watch(
() => props.modelValue,
(visible) => {
// 关键点:弹框打开时监听 ESC,关闭后及时解绑,避免全局事件泄漏。
if (visible) {
document.addEventListener('keydown', handleEscKey);
return;
@@ -77,29 +73,29 @@ onBeforeUnmount(() => {
<Transition name="delete-dialog-fade">
<div
v-if="modelValue"
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
class="dialog-overlay items-center"
@click.self="handleCancel"
>
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
<div class="dialog-panel max-w-[416px] rounded-lg px-6 pt-7 pb-5">
<div class="flex items-start gap-3">
<span class="delete-dialog-icon" aria-hidden="true">!</span>
<span class="dialog-icon-warning" aria-hidden="true">!</span>
<div class="min-w-0">
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
<h3 class="text-base font-semibold leading-6 text-primary">
{{ resolvedTitle }}
</h3>
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
<p class="section-desc mt-3 whitespace-pre-line">
{{ resolvedMessage }}
</p>
</div>
</div>
<div class="mt-6 flex justify-end gap-2">
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
<button type="button" class="btn-secondary btn-sm" @click="handleCancel">
{{ resolvedCancelText }}
</button>
<button
type="button"
class="delete-dialog-btn confirm"
class="btn-danger btn-sm"
:disabled="confirmLoading"
@click="handleConfirm"
>
@@ -113,60 +109,6 @@ onBeforeUnmount(() => {
</template>
<style scoped>
.delete-dialog-icon {
width: 22px;
height: 22px;
border-radius: 9999px;
background: #faad14;
color: #fff;
font-size: 14px;
line-height: 1;
font-weight: 600;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-top: 2px;
}
.delete-dialog-btn {
min-width: 66px;
height: 32px;
border-radius: 6px;
font-size: 14px;
line-height: 1;
font-weight: 400;
padding: 4px 15px;
transition: all 0.2s ease;
}
.delete-dialog-btn.cancel {
color: rgba(0, 0, 0, 0.88);
background: #fff;
border: 1px solid #d9d9d9;
}
.delete-dialog-btn.cancel:hover {
border-color: #4096ff;
color: #4096ff;
}
.delete-dialog-btn.confirm {
color: #fff;
background: #1677ff;
border: 1px solid #1677ff;
}
.delete-dialog-btn.confirm:hover {
background: #4096ff;
border-color: #4096ff;
}
.delete-dialog-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.delete-dialog-fade-enter-active,
.delete-dialog-fade-leave-active {
transition: opacity 0.18s ease;
@@ -178,17 +120,9 @@ onBeforeUnmount(() => {
}
@media (max-width: 768px) {
.delete-dialog-container {
.dialog-panel {
max-width: 94vw;
padding: 20px 16px 16px;
}
.delete-dialog-icon {
margin-top: 1px;
}
.delete-dialog-btn {
min-width: 62px;
}
}
</style>
+24 -24
View File
@@ -417,29 +417,29 @@ watch(
</script>
<template>
<div v-if="modelValue && file" class="fixed inset-0 z-[80] flex items-center justify-center bg-black/50 dark:bg-slate-950/70 backdrop-blur-sm p-4">
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden border border-slate-200 dark:border-slate-700">
<div class="px-6 py-4 border-b border-slate-200 dark:border-slate-700 flex items-start justify-between gap-4">
<div v-if="modelValue && file" class="dialog-overlay dialog-overlay--z80 items-center">
<div class="dialog-panel max-w-5xl h-[85vh] overflow-hidden">
<div class="dialog-header dialog-header--compact items-start">
<div class="min-w-0">
<div class="text-sm font-medium text-slate-500 dark:text-slate-400 tracking-wide">{{ t('filePreview.title') }}</div>
<div class="mt-1 font-semibold text-slate-900 dark:text-slate-100 break-words">{{ file.name }}</div>
<button type="button" @click="downloadFile" :disabled="isDownloading" class="mt-2 inline-flex items-center justify-center px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-50 text-brand-700 hover:bg-brand-100 border border-brand-200 dark:bg-brand-900/30 dark:text-brand-300 dark:border-brand-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
<div class="label-field tracking-wide">{{ t('filePreview.title') }}</div>
<div class="mt-1 font-semibold text-primary break-words">{{ file.name }}</div>
<button type="button" @click="downloadFile" :disabled="isDownloading" class="btn-secondary btn-sm mt-2 inline-flex border-brand-200 text-brand-700 hover:bg-brand-50 disabled:opacity-50 disabled:cursor-not-allowed">
<svg v-if="!isDownloading" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
<svg v-else class="animate-spin -ml-1 mr-2 h-4 w-4 text-brand-700 dark:text-brand-300" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<svg v-else class="animate-spin -ml-1 mr-2 h-4 w-4 text-brand-700" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
{{ isDownloading ? t('filePreview.downloading') : t('filePreview.download') }}
</button>
</div>
<button type="button" @click="close" class="shrink-0 whitespace-nowrap inline-flex items-center justify-center px-4 py-2 rounded-xl border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 bg-white/80 dark:bg-slate-900/80 hover:bg-slate-100 dark:hover:bg-slate-800">{{ t('common.close') }}</button>
<button type="button" class="btn-secondary shrink-0" @click="close">{{ t('common.close') }}</button>
</div>
<div class="flex-1 overflow-auto p-4 bg-slate-50 dark:bg-slate-950">
<div v-if="isLoading" class="text-sm text-slate-500 dark:text-slate-400">{{ t('common.loading') }}</div>
<div v-else-if="error" class="text-sm text-red-600 bg-red-50 border border-red-200 rounded-lg p-3">
<div class="dialog-preview-body">
<div v-if="isLoading" class="text-sm text-muted">{{ t('common.loading') }}</div>
<div v-else-if="error" class="alert-ds alert-error text-sm">
<template v-if="previewTooLarge">
{{ t('filePreview.tooLarge') }}
</template>
@@ -449,14 +449,14 @@ watch(
</div>
<div
v-else-if="resolvedMode === 'markdown'"
class="prose prose-sm max-w-none bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-5"
class="prose prose-sm max-w-none dialog-preview-frame p-5"
v-html="markdownHtml"
></div>
<div
v-else-if="resolvedMode === 'sheet' && excelPreview"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4 overflow-auto"
class="dialog-preview-frame h-full p-4 overflow-auto"
>
<div class="mb-3 text-xs text-slate-500 dark:text-slate-400">
<div class="mb-3 text-xs text-muted">
Sheet: {{ excelPreview.sheet_name }} | Rows: {{ excelPreview.rows.length }}
<span v-if="excelPreview.truncated"> (truncated)</span>
</div>
@@ -466,7 +466,7 @@ watch(
<th
v-for="(col, i) in excelPreview.columns"
:key="`h-${i}`"
class="sticky top-0 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 px-2 py-1 text-left font-semibold"
class="sticky top-0 bg-surface-soft border border-default px-2 py-1 text-left font-semibold text-secondary"
>
{{ col }}
</th>
@@ -477,7 +477,7 @@ watch(
<td
v-for="(cell, ci) in row"
:key="`c-${ri}-${ci}`"
class="border border-slate-200 dark:border-slate-700 px-2 py-1 align-top whitespace-pre-wrap break-words"
class="border border-default px-2 py-1 align-top whitespace-pre-wrap break-words text-secondary"
>
{{ cell }}
</td>
@@ -487,7 +487,7 @@ watch(
</div>
<div
v-else-if="resolvedMode === 'office' && officeKind"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-2 overflow-auto"
class="dialog-preview-frame h-full p-2 overflow-auto"
>
<VueOfficeDocx
v-if="officeKind === 'docx'"
@@ -500,12 +500,12 @@ watch(
style="height: 100%; width: 100%;"
/>
</div>
<div v-else-if="resolvedMode === 'image'" class="h-full flex items-center justify-center bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-2">
<div v-else-if="resolvedMode === 'image'" class="dialog-preview-frame h-full flex items-center justify-center p-2">
<img :src="imageSrc" :alt="file.name" class="max-w-full max-h-full object-contain" />
</div>
<div
v-else-if="['pdf', 'doc', 'ppt', 'pptx'].includes(ext) && officeObjectUrl"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 overflow-hidden"
class="dialog-preview-frame h-full overflow-hidden"
>
<iframe
:src="officeObjectUrl"
@@ -515,12 +515,12 @@ watch(
</div>
<div
v-else-if="needsOfficeFallback"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-6"
class="dialog-preview-frame h-full p-6"
>
<!-- Graceful fallback for private/non-HTTPS Office links:
show actions instead of an empty iframe. -->
<div class="text-sm text-slate-700 dark:text-slate-200 font-semibold">Preview not available for this file URL</div>
<div class="mt-2 text-sm text-slate-500 dark:text-slate-400">
<div class="text-sm font-semibold text-secondary">Preview not available for this file URL</div>
<div class="mt-2 text-sm text-muted">
This Office file uses a private or non-HTTPS link, so online preview cannot render it.
</div>
<div class="mt-4 flex gap-3">
@@ -528,7 +528,7 @@ watch(
type="button"
@click="downloadFile"
:disabled="isDownloading"
class="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center"
class="btn-primary btn-sm inline-flex"
>
<svg v-if="isDownloading" class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
@@ -541,7 +541,7 @@ watch(
<iframe
v-else
:src="iframeSrc"
class="w-full h-full min-h-[480px] bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-700"
class="dialog-preview-frame w-full h-full min-h-[480px]"
allow="clipboard-read; clipboard-write"
></iframe>
</div>
@@ -118,34 +118,34 @@ const submitFeedback = async () => {
<template>
<div
v-if="modelValue"
class="fixed inset-0 z-[80] flex items-start justify-center overflow-y-auto bg-black/40 p-3 backdrop-blur-sm sm:items-center sm:p-4"
class="dialog-overlay dialog-overlay--z80"
>
<div class="flex max-h-[92vh] w-full max-w-2xl flex-col rounded-2xl border border-transparent bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-900">
<div class="flex items-center justify-between border-b border-gray-100 px-5 pb-4 pt-5 dark:border-slate-800 sm:px-8 sm:pb-4 sm:pt-7">
<h3 class="text-2xl font-bold text-gray-900 dark:text-slate-100">{{ t('feedback.title') }}</h3>
<div class="dialog-panel max-w-2xl max-h-[92vh]">
<div class="dialog-header">
<h3 class="section-title text-2xl">{{ t('feedback.title') }}</h3>
<button
@click="closeDialog"
class="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-300"
type="button"
class="btn-icon-ds"
aria-label="Close"
@click="closeDialog"
>
<X class="h-5 w-5" />
</button>
</div>
<div class="space-y-5 overflow-y-auto px-5 py-5 sm:px-8">
<div class="dialog-body space-y-5">
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.type') }}</label>
<div class="flex flex-wrap gap-3">
<label class="label-field block">{{ t('feedback.labels.type') }}</label>
<div class="segment-control segment-control--chips segment-control--md" role="radiogroup" :aria-label="t('feedback.labels.type')">
<button
v-for="item in typeOptions"
:key="item"
type="button"
role="radio"
:aria-checked="selectedType === item"
class="segment-item"
:class="selectedType === item ? 'segment-item--active' : ''"
@click="selectedType = item"
class="rounded-xl border px-4 py-2.5 text-base font-medium transition-colors"
:class="
selectedType === item
? 'border-blue-500 bg-blue-50 text-blue-700 dark:border-brand-500 dark:bg-brand-500/15 dark:text-brand-300'
: 'border-gray-200 bg-gray-50 text-gray-700 hover:bg-gray-100 dark:border-slate-600 dark:bg-slate-800/80 dark:text-slate-300 dark:hover:border-slate-500 dark:hover:bg-slate-700/80'
"
>
{{ item }}
</button>
@@ -153,44 +153,45 @@ const submitFeedback = async () => {
</div>
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.module') }}</label>
<select
v-model="selectedModule"
class="w-full rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-base text-gray-900 shadow-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:focus:border-brand-500 dark:focus:bg-slate-800 dark:focus:ring-brand-500/20"
>
<label class="label-field block">{{ t('feedback.labels.module') }}</label>
<select v-model="selectedModule" class="input-field text-base">
<option v-for="item in moduleOptions" :key="item" :value="item">{{ item }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.content') }}<span class="ml-0.5 text-red-500 dark:text-red-400">*</span></label>
<label class="label-field block">
{{ t('feedback.labels.content') }}<span class="ml-0.5 text-red-500">*</span>
</label>
<textarea
v-model="content"
rows="5"
maxlength="2000"
class="w-full resize-none rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-base text-gray-900 shadow-sm outline-none transition-all placeholder:text-gray-400 focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:border-brand-500 dark:focus:bg-slate-800 dark:focus:ring-brand-500/20"
class="input-field resize-none text-base"
:placeholder="t('feedback.placeholder.content')"
/>
<div class="mt-2 flex items-center justify-between">
<div v-if="error" class="text-base text-red-600 dark:text-red-400">{{ error }}</div>
<div v-else class="text-base text-gray-400"> </div>
<div class="text-base text-gray-400 dark:text-slate-500">{{ content.length }}/2000</div>
<div v-if="error" class="text-base text-red-600">{{ error }}</div>
<div v-else class="text-base text-muted"> </div>
<div class="text-base text-muted">{{ content.length }}/2000</div>
</div>
</div>
</div>
<div class="flex justify-end gap-3 rounded-b-2xl border-t border-gray-100 bg-white px-5 py-4 dark:border-slate-800 dark:bg-slate-900 sm:px-8">
<div class="dialog-footer">
<button
@click="closeDialog"
class="rounded-xl px-5 py-2.5 text-base font-medium text-gray-600 transition-colors hover:bg-gray-100 dark:text-slate-400 dark:hover:bg-slate-800 dark:hover:text-slate-200"
type="button"
class="btn-ghost"
:disabled="submitting"
@click="closeDialog"
>
{{ t('feedback.cancel') }}
</button>
<button
@click="submitFeedback"
class="inline-flex items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-base font-medium text-white shadow-md shadow-blue-200 transition-all hover:bg-blue-700 active:scale-95 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-brand-600 dark:shadow-none dark:hover:bg-brand-500"
type="button"
class="btn-primary"
:disabled="!canSubmit"
@click="submitFeedback"
>
<MessageSquareText class="h-5 w-5" />
{{ submitting ? t('feedback.submitting') : t('feedback.submit') }}
+15 -42
View File
@@ -5,15 +5,12 @@ import { Check, Info, AlertTriangle, XCircle, X } from 'lucide-vue-next';
type MessageLevel = 'success' | 'info' | 'warning' | 'error';
interface Props {
// 父组件通过 v-model 控制弹框显隐。
modelValue: boolean;
// 消息级别决定配色和图标。
level?: MessageLevel;
title?: string;
message?: string;
closeOnMask?: boolean;
closeOnEsc?: boolean;
// 自动关闭时长(毫秒):<= 0 表示不自动关闭。
autoCloseMs?: number;
}
@@ -31,30 +28,14 @@ const emit = defineEmits<{
(e: 'close'): void;
}>();
const STYLE_MAP: Record<MessageLevel, { panel: string; iconWrap: string; icon: string }> = {
success: {
panel: 'bg-[#eef8e8] border-[#b7e2a7]',
iconWrap: 'border-[#52c41a]',
icon: 'text-[#52c41a]',
},
info: {
panel: 'bg-[#eaf4ff] border-[#9fcbff]',
iconWrap: 'border-[#1677ff]',
icon: 'text-[#1677ff]',
},
warning: {
panel: 'bg-[#fff8e8] border-[#ffd88a]',
iconWrap: 'border-[#faad14]',
icon: 'text-[#faad14]',
},
error: {
panel: 'bg-[#fff1f0] border-[#ffb3b0]',
iconWrap: 'border-[#ff4d4f]',
icon: 'text-[#ff4d4f]',
},
const ALERT_CLASS: Record<MessageLevel, string> = {
success: 'alert-ds alert-success',
info: 'alert-ds alert-info',
warning: 'alert-ds alert-warning',
error: 'alert-ds alert-error',
};
const ICON_MAP: Record<MessageLevel, any> = {
const ICON_MAP: Record<MessageLevel, typeof Check> = {
success: Check,
info: Info,
warning: AlertTriangle,
@@ -68,7 +49,7 @@ const DEFAULT_TITLE_MAP: Record<MessageLevel, string> = {
error: 'Error',
};
const resolvedStyle = computed(() => STYLE_MAP[props.level]);
const panelClass = computed(() => ALERT_CLASS[props.level]);
const resolvedIcon = computed(() => ICON_MAP[props.level]);
const resolvedTitle = computed(() => props.title || DEFAULT_TITLE_MAP[props.level]);
const resolvedMessage = computed(() => props.message || '');
@@ -109,7 +90,6 @@ watch(
}
document.addEventListener('keydown', handleEscKey);
// 关键点:弹框可见时只要内容变化,也会重新计时自动关闭。
if (props.autoCloseMs > 0) {
autoCloseTimer = setTimeout(() => {
closeDialog();
@@ -129,16 +109,16 @@ onBeforeUnmount(() => {
<Transition name="level-dialog-fade">
<div
v-if="modelValue"
class="fixed inset-0 z-[110] bg-black/40 flex items-center justify-center p-4"
class="dialog-overlay dialog-overlay--z110 items-center"
@click.self="handleMaskClose"
>
<div
class="level-dialog-panel w-full max-w-[430px] rounded-2xl border shadow-[0_14px_28px_rgba(0,0,0,0.14)] px-9 py-8 relative"
:class="resolvedStyle.panel"
class="level-dialog-panel w-full max-w-[430px] rounded-2xl border shadow-elevated px-9 py-8 relative"
:class="panelClass"
>
<button
type="button"
class="absolute top-4 right-4 w-8 h-8 inline-flex items-center justify-center rounded-full text-slate-500 hover:text-slate-700 hover:bg-black/5 transition-colors"
class="btn-icon-ds absolute top-4 right-4"
@click="closeDialog"
aria-label="close dialog"
>
@@ -146,18 +126,15 @@ onBeforeUnmount(() => {
</button>
<div class="flex items-start gap-4 pr-8 min-h-0">
<span
class="w-8 h-8 rounded-full border-2 inline-flex items-center justify-center shrink-0 mt-0.5"
:class="resolvedStyle.iconWrap"
>
<component :is="resolvedIcon" class="w-4 h-4" :class="resolvedStyle.icon" />
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-current mt-0.5">
<component :is="resolvedIcon" class="h-4 w-4" />
</span>
<div class="min-w-0 w-full">
<h3 class="text-[16px] leading-6 font-semibold text-slate-800">
<h3 class="text-base font-semibold leading-6">
{{ resolvedTitle }}
</h3>
<p class="level-dialog-message mt-3 text-[14px] leading-8 text-slate-700 whitespace-pre-line break-words">
<p class="level-dialog-message mt-3 text-sm leading-7 whitespace-pre-line break-words opacity-90">
{{ resolvedMessage }}
</p>
</div>
@@ -197,10 +174,6 @@ onBeforeUnmount(() => {
padding: 20px 18px;
}
.level-dialog-panel p {
line-height: 1.75;
}
.level-dialog-message {
max-height: 52vh;
}
+20 -20
View File
@@ -26,21 +26,21 @@ onMounted(() => {
</script>
<template>
<div class="mt-6 rounded-2xl border border-slate-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800">
<div class="admin-table-section mt-6 p-5">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('scheduleRuns.title') }}</h3>
<button class="rounded-lg border border-slate-300 px-3 py-1.5 text-sm text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-700" @click="loadRuns">
<h3 class="section-title">{{ t('scheduleRuns.title') }}</h3>
<button type="button" class="btn-secondary btn-sm" @click="loadRuns">
{{ t('scheduleRuns.refresh') }}
</button>
</div>
<p class="mb-3 text-xs text-slate-500 dark:text-slate-400">{{ t('scheduleRuns.tip') }}</p>
<div v-if="isLoading" class="py-6 text-sm text-slate-500 dark:text-slate-400">{{ t('scheduleRuns.loading') }}</div>
<div v-else-if="error" class="py-6 text-sm text-rose-500 dark:text-rose-400">{{ error }}</div>
<div v-else-if="runs.length === 0" class="py-6 text-sm text-slate-400 dark:text-slate-500">{{ t('scheduleRuns.empty') }}</div>
<div v-else class="overflow-x-auto">
<table class="w-full min-w-[920px] text-sm">
<p class="section-desc mb-3">{{ t('scheduleRuns.tip') }}</p>
<div v-if="isLoading" class="py-6 text-sm text-muted">{{ t('scheduleRuns.loading') }}</div>
<div v-else-if="error" class="py-6 text-sm text-rose-500">{{ error }}</div>
<div v-else-if="runs.length === 0" class="py-6 text-sm text-muted">{{ t('scheduleRuns.empty') }}</div>
<div v-else class="admin-table-wrap">
<table class="admin-table min-w-[920px] text-sm">
<thead>
<tr class="border-b border-slate-200 text-left text-slate-500 dark:border-slate-700 dark:text-slate-400">
<tr>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.runNo') }}</th>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.schedule') }}</th>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.start') }}</th>
@@ -53,17 +53,17 @@ onMounted(() => {
</tr>
</thead>
<tbody>
<tr v-for="run in runs" :key="run.id" class="border-b border-slate-100 text-slate-700 dark:border-slate-700 dark:text-slate-300">
<td class="px-2 py-2">{{ run.run_no }}</td>
<td class="px-2 py-2">{{ run.schedule_name || '-' }}</td>
<td class="px-2 py-2">{{ run.started_at || '-' }}</td>
<td class="px-2 py-2">{{ run.finished_at || '-' }}</td>
<td class="px-2 py-2">{{ run.status }}</td>
<td class="px-2 py-2">{{ run.total_count }}</td>
<td class="px-2 py-2">{{ run.success_count }}</td>
<td class="px-2 py-2">{{ run.failed_count }}</td>
<tr v-for="run in runs" :key="run.id">
<td class="px-2 py-2 text-secondary">{{ run.run_no }}</td>
<td class="px-2 py-2 text-secondary">{{ run.schedule_name || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.started_at || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.finished_at || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.status }}</td>
<td class="px-2 py-2 text-secondary">{{ run.total_count }}</td>
<td class="px-2 py-2 text-secondary">{{ run.success_count }}</td>
<td class="px-2 py-2 text-secondary">{{ run.failed_count }}</td>
<td class="px-2 py-2">
<a class="text-brand-600 hover:underline dark:text-brand-400" :href="workspaceRunExcelUrl(run.id)" target="_blank">{{ t('scheduleRuns.viewExcel') }}</a>
<a class="text-brand-600 hover:underline" :href="workspaceRunExcelUrl(run.id)" target="_blank">{{ t('scheduleRuns.viewExcel') }}</a>
</td>
</tr>
</tbody>
@@ -14,17 +14,18 @@ const { appliedTheme, toggleLightDark } = useTheme();
const isDarkTheme = computed(() => appliedTheme.value === 'dark');
const buttonClass = computed(() =>
props.floating
? 'fixed bottom-5 right-5 z-[70] h-11 w-11 rounded-full bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-lg border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-xl flex items-center justify-center transition-all'
: 'h-8 w-8 md:h-9 md:w-9 rounded-full bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-md flex items-center justify-center transition-all'
? 'theme-toggle-btn theme-toggle-btn--floating'
: 'theme-toggle-btn theme-toggle-btn--inline'
);
</script>
<template>
<button
@click="toggleLightDark"
type="button"
:class="buttonClass"
:title="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
:aria-label="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
@click="toggleLightDark"
>
<Sun v-if="isDarkTheme" class="w-4 h-4 md:w-5 md:h-5" />
<Moon v-else class="w-4 h-4 md:w-5 md:h-5" />
+29 -29
View File
@@ -25,52 +25,52 @@ watch(() => props.open, (open) => {
</script>
<template>
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
<div class="w-full max-w-4xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
<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="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifyHealth.title') }}</h3>
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.subtitle') }}</p>
<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 class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="loadHealth">
<button type="button" class="btn-secondary btn-sm" @click="loadHealth">
{{ t('common.refresh') }}
</button>
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
<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-slate-400">{{ t('kbDifyHealth.loading') }}</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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">Dify API</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
<div class="mt-2 break-all text-xs text-slate-500 dark:text-slate-400">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
<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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.datasetCount') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.dataset_count ?? '--' }}</div>
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.boundGroups') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.dataset_bound_groups }}</div>
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncingVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.syncing_versions }}</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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncedVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.synced_versions }}</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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.pending_sync_jobs }}</div>
<div class="mt-2 text-xs text-rose-500" v-if="payload.api.error">{{ payload.api.error }}</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>
@@ -49,44 +49,44 @@ watch(() => props.open, (open) => {
</script>
<template>
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
<div class="w-full max-w-3xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
<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="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifySettings.title') }}</h3>
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifySettings.subtitle') }}</p>
<h3 class="section-title text-xl">{{ t('kbDifySettings.title') }}</h3>
<p class="section-desc mt-1">{{ t('kbDifySettings.subtitle') }}</p>
</div>
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
<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-slate-400">{{ t('kbDifySettings.loading') }}</div>
<div v-else class="mt-6 grid gap-4 md:grid-cols-2">
<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="text-sm font-medium text-slate-600 dark:text-slate-300">Dify Base URL</span>
<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="text-sm font-medium text-slate-600 dark:text-slate-300">Dify API Key</span>
<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="text-sm font-medium text-slate-600 dark:text-slate-300">Permission</span>
<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="text-sm font-medium text-slate-600 dark:text-slate-300">Indexing Technique</span>
<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="text-sm font-medium text-slate-600 dark:text-slate-300">Search Method</span>
<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>
@@ -94,7 +94,7 @@ watch(() => props.open, (open) => {
</select>
</label>
<label class="space-y-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Doc Form</span>
<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>
@@ -102,10 +102,10 @@ watch(() => props.open, (open) => {
</div>
<div class="mt-6 flex justify-end gap-3">
<button class="rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800" @click="close">
<button type="button" class="btn-secondary" @click="close">
{{ t('common.cancel') }}
</button>
<button class="rounded-2xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60" :disabled="saving" @click="save">
<button type="button" class="btn-primary" :disabled="saving" @click="save">
{{ saving ? t('kbDifySettings.saving') : t('kbDifySettings.save') }}
</button>
</div>
+45 -42
View File
@@ -156,23 +156,23 @@ defineExpose({ loadData });
<template>
<div class="animate-fade-in-up">
<div class="flex flex-col gap-4 border-b border-gray-100 bg-white px-8 py-6 dark:border-slate-700 dark:bg-slate-900 lg:flex-row lg:items-start lg:justify-between">
<div class="kb-admin-header">
<div class="min-w-0 flex-1">
<h2 class="text-xl font-bold text-gray-900 dark:text-slate-100">{{ t('kbAdmin.title') }}</h2>
<p class="mt-1 text-sm text-gray-500 dark:text-slate-400">
<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="inline-flex w-full items-stretch divide-x divide-slate-200 overflow-hidden rounded-xl border border-slate-200 bg-slate-50 dark:divide-slate-600 dark:border-slate-600 dark:bg-slate-800/80 sm:w-auto"
class="kb-admin-toolbar"
role="toolbar"
:aria-label="t('kbAdmin.toolbar')"
>
<button
type="button"
class="kb-admin-toolbar-btn"
@click="settingsDialogOpen = true"
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
:title="t('kbAdmin.difySettings')"
>
<Settings class="h-4 w-4 shrink-0" />
@@ -180,8 +180,8 @@ defineExpose({ loadData });
</button>
<button
type="button"
class="kb-admin-toolbar-btn"
@click="healthDialogOpen = true"
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
:title="t('kbAdmin.healthCheck')"
>
<Activity class="h-4 w-4 shrink-0" />
@@ -190,8 +190,8 @@ defineExpose({ loadData });
</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')"
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-sm font-medium text-white shadow-lg shadow-blue-200 transition-colors hover:bg-blue-700 sm:w-auto"
>
<Wrench class="h-4 w-4 shrink-0" />
<span class="whitespace-nowrap">{{ t('kbAdmin.goWorkspace') }}</span>
@@ -199,25 +199,25 @@ defineExpose({ loadData });
</div>
</div>
<div class="grid grid-cols-1 gap-6 bg-white p-8 dark:bg-slate-900 xl:grid-cols-[420px_minmax(0,1fr)]">
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<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 dark:bg-brand-500/10">
<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="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ formTitle }}</h3>
<p class="text-sm text-slate-500 dark:text-slate-400">{{ formDescription }}</p>
<h3 class="section-title">{{ formTitle }}</h3>
<p class="section-desc">{{ 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">{{ t('kbAdmin.form.groupName') }}</label>
<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="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">{{ t('kbAdmin.form.groupDesc') }}</label>
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupDesc') }}</label>
<textarea
v-model="form.description"
rows="4"
@@ -225,21 +225,21 @@ defineExpose({ loadData });
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
/>
</div>
<div class="flex flex-wrap items-center justify-end gap-2 border-t border-slate-100 pt-4 dark:border-slate-700">
<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"
class="inline-flex items-center gap-1.5 rounded-xl bg-blue-600 px-5 py-2 text-sm font-medium text-white shadow-md shadow-blue-200 transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
>
<FolderPlus v-if="!isSubmitting" class="h-4 w-4 shrink-0" />
{{ submitText }}
</button>
<button
v-if="editingGroupId"
@click="resetForm"
type="button"
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 px-4 py-2 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"
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') }}
@@ -248,7 +248,7 @@ defineExpose({ loadData });
<p
v-if="feedback"
class="text-sm"
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600 dark:text-emerald-400'"
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600'"
>
{{ feedback }}
</p>
@@ -256,44 +256,46 @@ defineExpose({ loadData });
</section>
<div class="space-y-6">
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<section class="kb-admin-section">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.groupsTitle') }}</h3>
<span class="text-xs text-slate-400">{{ isRefreshing ? t('common.loading') : '/api/kb/groups' }}</span>
<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="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
<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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
class="kb-admin-card"
>
<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 || t('kbAdmin.noDescription') }}</div>
<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="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">
<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-slate-400">
<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)"
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" />
{{ 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)"
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" />
{{ t('common.delete') }}
@@ -304,40 +306,41 @@ defineExpose({ loadData });
</div>
</section>
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<section class="kb-admin-section">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.jobsTitle') }}</h3>
<span class="text-xs text-slate-400">/api/kb/jobs</span>
<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="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
<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="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
class="kb-admin-card"
>
<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">
<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-slate-400">
<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="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">
<span class="kb-admin-badge">
{{ job.status }}
</span>
</div>
<div class="mt-3 flex justify-end" v-if="['clean', 'sync_dify'].includes(job.job_type) && job.status !== 'success'">
<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"
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 ? t('kbAdmin.running') : t('kbAdmin.runJob') }}