feat(faq): 知识库相对应文档更新,标记关联的问题为待复审状态并暂停缓存命中
This commit is contained in:
1 parent
757231e3d5
commit
0d59b23e0c
16 files changed
+809
-185
No files matched your search
@@ -56,6 +56,10 @@ const {
|
||||
|
||||
filterCacheOnly,
|
||||
|
||||
filterStaleOnly,
|
||||
|
||||
staleCount,
|
||||
|
||||
searchKeyword,
|
||||
|
||||
loadAll,
|
||||
@@ -68,6 +72,8 @@ const {
|
||||
|
||||
saveQuestion,
|
||||
|
||||
saveReviewQuestion,
|
||||
|
||||
deleteQuestion,
|
||||
|
||||
closeDeleteConfirm,
|
||||
@@ -144,6 +150,13 @@ onMounted(() => {
|
||||
|
||||
{{ t('admin.question.tabs.manual') }}
|
||||
|
||||
<span
|
||||
v-if="staleCount > 0"
|
||||
class="ml-1.5 inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-800"
|
||||
>
|
||||
{{ staleCount }}
|
||||
</span>
|
||||
|
||||
</button>
|
||||
|
||||
<button
|
||||
@@ -218,6 +231,14 @@ onMounted(() => {
|
||||
|
||||
</label>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="filterStaleOnly" type="checkbox" class="accent-brand-600" />
|
||||
|
||||
<span>{{ t('admin.question.filters.staleOnly') }}</span>
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="text-xs text-muted">
|
||||
@@ -274,6 +295,18 @@ onMounted(() => {
|
||||
|
||||
<div class="font-medium text-primary text-sm">{{ q.title }}</div>
|
||||
|
||||
<span
|
||||
|
||||
v-if="q.stale_at"
|
||||
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-amber-50 text-amber-800 border border-amber-100"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.stale') }}
|
||||
|
||||
</span>
|
||||
|
||||
<span
|
||||
|
||||
v-if="!q.is_enabled"
|
||||
@@ -416,21 +449,23 @@ onMounted(() => {
|
||||
|
||||
|
||||
|
||||
<QuestionFormModal
|
||||
<QuestionFormModal
|
||||
|
||||
:visible="showFormModal"
|
||||
:visible="showFormModal"
|
||||
|
||||
:form="form"
|
||||
:form="form"
|
||||
|
||||
:agents="agents"
|
||||
:agents="agents"
|
||||
|
||||
:is-saving="isSaving"
|
||||
:is-saving="isSaving"
|
||||
|
||||
@close="closeFormModal"
|
||||
@close="closeFormModal"
|
||||
|
||||
@save="saveQuestion"
|
||||
@save="saveQuestion"
|
||||
|
||||
/>
|
||||
@review="saveReviewQuestion"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,160 +1,199 @@
|
||||
/**␍
|
||||
* features/admin/modules/questions/components/QuestionFormModal.vue␍
|
||||
* 常用问题 / FAQ 缓存创建与编辑居中弹窗。␍
|
||||
* 依赖:QuestionFormState、admin 通用 modal 样式。␍
|
||||
* 逻辑:QuestionsPage 打开本组件;提交时 emit save,由 composable 调 API。␍
|
||||
*/␍
|
||||
<script setup lang="ts">␍
|
||||
import { computed } from 'vue';␍
|
||||
import { useI18n } from 'vue-i18n';␍
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';␍
|
||||
import type { QuestionFormState } from '@/features/admin/types/question.types';␍
|
||||
␍
|
||||
const props = defineProps<{␍
|
||||
visible: boolean;␍
|
||||
form: QuestionFormState;␍
|
||||
agents: AdminAgentOption[];␍
|
||||
isSaving: boolean;␍
|
||||
}>();␍
|
||||
␍
|
||||
const emit = defineEmits<{␍
|
||||
close: [];␍
|
||||
save: [];␍
|
||||
}>();␍
|
||||
␍
|
||||
const { t } = useI18n();␍
|
||||
␍
|
||||
/** 启用 FAQ 缓存时标准答案为必填。 */␍
|
||||
const answerRequired = computed(() => props.form.cache_enabled);␍
|
||||
</script>␍
|
||||
␍
|
||||
<template>␍
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">␍
|
||||
<div class="admin-modal-panel max-w-3xl max-h-[92vh] scale-100">␍
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">␍
|
||||
<h3 class="section-title">␍
|
||||
{{ form.id ? t('admin.question.edit') : t('admin.question.add') }}␍
|
||||
</h3>␍
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.question.formHint') }}</p>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div class="px-5 sm:px-8 py-5 space-y-6 overflow-y-auto">␍
|
||||
<section class="space-y-4">␍
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">␍
|
||||
{{ t('admin.question.sections.basic') }}␍
|
||||
</h4>␍
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">␍
|
||||
<div class="space-y-1.5 md:col-span-2">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.title') }}</label>␍
|
||||
<input␍
|
||||
v-model="form.title"␍
|
||||
type="text"␍
|
||||
class="input-field text-sm"␍
|
||||
:placeholder="t('admin.question.fields.titlePlaceholder')"␍
|
||||
/>␍
|
||||
</div>␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.targetAgent') }}</label>␍
|
||||
<select v-model="form.agent_id" class="input-field text-sm">␍
|
||||
<option :value="undefined" disabled>{{ t('admin.perm.batchModal.selectAgents') }}</option>␍
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">␍
|
||||
{{ agent.name }}␍
|
||||
</option>␍
|
||||
</select>␍
|
||||
</div>␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.sortOrder') }}</label>␍
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" />␍
|
||||
</div>␍
|
||||
<div class="md:col-span-2 flex flex-wrap gap-6">␍
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">␍
|
||||
<input v-model="form.is_enabled" type="checkbox" class="accent-brand-600" />␍
|
||||
<span>{{ t('admin.question.fields.isEnabled') }}</span>␍
|
||||
</label>␍
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">␍
|
||||
<input v-model="form.cache_enabled" type="checkbox" class="accent-brand-600" />␍
|
||||
<span>{{ t('admin.question.fields.cacheEnabled') }}</span>␍
|
||||
</label>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</section>␍
|
||||
␍
|
||||
<section class="space-y-4">␍
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">␍
|
||||
{{ t('admin.question.sections.matching') }}␍
|
||||
</h4>␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.content') }}</label>␍
|
||||
<textarea␍
|
||||
v-model="form.question"␍
|
||||
rows="3"␍
|
||||
class="input-field text-sm resize-y min-h-[88px]"␍
|
||||
:placeholder="t('admin.question.fields.contentPlaceholder')"␍
|
||||
/>␍
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.contentHelp') }}</p>␍
|
||||
</div>␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.aliases') }}</label>␍
|
||||
<textarea␍
|
||||
v-model="form.aliasesText"␍
|
||||
rows="3"␍
|
||||
class="input-field text-sm resize-y min-h-[88px] font-mono"␍
|
||||
:placeholder="t('admin.question.fields.aliasesPlaceholder')"␍
|
||||
/>␍
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.aliasesHelp') }}</p>␍
|
||||
</div>␍
|
||||
</section>␍
|
||||
␍
|
||||
<section class="space-y-4 rounded-2xl border border-default bg-surface-soft/60 p-4">␍
|
||||
<div class="flex items-start justify-between gap-3">␍
|
||||
<div>␍
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">␍
|
||||
{{ t('admin.question.sections.cache') }}␍
|
||||
</h4>␍
|
||||
<p class="text-xs text-muted mt-1">{{ t('admin.question.fields.cacheHelp') }}</p>␍
|
||||
</div>␍
|
||||
<span␍
|
||||
class="inline-flex shrink-0 items-center rounded-full px-2.5 py-0.5 text-xs font-medium"␍
|
||||
:class="form.cache_enabled ? 'bg-emerald-50 text-emerald-700 border border-emerald-100' : 'bg-surface-soft text-muted border border-default'"␍
|
||||
>␍
|
||||
{{ form.cache_enabled ? t('admin.question.badges.cacheOn') : t('admin.question.badges.cacheOff') }}␍
|
||||
</span>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">␍
|
||||
{{ t('admin.question.fields.answer') }}␍
|
||||
<span v-if="answerRequired" class="text-red-500">*</span>␍
|
||||
</label>␍
|
||||
<textarea␍
|
||||
v-model="form.answer"␍
|
||||
rows="6"␍
|
||||
class="input-field text-sm resize-y min-h-[140px]"␍
|
||||
:placeholder="t('admin.question.fields.answerPlaceholder')"␍
|
||||
/>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div class="space-y-1.5">␍
|
||||
<label class="label-field">{{ t('admin.question.fields.expiresAt') }}</label>␍
|
||||
<input v-model="form.expires_at" type="datetime-local" class="input-field text-sm" />␍
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.expiresAtHelp') }}</p>␍
|
||||
</div>␍
|
||||
</section>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div class="admin-modal-footer">␍
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>␍
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">␍
|
||||
{{␍
|
||||
isSaving␍
|
||||
? t('admin.save') + '...'␍
|
||||
: form.id␍
|
||||
? t('admin.update')␍
|
||||
: t('admin.add')␍
|
||||
}}␍
|
||||
</button>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</template>␍
|
||||
␍
|
||||
/**
|
||||
* features/admin/modules/questions/components/QuestionFormModal.vue
|
||||
* 常用问题 / FAQ 缓存创建与编辑居中弹窗。
|
||||
* 依赖:QuestionFormState、admin 通用 modal 样式。
|
||||
* 逻辑:QuestionsPage 打开本组件;提交时 emit save,由 composable 调 API。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';
|
||||
import type { QuestionFormState } from '@/features/admin/types/question.types';
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
form: QuestionFormState;
|
||||
agents: AdminAgentOption[];
|
||||
isSaving: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
save: [];
|
||||
review: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/** 启用 FAQ 缓存时标准答案为必填。 */
|
||||
const answerRequired = computed(() => props.form.cache_enabled);
|
||||
|
||||
/** 是否处于 KB 更新后的待复审状态。 */
|
||||
const isStale = computed(() => Boolean(props.form.stale_at));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-3xl max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">
|
||||
{{ form.id ? t('admin.question.edit') : t('admin.question.add') }}
|
||||
</h3>
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.question.formHint') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="px-5 sm:px-8 py-5 space-y-6 overflow-y-auto">
|
||||
<div
|
||||
v-if="isStale"
|
||||
class="rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"
|
||||
>
|
||||
<p class="font-medium">{{ t('admin.question.stale.bannerTitle') }}</p>
|
||||
<p class="mt-1 text-xs text-amber-800">
|
||||
{{ t('admin.question.stale.bannerBody', {
|
||||
doc: form.stale_kb_document_title || t('admin.question.stale.unknownDoc'),
|
||||
reason: form.stale_reason === 'kb_document_deleted'
|
||||
? t('admin.question.stale.reasonDeleted')
|
||||
: t('admin.question.stale.reasonUpdated'),
|
||||
}) }}
|
||||
</p>
|
||||
<p class="mt-1 text-xs text-amber-700">{{ t('admin.question.stale.bannerHint') }}</p>
|
||||
</div>
|
||||
|
||||
<section class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.basic') }}
|
||||
</h4>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="space-y-1.5 md:col-span-2">
|
||||
<label class="label-field">{{ t('admin.question.fields.title') }}</label>
|
||||
<input
|
||||
v-model="form.title"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.question.fields.titlePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.targetAgent') }}</label>
|
||||
<select v-model="form.agent_id" class="input-field text-sm">
|
||||
<option :value="undefined" disabled>{{ t('admin.perm.batchModal.selectAgents') }}</option>
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="md:col-span-2 flex flex-wrap gap-6">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.is_enabled" type="checkbox" class="accent-brand-600" />
|
||||
<span>{{ t('admin.question.fields.isEnabled') }}</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.cache_enabled" type="checkbox" class="accent-brand-600" />
|
||||
<span>{{ t('admin.question.fields.cacheEnabled') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.matching') }}
|
||||
</h4>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.content') }}</label>
|
||||
<textarea
|
||||
v-model="form.question"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y min-h-[88px]"
|
||||
:placeholder="t('admin.question.fields.contentPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.contentHelp') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.aliases') }}</label>
|
||||
<textarea
|
||||
v-model="form.aliasesText"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y min-h-[88px] font-mono"
|
||||
:placeholder="t('admin.question.fields.aliasesPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.aliasesHelp') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="space-y-4 rounded-2xl border border-default bg-surface-soft/60 p-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.cache') }}
|
||||
</h4>
|
||||
<p class="text-xs text-muted mt-1">{{ t('admin.question.fields.cacheHelp') }}</p>
|
||||
</div>
|
||||
<span
|
||||
class="inline-flex shrink-0 items-center rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="form.cache_enabled ? 'bg-emerald-50 text-emerald-700 border border-emerald-100' : 'bg-surface-soft text-muted border border-default'"
|
||||
>
|
||||
{{ form.cache_enabled ? t('admin.question.badges.cacheOn') : t('admin.question.badges.cacheOff') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">
|
||||
{{ t('admin.question.fields.answer') }}
|
||||
<span v-if="answerRequired" class="text-red-500">*</span>
|
||||
</label>
|
||||
<textarea
|
||||
v-model="form.answer"
|
||||
rows="6"
|
||||
class="input-field text-sm resize-y min-h-[140px]"
|
||||
:placeholder="t('admin.question.fields.answerPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.expiresAt') }}</label>
|
||||
<input v-model="form.expires_at" type="datetime-local" class="input-field text-sm" />
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.expiresAtHelp') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
v-if="isStale"
|
||||
type="button"
|
||||
class="btn-primary disabled:opacity-70"
|
||||
:disabled="isSaving"
|
||||
@click="emit('review')"
|
||||
>
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: t('admin.question.stale.completeReview')
|
||||
}}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-primary disabled:opacity-70"
|
||||
:disabled="isSaving"
|
||||
@click="emit('save')"
|
||||
>
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: form.id
|
||||
? t('admin.update')
|
||||
: t('admin.add')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -37,17 +37,21 @@ export function useQuestionsAdmin() {
|
||||
const showFormModal = ref(false);
|
||||
const filterAgentId = ref<number | ''>('');
|
||||
const filterCacheOnly = ref(false);
|
||||
const filterStaleOnly = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const staleCount = computed(() => questions.value.filter((q) => Boolean(q.stale_at)).length);
|
||||
|
||||
const filteredQuestions = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase();
|
||||
return questions.value.filter((q) => {
|
||||
if (filterAgentId.value !== '' && q.agent_id !== filterAgentId.value) return false;
|
||||
if (filterCacheOnly.value && !q.cache_enabled) return false;
|
||||
if (filterStaleOnly.value && !q.stale_at) return false;
|
||||
if (!keyword) return true;
|
||||
const haystack = [q.title, q.question, q.answer, ...(q.aliases || [])]
|
||||
.filter(Boolean)
|
||||
@@ -130,6 +134,9 @@ export function useQuestionsAdmin() {
|
||||
agent_id: q.agent_id,
|
||||
sort_order: q.sort_order,
|
||||
expires_at: q.expires_at ? q.expires_at.slice(0, 16) : '',
|
||||
stale_at: q.stale_at || null,
|
||||
stale_reason: q.stale_reason || null,
|
||||
stale_kb_document_title: q.stale_kb_document_title || null,
|
||||
};
|
||||
showFormModal.value = true;
|
||||
};
|
||||
@@ -191,6 +198,33 @@ export function useQuestionsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 完成 KB 待复审:更新答案、清除 stale 并重新启用缓存。
|
||||
*/
|
||||
const saveReviewQuestion = async (): Promise<void> => {
|
||||
if (!form.value.id) return;
|
||||
if (!form.value.answer.trim()) {
|
||||
msg.warning(t('admin.question.msg.answerRequired'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await saveAdminQuickQuestion(
|
||||
`/api/admin/quick-questions/${form.value.id}`,
|
||||
'PUT',
|
||||
buildQuestionPayload({ ...form.value, cache_enabled: true }, { clearStale: true }),
|
||||
);
|
||||
await loadQuestions();
|
||||
closeFormModal();
|
||||
msg.success(t('admin.question.msg.reviewCompleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteQuestion = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.question.confirmDelete'), async () => {
|
||||
try {
|
||||
@@ -215,12 +249,15 @@ export function useQuestionsAdmin() {
|
||||
deleteConfirmMessage,
|
||||
filterAgentId,
|
||||
filterCacheOnly,
|
||||
filterStaleOnly,
|
||||
staleCount,
|
||||
searchKeyword,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveQuestion,
|
||||
saveReviewQuestion,
|
||||
deleteQuestion,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
|
||||
@@ -17,6 +17,11 @@ export interface AdminQuickQuestionRow {
|
||||
sort_order: number;
|
||||
expires_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
source_kb_document_ids?: number[];
|
||||
stale_at?: string | null;
|
||||
stale_reason?: string | null;
|
||||
stale_kb_document_id?: number | null;
|
||||
stale_kb_document_title?: string | null;
|
||||
}
|
||||
|
||||
export interface QuestionFormState {
|
||||
@@ -30,6 +35,9 @@ export interface QuestionFormState {
|
||||
agent_id?: number;
|
||||
sort_order: number;
|
||||
expires_at: string;
|
||||
stale_at?: string | null;
|
||||
stale_reason?: string | null;
|
||||
stale_kb_document_title?: string | null;
|
||||
}
|
||||
|
||||
export const createEmptyQuestionForm = (): QuestionFormState => ({
|
||||
@@ -63,7 +71,10 @@ export const textToAliases = (text: string): string[] => {
|
||||
};
|
||||
|
||||
/** 构建提交 API 的 payload。 */
|
||||
export const buildQuestionPayload = (form: QuestionFormState): Record<string, unknown> => ({
|
||||
export const buildQuestionPayload = (
|
||||
form: QuestionFormState,
|
||||
options?: { clearStale?: boolean },
|
||||
): Record<string, unknown> => ({
|
||||
title: form.title,
|
||||
question: form.question,
|
||||
answer: form.answer || null,
|
||||
@@ -73,4 +84,5 @@ export const buildQuestionPayload = (form: QuestionFormState): Record<string, un
|
||||
agent_id: form.agent_id,
|
||||
sort_order: form.sort_order,
|
||||
expires_at: form.expires_at || null,
|
||||
...(options?.clearStale ? { clear_stale: true } : {}),
|
||||
});
|
||||
@@ -240,12 +240,14 @@
|
||||
"search": "Search title, query or answer…",
|
||||
"allAgents": "All agents",
|
||||
"cacheOnly": "Cache enabled only",
|
||||
"staleOnly": "Pending review only",
|
||||
"resultCount": "{count} item(s)"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "Cached",
|
||||
"cacheOff": "Not cached",
|
||||
"disabled": "Disabled"
|
||||
"disabled": "Disabled",
|
||||
"stale": "Review"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} alias(es)"
|
||||
@@ -258,7 +260,17 @@
|
||||
"msg": {
|
||||
"fillAll": "Please fill in title, query and target agent",
|
||||
"answerRequired": "Preset answer is required when FAQ cache is enabled",
|
||||
"saved": "Saved successfully"
|
||||
"saved": "Saved successfully",
|
||||
"reviewCompleted": "Review completed; FAQ cache re-enabled"
|
||||
},
|
||||
"stale": {
|
||||
"bannerTitle": "Linked knowledge base changed — cache paused",
|
||||
"bannerBody": "Triggered by: {doc} ({reason})",
|
||||
"bannerHint": "Update the standard answer from the latest KB, then click Complete review. While stale, users get fresh answers via Dify.",
|
||||
"unknownDoc": "Unknown document",
|
||||
"reasonUpdated": "Document updated",
|
||||
"reasonDeleted": "Document deleted",
|
||||
"completeReview": "Complete review & enable cache"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "Common Questions",
|
||||
|
||||
@@ -240,12 +240,14 @@
|
||||
"search": "ค้นหาหัวข้อ คำถาม หรือคำตอบ…",
|
||||
"allAgents": "ตัวแทนทั้งหมด",
|
||||
"cacheOnly": "เฉพาะที่เปิด cache",
|
||||
"staleOnly": "รอตรวจสอบเท่านั้น",
|
||||
"resultCount": "{count} รายการ"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "Cache แล้ว",
|
||||
"cacheOff": "ยังไม่ cache",
|
||||
"disabled": "ปิดใช้งาน"
|
||||
"disabled": "ปิดใช้งาน",
|
||||
"stale": "รอตรวจ"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} คำถามทางเลือก"
|
||||
@@ -258,7 +260,17 @@
|
||||
"msg": {
|
||||
"fillAll": "กรุณากรอกหัวข้อ คำถาม และตัวแทนเป้าหมาย",
|
||||
"answerRequired": "ต้องกรอกคำตอบมาตรฐานเมื่อเปิด FAQ cache",
|
||||
"saved": "บันทึกสำเร็จ"
|
||||
"saved": "บันทึกสำเร็จ",
|
||||
"reviewCompleted": "ตรวจสอบเสร็จแล้ว เปิด FAQ cache อีกครั้ง"
|
||||
},
|
||||
"stale": {
|
||||
"bannerTitle": "ฐานความรู้ที่เชื่อมโยงมีการเปลี่ยนแปลง — หยุด cache ชั่วคราว",
|
||||
"bannerBody": "เอกสารที่ทริกเกอร์: {doc} ({reason})",
|
||||
"bannerHint": "อัปเดตคำตอบมาตรฐานจาก KB ล่าสุด แล้วกดเสร็จสิ้นการตรวจสอบ ระหว่างรอตรวจ ผู้ใช้จะได้คำตอบใหม่ผ่าน Dify",
|
||||
"unknownDoc": "เอกสารไม่ทราบ",
|
||||
"reasonUpdated": "อัปเดตเอกสารแล้ว",
|
||||
"reasonDeleted": "ลบเอกสารแล้ว",
|
||||
"completeReview": "เสร็จสิ้นการตรวจสอบและเปิด cache"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "คำถามทั่วไป",
|
||||
|
||||
@@ -241,12 +241,14 @@
|
||||
"search": "搜索标题、问句或答案…",
|
||||
"allAgents": "全部应用",
|
||||
"cacheOnly": "仅显示已启用缓存",
|
||||
"staleOnly": "仅显示待复审",
|
||||
"resultCount": "共 {count} 条"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "已缓存",
|
||||
"cacheOff": "未缓存",
|
||||
"disabled": "已停用"
|
||||
"disabled": "已停用",
|
||||
"stale": "待复审"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} 条同义问法"
|
||||
@@ -259,7 +261,17 @@
|
||||
"msg": {
|
||||
"fillAll": "请填写标题、问句和目标应用",
|
||||
"answerRequired": "启用 FAQ 缓存时必须填写标准答案",
|
||||
"saved": "保存成功"
|
||||
"saved": "保存成功",
|
||||
"reviewCompleted": "复审完成,FAQ 缓存已重新启用"
|
||||
},
|
||||
"stale": {
|
||||
"bannerTitle": "关联知识库已更新,缓存已暂停",
|
||||
"bannerBody": "触发文档:{doc}({reason})",
|
||||
"bannerHint": "请对照最新知识库更新标准答案,完成后点击「完成复审并启用缓存」。失效期间用户提问将走 Dify 获取新答案。",
|
||||
"unknownDoc": "未知文档",
|
||||
"reasonUpdated": "文档内容已更新",
|
||||
"reasonDeleted": "文档已删除",
|
||||
"completeReview": "完成复审并启用缓存"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "常用问题",
|
||||
|
||||
@@ -240,12 +240,14 @@
|
||||
"search": "搜尋標題、問句或答案…",
|
||||
"allAgents": "全部應用",
|
||||
"cacheOnly": "僅顯示已啟用快取",
|
||||
"staleOnly": "僅顯示待複審",
|
||||
"resultCount": "共 {count} 條"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "已快取",
|
||||
"cacheOff": "未快取",
|
||||
"disabled": "已停用"
|
||||
"disabled": "已停用",
|
||||
"stale": "待複審"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} 條同義問法"
|
||||
@@ -258,7 +260,17 @@
|
||||
"msg": {
|
||||
"fillAll": "請填寫標題、問句和目標應用",
|
||||
"answerRequired": "啟用 FAQ 快取時必須填寫標準答案",
|
||||
"saved": "儲存成功"
|
||||
"saved": "儲存成功",
|
||||
"reviewCompleted": "複審完成,FAQ 快取已重新啟用"
|
||||
},
|
||||
"stale": {
|
||||
"bannerTitle": "關聯知識庫已更新,快取已暫停",
|
||||
"bannerBody": "觸發文件:{doc}({reason})",
|
||||
"bannerHint": "請對照最新知識庫更新標準答案,完成後點擊「完成複審並啟用快取」。失效期間使用者提問將走 Dify 取得新答案。",
|
||||
"unknownDoc": "未知文件",
|
||||
"reasonUpdated": "文件內容已更新",
|
||||
"reasonDeleted": "文件已刪除",
|
||||
"completeReview": "完成複審並啟用快取"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "常用問題",
|
||||
|
||||
Reference in new issue
Block a user