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 } : {}),
|
||||
});
|
||||
Reference in new issue
Block a user