Merge branch 'dev' into hugo
This commit is contained in:
commit
97a5a1f106
35 files changed
+3749
-259
No files matched your search
@@ -247,3 +247,40 @@ export const saveAdminQuickQuestion = (url: string, method: string, payload: Rec
|
||||
requestJson(url, { method, ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const deleteAdminQuickQuestion = (id: number) =>
|
||||
requestJson(`/api/admin/quick-questions/${id}`, { method: 'DELETE', ...auth() });
|
||||
|
||||
// Hot FAQ candidates (offline aggregation)
|
||||
export const listAdminFaqCandidates = (agentId?: number) => {
|
||||
const query = agentId ? `?agent_id=${agentId}` : '';
|
||||
return requestJson<any>(`/api/admin/faq-candidates${query}`, auth());
|
||||
};
|
||||
|
||||
export const refreshAdminFaqCandidates = (payload?: { agent_id?: number; dry_run?: boolean }) =>
|
||||
requestJson<{
|
||||
promoted_count?: number;
|
||||
scanned_logs?: number;
|
||||
enabled?: boolean;
|
||||
dry_run?: boolean;
|
||||
}>('/api/admin/faq-candidates/refresh', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(payload || {}),
|
||||
});
|
||||
|
||||
export const promoteAdminFaqCandidate = (payload: {
|
||||
agent_id: number;
|
||||
q_norm: string;
|
||||
title?: string;
|
||||
sort_order?: number;
|
||||
}) =>
|
||||
requestJson('/api/admin/faq-candidates/promote', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
export const dismissAdminFaqCandidate = (payload: { agent_id: number; q_norm: string }) =>
|
||||
requestJson('/api/admin/faq-candidates/dismiss', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
@@ -1,174 +1,455 @@
|
||||
/**
|
||||
|
||||
* features/admin/modules/questions/QuestionsPage.vue
|
||||
* 常用问题管理独立页面。路由:/admin/questions
|
||||
|
||||
* 常用问题管理:Tab「常用问题」+「热点发现」(离线聚合候选)。
|
||||
|
||||
* 依赖:useQuestionsAdmin、HotFaqCandidatesPanel、QuestionFormModal。
|
||||
|
||||
* 逻辑:路由 /admin/questions;热点候选晋升后写入 QuickQuestion 并由 Phase 1 FAQ 在线命中。
|
||||
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Trash2 } from 'lucide-vue-next';
|
||||
|
||||
import { Edit, Plus, Trash2, Zap } from 'lucide-vue-next';
|
||||
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
|
||||
import HotFaqCandidatesPanel from './components/HotFaqCandidatesPanel.vue';
|
||||
|
||||
import QuestionFormModal from './components/QuestionFormModal.vue';
|
||||
|
||||
import { useQuestionsAdmin } from './composables/useQuestionsAdmin';
|
||||
|
||||
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const activeTab = ref<'manual' | 'hot'>('manual');
|
||||
|
||||
|
||||
|
||||
const {
|
||||
questions,
|
||||
|
||||
filteredQuestions,
|
||||
|
||||
agents,
|
||||
|
||||
form,
|
||||
isEditing,
|
||||
|
||||
isLoading,
|
||||
|
||||
isSaving,
|
||||
|
||||
showFormModal,
|
||||
|
||||
showDeleteConfirmDialog,
|
||||
|
||||
deleteConfirmMessage,
|
||||
|
||||
filterAgentId,
|
||||
|
||||
filterCacheOnly,
|
||||
|
||||
searchKeyword,
|
||||
|
||||
loadAll,
|
||||
resetForm,
|
||||
editQuestion,
|
||||
|
||||
openCreateModal,
|
||||
|
||||
openEditModal,
|
||||
|
||||
closeFormModal,
|
||||
|
||||
saveQuestion,
|
||||
|
||||
deleteQuestion,
|
||||
|
||||
closeDeleteConfirm,
|
||||
|
||||
confirmDelete,
|
||||
|
||||
truncateQuestionPreview,
|
||||
|
||||
truncateAnswerPreview,
|
||||
|
||||
} = useQuestionsAdmin();
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
void loadAll();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
|
||||
<div class="admin-table-header admin-table-header--stacked mb-4">
|
||||
|
||||
<div>
|
||||
|
||||
<h2 class="section-title">{{ t('admin.question.title') }}</h2>
|
||||
|
||||
<p class="section-desc mt-1">{{ t('admin.question.subtitle') }}</p>
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
|
||||
v-if="activeTab === 'manual'"
|
||||
|
||||
type="button"
|
||||
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
|
||||
@click="openCreateModal"
|
||||
|
||||
>
|
||||
|
||||
<Plus class="w-4 h-4" />
|
||||
|
||||
<span>{{ t('admin.question.add') }}</span>
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="mb-6 flex gap-1 border-b border-default">
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors"
|
||||
|
||||
:class="activeTab === 'manual' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
|
||||
|
||||
@click="activeTab = 'manual'"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.tabs.manual') }}
|
||||
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors"
|
||||
|
||||
:class="activeTab === 'hot' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
|
||||
|
||||
@click="activeTab = 'hot'"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.tabs.hotDiscovery') }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<HotFaqCandidatesPanel v-if="activeTab === 'hot'" />
|
||||
|
||||
|
||||
|
||||
<template v-else>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.question.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.question.subtitle') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div class="lg:col-span-1 card p-6 shadow-sm h-fit">
|
||||
<h3 class="font-bold text-primary mb-4">
|
||||
{{ isEditing ? t('admin.question.edit') : t('admin.question.add') }}
|
||||
</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.title') }}</label>
|
||||
<input
|
||||
v-model="form.title"
|
||||
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="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.content') }}</label>
|
||||
<textarea
|
||||
v-model="form.question"
|
||||
rows="4"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.question.fields.contentPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2 pt-2">
|
||||
<button
|
||||
v-if="isEditing"
|
||||
type="button"
|
||||
class="btn-ghost btn-sm"
|
||||
@click="resetForm"
|
||||
>
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary btn-sm disabled:opacity-50"
|
||||
:disabled="isSaving"
|
||||
@click="saveQuestion"
|
||||
>
|
||||
{{ isSaving ? t('admin.save') + '...' : (isEditing ? t('admin.update') : t('admin.add')) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
|
||||
<div class="mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
|
||||
<div class="flex flex-1 flex-wrap items-center gap-3">
|
||||
|
||||
<input
|
||||
|
||||
v-model="searchKeyword"
|
||||
|
||||
type="search"
|
||||
|
||||
class="input-field text-sm w-full max-w-xs"
|
||||
|
||||
:placeholder="t('admin.question.filters.search')"
|
||||
|
||||
/>
|
||||
|
||||
<select v-model="filterAgentId" class="input-field text-sm w-full max-w-[200px]">
|
||||
|
||||
<option value="">{{ t('admin.question.filters.allAgents') }}</option>
|
||||
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
|
||||
{{ agent.name }}
|
||||
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="filterCacheOnly" type="checkbox" class="accent-brand-600" />
|
||||
|
||||
<span>{{ t('admin.question.filters.cacheOnly') }}</span>
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="text-xs text-muted">
|
||||
|
||||
{{ t('admin.question.filters.resultCount', { count: filteredQuestions.length }) }}
|
||||
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-2 admin-table-section">
|
||||
<div v-if="questions.length === 0" class="p-8 text-center text-muted">
|
||||
{{ t('admin.question.noData') }}
|
||||
</div>
|
||||
<table v-else class="admin-table">
|
||||
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
|
||||
<table class="admin-table">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-xs font-semibold text-muted uppercase">
|
||||
{{ t('admin.question.headers.title') }}
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-semibold text-muted uppercase">
|
||||
{{ t('admin.question.headers.agent') }}
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-semibold text-muted uppercase">
|
||||
{{ t('admin.question.headers.order') }}
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-semibold text-muted uppercase text-right">
|
||||
{{ t('admin.question.headers.actions') }}
|
||||
</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.title') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.agent') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.content') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.answer') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.question.headers.cache') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.question.headers.hits') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-16">{{ t('admin.question.headers.order') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-right text-xs w-28">{{ t('admin.question.headers.actions') }}</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
<tbody class="divide-y divide-subtle">
|
||||
<tr v-for="q in questions" :key="q.id">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm">{{ q.title }}</div>
|
||||
<div class="text-xs text-muted truncate max-w-xs mt-0.5">{{ q.question }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700 border border-blue-100"
|
||||
>
|
||||
{{ q.agent_name || 'Unknown' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted">{{ q.sort_order }}</td>
|
||||
<td class="px-6 py-4 text-right flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors"
|
||||
@click="editQuestion(q)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
@click="deleteQuestion(q.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr v-if="filteredQuestions.length === 0">
|
||||
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.question.noData') }}</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr v-for="q in filteredQuestions" :key="q.id" class="group">
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
<div class="font-medium text-primary text-sm">{{ q.title }}</div>
|
||||
|
||||
<span
|
||||
|
||||
v-if="!q.is_enabled"
|
||||
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-surface-soft text-muted border border-default"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.disabled') }}
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<span
|
||||
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700 border border-blue-100"
|
||||
|
||||
>
|
||||
|
||||
{{ q.agent_name || 'Unknown' }}
|
||||
|
||||
</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<p class="text-sm text-secondary truncate max-w-[180px]" :title="q.question">
|
||||
|
||||
{{ truncateQuestionPreview(q.question) }}
|
||||
|
||||
</p>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<p
|
||||
|
||||
v-if="q.cache_enabled && q.answer"
|
||||
|
||||
class="text-sm text-secondary truncate max-w-[160px]"
|
||||
|
||||
:title="q.answer"
|
||||
|
||||
>
|
||||
|
||||
{{ truncateAnswerPreview(q.answer) }}
|
||||
|
||||
</p>
|
||||
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<span
|
||||
|
||||
v-if="q.cache_enabled"
|
||||
|
||||
class="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium bg-emerald-50 text-emerald-700 border border-emerald-100"
|
||||
|
||||
>
|
||||
|
||||
<Zap class="w-3 h-3" />
|
||||
|
||||
{{ t('admin.question.badges.cacheOn') }}
|
||||
|
||||
</span>
|
||||
|
||||
<span
|
||||
|
||||
v-else
|
||||
|
||||
class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-soft text-muted border border-default"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.cacheOff') }}
|
||||
|
||||
</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4 text-sm text-muted tabular-nums">{{ q.hit_count || 0 }}</td>
|
||||
|
||||
<td class="px-6 py-4 text-sm text-muted tabular-nums">{{ q.sort_order }}</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<div class="flex justify-end gap-1">
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="p-1.5 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
|
||||
@click="openEditModal(q)"
|
||||
|
||||
>
|
||||
|
||||
<Edit class="w-4 h-4" />
|
||||
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
|
||||
@click="deleteQuestion(q.id)"
|
||||
|
||||
>
|
||||
|
||||
<Trash2 class="w-4 h-4" />
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<QuestionFormModal
|
||||
|
||||
:visible="showFormModal"
|
||||
|
||||
:form="form"
|
||||
|
||||
:agents="agents"
|
||||
|
||||
:is-saving="isSaving"
|
||||
|
||||
@close="closeFormModal"
|
||||
|
||||
@save="saveQuestion"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<DeleteConfirmDialog
|
||||
|
||||
v-model="showDeleteConfirmDialog"
|
||||
|
||||
:message="deleteConfirmMessage"
|
||||
|
||||
@cancel="closeDeleteConfirm"
|
||||
|
||||
@confirm="confirmDelete"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* features/admin/modules/questions/components/HotFaqCandidatesPanel.vue
|
||||
* 热点 FAQ 候选列表:离线聚合结果展示、刷新、晋升、忽略。
|
||||
* 依赖:useHotFaqCandidates。
|
||||
* 逻辑:QuestionsPage「热点发现」Tab 挂载本组件。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowUpCircle, Info, RefreshCw, XCircle } from 'lucide-vue-next';
|
||||
import { useHotFaqCandidates } from '../composables/useHotFaqCandidates';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
filteredItems,
|
||||
agents,
|
||||
stats,
|
||||
rules,
|
||||
isLoading,
|
||||
isRefreshing,
|
||||
filterAgentId,
|
||||
searchKeyword,
|
||||
showRules,
|
||||
loadAll,
|
||||
loadCandidates,
|
||||
refreshCandidates,
|
||||
promoteCandidate,
|
||||
dismissCandidate,
|
||||
truncatePreview,
|
||||
} = useHotFaqCandidates();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
|
||||
const onAgentFilterChange = () => {
|
||||
void loadCandidates();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 p-4 text-sm text-secondary">
|
||||
<p>{{ t('admin.hotFaq.intro') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 inline-flex items-center gap-1 text-xs font-medium text-brand-600 hover:underline"
|
||||
@click="showRules = !showRules"
|
||||
>
|
||||
<Info class="w-3.5 h-3.5" />
|
||||
{{ showRules ? t('admin.hotFaq.hideRules') : t('admin.hotFaq.showRules') }}
|
||||
</button>
|
||||
<div v-if="showRules && rules" class="mt-3 space-y-2 text-xs text-muted border-t border-subtle pt-3">
|
||||
<div>
|
||||
<span class="font-semibold text-secondary">{{ t('admin.hotFaq.rules.selection') }}</span>
|
||||
{{ (rules as any).selection?.description }}
|
||||
</div>
|
||||
<ul class="list-disc pl-5 space-y-0.5">
|
||||
<li>{{ t('admin.hotFaq.rules.windowDays', { n: (rules as any).selection?.window_days }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minCount', { n: (rules as any).selection?.min_count }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minUsers', { n: (rules as any).selection?.min_users }) }}</li>
|
||||
</ul>
|
||||
<div class="pt-1">
|
||||
<span class="font-semibold text-secondary">{{ t('admin.hotFaq.rules.answer') }}</span>
|
||||
{{ (rules as any).answer?.description }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div class="flex flex-1 flex-wrap items-center gap-3">
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
type="search"
|
||||
class="input-field text-sm w-full max-w-xs"
|
||||
:placeholder="t('admin.hotFaq.filters.search')"
|
||||
/>
|
||||
<select
|
||||
v-model="filterAgentId"
|
||||
class="input-field text-sm w-full max-w-[200px]"
|
||||
@change="onAgentFilterChange"
|
||||
>
|
||||
<option value="">{{ t('admin.hotFaq.filters.allAgents') }}</option>
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs text-muted">
|
||||
{{ t('admin.hotFaq.stats.summary', {
|
||||
count: stats.total_candidates ?? 0,
|
||||
asks: stats.total_ask_count_7d ?? 0,
|
||||
}) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-sm"
|
||||
:disabled="isRefreshing"
|
||||
@click="refreshCandidates(true)"
|
||||
>
|
||||
{{ t('admin.hotFaq.actions.dryRun') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 text-sm font-medium disabled:opacity-70"
|
||||
:disabled="isRefreshing"
|
||||
@click="refreshCandidates(false)"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': isRefreshing }" />
|
||||
{{ t('admin.hotFaq.actions.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-16">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<div v-else class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.query') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.agent') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.answer') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.asks') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.users') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-24">{{ t('admin.hotFaq.headers.tokens') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.dominance') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-36">{{ t('admin.hotFaq.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredItems.length === 0">
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.hotFaq.noData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in filteredItems" :key="`${row.agent_id}-${row.q_norm}`">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm">{{ row.canonical_query }}</div>
|
||||
<p v-if="row.sample_queries?.length" class="text-[11px] text-muted mt-1 truncate max-w-[200px]">
|
||||
{{ row.sample_queries.slice(0, 2).join(' / ') }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex px-2.5 py-0.5 rounded-full text-xs bg-blue-50 text-blue-700 border border-blue-100">
|
||||
{{ row.agent_name || row.agent_id }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-secondary truncate max-w-[180px]" :title="row.answer">
|
||||
{{ truncatePreview(row.answer) }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.ask_count_7d }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.user_count_7d }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.avg_tokens }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">
|
||||
{{ row.answer_dominance != null ? `${Math.round(row.answer_dominance * 100)}%` : '—' }}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 px-2.5 py-1.5 text-xs font-medium text-emerald-700 bg-emerald-50 hover:bg-emerald-100 rounded-lg border border-emerald-100"
|
||||
:title="t('admin.hotFaq.actions.promote')"
|
||||
@click="promoteCandidate(row)"
|
||||
>
|
||||
<ArrowUpCircle class="w-3.5 h-3.5" />
|
||||
{{ t('admin.hotFaq.actions.promote') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg"
|
||||
:title="t('admin.hotFaq.actions.dismiss')"
|
||||
@click="dismissCandidate(row)"
|
||||
>
|
||||
<XCircle class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,160 @@
|
||||
/**␍
|
||||
* 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>␍
|
||||
␍
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* features/admin/modules/questions/composables/useHotFaqCandidates.ts
|
||||
* 热点 FAQ 候选(离线聚合)管理:列表、刷新、晋升、忽略。
|
||||
* 依赖:admin.api、useMessage。
|
||||
* 逻辑:QuestionsPage「热点发现」Tab 调用本 composable。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
dismissAdminFaqCandidate,
|
||||
listAdminAgents,
|
||||
listAdminFaqCandidates,
|
||||
promoteAdminFaqCandidate,
|
||||
refreshAdminFaqCandidates,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';
|
||||
|
||||
export interface HotFaqCandidateRow {
|
||||
agent_id: number;
|
||||
agent_name?: string;
|
||||
q_norm: string;
|
||||
canonical_query: string;
|
||||
answer: string;
|
||||
ask_count_7d: number;
|
||||
user_count_7d: number;
|
||||
avg_tokens: number;
|
||||
avg_latency_ms?: number;
|
||||
answer_dominance?: number;
|
||||
last_asked_at?: string;
|
||||
sample_queries?: string[];
|
||||
}
|
||||
|
||||
const PREVIEW_MAX = 56;
|
||||
|
||||
export function useHotFaqCandidates() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const items = ref<HotFaqCandidateRow[]>([]);
|
||||
const agents = ref<AdminAgentOption[]>([]);
|
||||
const stats = ref<Record<string, unknown>>({});
|
||||
const rules = ref<Record<string, unknown> | null>(null);
|
||||
const isLoading = ref(true);
|
||||
const isRefreshing = ref(false);
|
||||
const filterAgentId = ref<number | ''>('');
|
||||
const searchKeyword = ref('');
|
||||
const showRules = ref(false);
|
||||
|
||||
const filteredItems = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase();
|
||||
return items.value.filter((row) => {
|
||||
if (filterAgentId.value !== '' && row.agent_id !== filterAgentId.value) return false;
|
||||
if (!keyword) return true;
|
||||
const haystack = [
|
||||
row.canonical_query,
|
||||
row.answer,
|
||||
...(row.sample_queries || []),
|
||||
]
|
||||
.join(' ')
|
||||
.toLowerCase();
|
||||
return haystack.includes(keyword);
|
||||
});
|
||||
});
|
||||
|
||||
const loadAgents = async (): Promise<void> => {
|
||||
try {
|
||||
agents.value = await listAdminAgents();
|
||||
} catch {
|
||||
agents.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const loadCandidates = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const agentId = filterAgentId.value === '' ? undefined : Number(filterAgentId.value);
|
||||
const data = await listAdminFaqCandidates(agentId);
|
||||
items.value = Array.isArray(data.items) ? data.items : [];
|
||||
stats.value = data.stats || {};
|
||||
rules.value = data.rules || null;
|
||||
} catch (e) {
|
||||
console.error('Failed to load FAQ candidates', e);
|
||||
items.value = [];
|
||||
stats.value = {};
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const loadAll = async (): Promise<void> => {
|
||||
await Promise.all([loadAgents(), loadCandidates()]);
|
||||
};
|
||||
|
||||
/**
|
||||
* 触发离线聚合刷新。
|
||||
* @param dryRun - 为 true 时仅预览统计
|
||||
*/
|
||||
const refreshCandidates = async (dryRun = false): Promise<void> => {
|
||||
isRefreshing.value = true;
|
||||
try {
|
||||
const agentId = filterAgentId.value === '' ? undefined : Number(filterAgentId.value);
|
||||
const result = await refreshAdminFaqCandidates({
|
||||
agent_id: agentId,
|
||||
dry_run: dryRun,
|
||||
});
|
||||
if (dryRun) {
|
||||
msg.info(
|
||||
t('admin.hotFaq.msg.dryRunDone', {
|
||||
promoted: result.promoted_count ?? 0,
|
||||
scanned: result.scanned_logs ?? 0,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
msg.success(t('admin.hotFaq.msg.refreshed'));
|
||||
await loadCandidates();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isRefreshing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 晋升候选为全局 FAQ(QuickQuestion + cache_enabled)。
|
||||
*/
|
||||
const promoteCandidate = async (row: HotFaqCandidateRow): Promise<void> => {
|
||||
try {
|
||||
await promoteAdminFaqCandidate({
|
||||
agent_id: row.agent_id,
|
||||
q_norm: row.q_norm,
|
||||
title: row.canonical_query.slice(0, 100),
|
||||
});
|
||||
msg.success(t('admin.hotFaq.msg.promoted'));
|
||||
await loadCandidates();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 忽略候选并加入 deny 黑名单。
|
||||
*/
|
||||
const dismissCandidate = async (row: HotFaqCandidateRow): Promise<void> => {
|
||||
try {
|
||||
await dismissAdminFaqCandidate({ agent_id: row.agent_id, q_norm: row.q_norm });
|
||||
msg.success(t('admin.hotFaq.msg.dismissed'));
|
||||
await loadCandidates();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
const truncatePreview = (text: string): string => {
|
||||
const value = String(text || '').trim();
|
||||
if (value.length <= PREVIEW_MAX) return value;
|
||||
return `${value.slice(0, PREVIEW_MAX)}…`;
|
||||
};
|
||||
|
||||
return {
|
||||
items,
|
||||
filteredItems,
|
||||
agents,
|
||||
stats,
|
||||
rules,
|
||||
isLoading,
|
||||
isRefreshing,
|
||||
filterAgentId,
|
||||
searchKeyword,
|
||||
showRules,
|
||||
loadAll,
|
||||
loadCandidates,
|
||||
refreshCandidates,
|
||||
promoteCandidate,
|
||||
dismissCandidate,
|
||||
truncatePreview,
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* features/admin/modules/questions/composables/useQuestionsAdmin.ts
|
||||
* 常用问题管理:列表、创建、编辑、删除。
|
||||
* 常用问题 / FAQ 缓存管理:列表筛选、创建/编辑弹窗、删除。
|
||||
* 依赖:admin.api、question.types、useMessage。
|
||||
* 逻辑:QuestionsPage 调用本 composable 驱动表格与居中表单弹窗。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
deleteAdminQuickQuestion,
|
||||
@@ -13,11 +15,16 @@ import {
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';
|
||||
import {
|
||||
aliasesToText,
|
||||
buildQuestionPayload,
|
||||
createEmptyQuestionForm,
|
||||
type AdminQuickQuestionRow,
|
||||
type QuestionFormState,
|
||||
} from '@/features/admin/types/question.types';
|
||||
|
||||
const QUESTION_PREVIEW_MAX_LEN = 60;
|
||||
const ANSWER_PREVIEW_MAX_LEN = 48;
|
||||
|
||||
export function useQuestionsAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
@@ -25,14 +32,31 @@ export function useQuestionsAdmin() {
|
||||
const questions = ref<AdminQuickQuestionRow[]>([]);
|
||||
const agents = ref<AdminAgentOption[]>([]);
|
||||
const form = ref<QuestionFormState>(createEmptyQuestionForm());
|
||||
const isEditing = ref(false);
|
||||
const isLoading = ref(true);
|
||||
const isSaving = ref(false);
|
||||
const showFormModal = ref(false);
|
||||
const filterAgentId = ref<number | ''>('');
|
||||
const filterCacheOnly = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
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 (!keyword) return true;
|
||||
const haystack = [q.title, q.question, q.answer, ...(q.aliases || [])]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLowerCase();
|
||||
return haystack.includes(keyword);
|
||||
});
|
||||
});
|
||||
|
||||
const loadQuestions = async (): Promise<void> => {
|
||||
try {
|
||||
questions.value = await listAdminQuickQuestions();
|
||||
@@ -77,38 +101,88 @@ export function useQuestionsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置表单为空白状态。
|
||||
*/
|
||||
const resetForm = (): void => {
|
||||
form.value = createEmptyQuestionForm();
|
||||
isEditing.value = false;
|
||||
};
|
||||
|
||||
const editQuestion = (q: AdminQuickQuestionRow): void => {
|
||||
/** 打开「添加问题」弹窗并重置表单。 */
|
||||
const openCreateModal = (): void => {
|
||||
resetForm();
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开「编辑问题」弹窗并回填选中行数据。
|
||||
* @param q - 表格行数据
|
||||
*/
|
||||
const openEditModal = (q: AdminQuickQuestionRow): void => {
|
||||
form.value = {
|
||||
id: q.id,
|
||||
title: q.title,
|
||||
question: q.question,
|
||||
answer: q.answer || '',
|
||||
aliasesText: aliasesToText(q.aliases),
|
||||
cache_enabled: q.cache_enabled,
|
||||
is_enabled: q.is_enabled,
|
||||
agent_id: q.agent_id,
|
||||
sort_order: q.sort_order,
|
||||
expires_at: q.expires_at ? q.expires_at.slice(0, 16) : '',
|
||||
};
|
||||
isEditing.value = true;
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/** 关闭表单弹窗并重置表单。 */
|
||||
const closeFormModal = (): void => {
|
||||
showFormModal.value = false;
|
||||
resetForm();
|
||||
};
|
||||
|
||||
/**
|
||||
* 截断文本用于表格预览列。
|
||||
* @param text - 完整文本
|
||||
* @param maxLen - 最大长度
|
||||
* @returns 截断后的预览文本
|
||||
*/
|
||||
const truncatePreview = (text: string, maxLen: number): string => {
|
||||
const value = String(text || '').trim();
|
||||
if (value.length <= maxLen) return value;
|
||||
return `${value.slice(0, maxLen)}…`;
|
||||
};
|
||||
|
||||
const truncateQuestionPreview = (text: string): string =>
|
||||
truncatePreview(text, QUESTION_PREVIEW_MAX_LEN);
|
||||
|
||||
const truncateAnswerPreview = (text: string): string =>
|
||||
truncatePreview(text, ANSWER_PREVIEW_MAX_LEN);
|
||||
|
||||
/**
|
||||
* 校验并提交创建/更新请求,成功后刷新列表并关闭弹窗。
|
||||
*/
|
||||
const saveQuestion = async (): Promise<void> => {
|
||||
if (!form.value.title || !form.value.question || !form.value.agent_id) {
|
||||
msg.warning(t('admin.question.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
if (form.value.cache_enabled && !form.value.answer.trim()) {
|
||||
msg.warning(t('admin.question.msg.answerRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
const isEditing = Boolean(form.value.id);
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const url = isEditing.value
|
||||
const url = isEditing
|
||||
? `/api/admin/quick-questions/${form.value.id}`
|
||||
: '/api/admin/quick-questions';
|
||||
const method = isEditing.value ? 'PUT' : 'POST';
|
||||
const method = isEditing ? 'PUT' : 'POST';
|
||||
|
||||
await saveAdminQuickQuestion(url, method, form.value as Record<string, unknown>);
|
||||
await saveAdminQuickQuestion(url, method, buildQuestionPayload(form.value));
|
||||
await loadQuestions();
|
||||
resetForm();
|
||||
closeFormModal();
|
||||
msg.success(t('admin.question.msg.saved'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
@@ -131,19 +205,26 @@ export function useQuestionsAdmin() {
|
||||
|
||||
return {
|
||||
questions,
|
||||
filteredQuestions,
|
||||
agents,
|
||||
form,
|
||||
isEditing,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
filterAgentId,
|
||||
filterCacheOnly,
|
||||
searchKeyword,
|
||||
loadAll,
|
||||
resetForm,
|
||||
editQuestion,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveQuestion,
|
||||
deleteQuestion,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateQuestionPreview,
|
||||
truncateAnswerPreview,
|
||||
};
|
||||
}
|
||||
@@ -1,28 +1,76 @@
|
||||
/**
|
||||
* features/admin/types/question.types.ts
|
||||
* 常用问题管理类型。
|
||||
* 常用问题 / FAQ 缓存管理类型。
|
||||
*/
|
||||
|
||||
export interface AdminQuickQuestionRow {
|
||||
id: number;
|
||||
title: string;
|
||||
question: string;
|
||||
answer?: string | null;
|
||||
aliases?: string[];
|
||||
cache_enabled: boolean;
|
||||
is_enabled: boolean;
|
||||
hit_count: number;
|
||||
agent_id: number;
|
||||
agent_name?: string;
|
||||
sort_order: number;
|
||||
expires_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface QuestionFormState {
|
||||
id?: number;
|
||||
title: string;
|
||||
question: string;
|
||||
answer: string;
|
||||
aliasesText: string;
|
||||
cache_enabled: boolean;
|
||||
is_enabled: boolean;
|
||||
agent_id?: number;
|
||||
sort_order: number;
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
export const createEmptyQuestionForm = (): QuestionFormState => ({
|
||||
title: '',
|
||||
question: '',
|
||||
answer: '',
|
||||
aliasesText: '',
|
||||
cache_enabled: false,
|
||||
is_enabled: true,
|
||||
agent_id: undefined,
|
||||
sort_order: 0,
|
||||
expires_at: '',
|
||||
});
|
||||
|
||||
/** 将别名数组转为表单 textarea 文本(每行一条)。 */
|
||||
export const aliasesToText = (aliases?: string[] | null): string =>
|
||||
Array.isArray(aliases) ? aliases.filter(Boolean).join('\n') : '';
|
||||
|
||||
/** 将 textarea 文本解析为别名字符串数组。 */
|
||||
export const textToAliases = (text: string): string[] => {
|
||||
const seen = new Set<string>();
|
||||
const result: string[] = [];
|
||||
for (const line of String(text || '').split('\n')) {
|
||||
const value = line.trim();
|
||||
if (value && !seen.has(value)) {
|
||||
seen.add(value);
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/** 构建提交 API 的 payload。 */
|
||||
export const buildQuestionPayload = (form: QuestionFormState): Record<string, unknown> => ({
|
||||
title: form.title,
|
||||
question: form.question,
|
||||
answer: form.answer || null,
|
||||
aliases: textToAliases(form.aliasesText),
|
||||
cache_enabled: form.cache_enabled,
|
||||
is_enabled: form.is_enabled,
|
||||
agent_id: form.agent_id,
|
||||
sort_order: form.sort_order,
|
||||
expires_at: form.expires_at || null,
|
||||
});
|
||||
@@ -197,27 +197,115 @@
|
||||
},
|
||||
"question": {
|
||||
"title": "Common Questions",
|
||||
"subtitle": "Manage global quick questions for all users",
|
||||
"subtitle": "Manage global quick questions with optional FAQ cache to skip Dify on match",
|
||||
"formHint": "When FAQ cache is enabled, matched questions return the preset answer without consuming tokens.",
|
||||
"edit": "Edit Question",
|
||||
"add": "Add New Question",
|
||||
"noData": "No common questions configured.",
|
||||
"headers": {
|
||||
"title": "Title",
|
||||
"agent": "Agent",
|
||||
"content": "Match Query",
|
||||
"answer": "Preset Answer",
|
||||
"cache": "FAQ Cache",
|
||||
"hits": "Hits",
|
||||
"order": "Order",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"sections": {
|
||||
"basic": "Basic Info",
|
||||
"matching": "Query Matching",
|
||||
"cache": "FAQ Cached Answer"
|
||||
},
|
||||
"fields": {
|
||||
"title": "Title",
|
||||
"titlePlaceholder": "e.g. Write Report",
|
||||
"titlePlaceholder": "e.g. Working Hours",
|
||||
"targetAgent": "Target Agent",
|
||||
"sortOrder": "Sort Order",
|
||||
"content": "Question Content",
|
||||
"contentPlaceholder": "Enter the prompt content..."
|
||||
"content": "Canonical Query",
|
||||
"contentPlaceholder": "e.g. What time does work start?",
|
||||
"contentHelp": "Users sending this normalized query will hit the cache.",
|
||||
"aliases": "Alternative Phrasings",
|
||||
"aliasesPlaceholder": "One per line, e.g.:\nWhat time do we start?\nOffice hours?",
|
||||
"aliasesHelp": "Optional. Each line is an alternative phrasing that maps to the same answer.",
|
||||
"answer": "Preset Answer",
|
||||
"answerPlaceholder": "Full answer returned directly on cache hit…",
|
||||
"cacheEnabled": "Enable FAQ cache (skip Dify)",
|
||||
"isEnabled": "Show on workspace",
|
||||
"cacheHelp": "When enabled, matched queries return the preset answer below without calling Dify.",
|
||||
"expiresAt": "Expires At",
|
||||
"expiresAtHelp": "Optional. After expiry the entry will not match. Leave empty for no expiry."
|
||||
},
|
||||
"filters": {
|
||||
"search": "Search title, query or answer…",
|
||||
"allAgents": "All agents",
|
||||
"cacheOnly": "Cache enabled only",
|
||||
"resultCount": "{count} item(s)"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "Cached",
|
||||
"cacheOff": "Not cached",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} alias(es)"
|
||||
},
|
||||
"confirmDelete": "Are you sure you want to delete this question?",
|
||||
"actions": {
|
||||
"edit": "Edit",
|
||||
"delete": "Delete"
|
||||
},
|
||||
"confirmDelete": "Are you sure?",
|
||||
"msg": {
|
||||
"fillAll": "Please fill all fields"
|
||||
"fillAll": "Please fill in title, query and target agent",
|
||||
"answerRequired": "Preset answer is required when FAQ cache is enabled",
|
||||
"saved": "Saved successfully"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "Common Questions",
|
||||
"hotDiscovery": "Hot Discovery"
|
||||
}
|
||||
},
|
||||
"hotFaq": {
|
||||
"intro": "Discovers frequent queries from recent ChatLogs and stores candidates in PostgreSQL. Promote to FAQ after review.",
|
||||
"showRules": "View aggregation rules",
|
||||
"hideRules": "Hide rules",
|
||||
"redisUnavailable": "Redis is not configured or unavailable.",
|
||||
"noData": "No hot candidates yet. Click Refresh to aggregate from ChatLog.",
|
||||
"headers": {
|
||||
"query": "Hot Query",
|
||||
"agent": "Agent",
|
||||
"answer": "Suggested Answer",
|
||||
"asks": "7d Asks",
|
||||
"users": "Users",
|
||||
"tokens": "Avg Tokens",
|
||||
"dominance": "Consensus",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"filters": {
|
||||
"search": "Search query or answer…",
|
||||
"allAgents": "All agents"
|
||||
},
|
||||
"stats": {
|
||||
"summary": "{count} candidate(s), {asks} asks in 7 days"
|
||||
},
|
||||
"rules": {
|
||||
"selection": "Selection:",
|
||||
"answer": "Best answer:",
|
||||
"windowDays": "Last {n} days, tokens_used>0 (Dify only)",
|
||||
"minCount": "At least {n} asks per normalized query",
|
||||
"minUsers": "At least {n} distinct users"
|
||||
},
|
||||
"actions": {
|
||||
"refresh": "Refresh",
|
||||
"dryRun": "Preview",
|
||||
"promote": "Promote to FAQ",
|
||||
"dismiss": "Dismiss"
|
||||
},
|
||||
"msg": {
|
||||
"refreshed": "Hot FAQ aggregation completed",
|
||||
"dryRunDone": "Preview done: {promoted} group(s) would promote ({scanned} logs scanned)",
|
||||
"promoted": "Promoted to common question FAQ",
|
||||
"dismissed": "Hot candidate dismissed"
|
||||
}
|
||||
},
|
||||
"announcement": {
|
||||
|
||||
@@ -197,27 +197,115 @@
|
||||
},
|
||||
"question": {
|
||||
"title": "คำถามทั่วไป",
|
||||
"subtitle": "จัดการคำถามด่วนทั่วโลก",
|
||||
"subtitle": "จัดการคำถามด่วนทั่วโลก พร้อม FAQ cache เพื่อข้าม Dify เมื่อจับคู่ได้",
|
||||
"formHint": "เมื่อเปิด FAQ cache คำถามที่จับคู่ได้จะส่งคำตอบที่กำหนดไว้โดยไม่ใช้ Token",
|
||||
"edit": "แก้ไขคำถาม",
|
||||
"add": "เพิ่มคำถามใหม่",
|
||||
"noData": "ไม่มีคำถามทั่วไป",
|
||||
"headers": {
|
||||
"title": "หัวข้อ",
|
||||
"agent": "ตัวแทน",
|
||||
"content": "คำถามจับคู่",
|
||||
"answer": "คำตอบมาตรฐาน",
|
||||
"cache": "FAQ Cache",
|
||||
"hits": "จำนวนครั้ง",
|
||||
"order": "ลำดับ",
|
||||
"actions": "การกระทำ"
|
||||
},
|
||||
"sections": {
|
||||
"basic": "ข้อมูลพื้นฐาน",
|
||||
"matching": "การจับคู่คำถาม",
|
||||
"cache": "คำตอบ FAQ Cache"
|
||||
},
|
||||
"fields": {
|
||||
"title": "หัวข้อ",
|
||||
"titlePlaceholder": "เช่น เขียนรายงาน",
|
||||
"titlePlaceholder": "เช่น เวลาทำงาน",
|
||||
"targetAgent": "ตัวแทนเป้าหมาย",
|
||||
"sortOrder": "ลำดับการเรียง",
|
||||
"content": "เนื้อหาคำถาม",
|
||||
"contentPlaceholder": "กรอกเนื้อหาคำถาม..."
|
||||
"content": "คำถามมาตรฐาน",
|
||||
"contentPlaceholder": "เช่น บริษัทเปิดกี่โมง?",
|
||||
"contentHelp": "ผู้ใช้ที่ส่งคำถามที่ตรงกัน (หลัง normalize) จะโดน cache",
|
||||
"aliases": "คำถามทางเลือก",
|
||||
"aliasesPlaceholder": "หนึ่งบรรทัดต่อหนึ่งคำถาม เช่น:\nกี่โมงเข้างาน\nเวลาเข้างานคืออะไร",
|
||||
"aliasesHelp": "ไม่บังคับ แต่ละบรรทัดเป็นคำถามทางเลือกที่ได้คำตอบเดียวกัน",
|
||||
"answer": "คำตอบมาตรฐาน",
|
||||
"answerPlaceholder": "คำตอบเต็มที่ส่งกลับเมื่อ cache hit…",
|
||||
"cacheEnabled": "เปิด FAQ cache (ข้าม Dify)",
|
||||
"isEnabled": "แสดงในหน้า workspace",
|
||||
"cacheHelp": "เมื่อเปิดใช้ คำถามที่จับคู่ได้จะส่งคำตอบด้านล่างโดยไม่เรียก Dify",
|
||||
"expiresAt": "หมดอายุเมื่อ",
|
||||
"expiresAtHelp": "ไม่บังคับ หลังหมดอายุจะไม่จับคู่ ปล่อยว่างหากไม่มีวันหมดอายุ"
|
||||
},
|
||||
"filters": {
|
||||
"search": "ค้นหาหัวข้อ คำถาม หรือคำตอบ…",
|
||||
"allAgents": "ตัวแทนทั้งหมด",
|
||||
"cacheOnly": "เฉพาะที่เปิด cache",
|
||||
"resultCount": "{count} รายการ"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "Cache แล้ว",
|
||||
"cacheOff": "ยังไม่ cache",
|
||||
"disabled": "ปิดใช้งาน"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} คำถามทางเลือก"
|
||||
},
|
||||
"confirmDelete": "คุณแน่ใจหรือไม่ว่าต้องการลบคำถามนี้?",
|
||||
"actions": {
|
||||
"edit": "แก้ไข",
|
||||
"delete": "ลบ"
|
||||
},
|
||||
"confirmDelete": "คุณแน่ใจหรือไม่?",
|
||||
"msg": {
|
||||
"fillAll": "กรุณากรอกข้อมูลให้ครบถ้วน"
|
||||
"fillAll": "กรุณากรอกหัวข้อ คำถาม และตัวแทนเป้าหมาย",
|
||||
"answerRequired": "ต้องกรอกคำตอบมาตรฐานเมื่อเปิด FAQ cache",
|
||||
"saved": "บันทึกสำเร็จ"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "คำถามทั่วไป",
|
||||
"hotDiscovery": "ค้นพบ Hotspot"
|
||||
}
|
||||
},
|
||||
"hotFaq": {
|
||||
"intro": "ค้นหาคำถามที่พบบ่อยจาก ChatLog 7 วันล่าสุด เก็บในตาราง PostgreSQL แล้วส่งเสริมเป็น FAQ",
|
||||
"showRules": "ดูกฎการรวม",
|
||||
"hideRules": "ซ่อนกฎ",
|
||||
"redisUnavailable": "Redis ไม่พร้อมใช้งาน",
|
||||
"noData": "ยังไม่มี candidate กด Refresh เพื่อรวมจาก ChatLog",
|
||||
"headers": {
|
||||
"query": "คำถาม Hot",
|
||||
"agent": "ตัวแทน",
|
||||
"answer": "คำตอบแนะนำ",
|
||||
"asks": "ถาม 7 วัน",
|
||||
"users": "ผู้ใช้",
|
||||
"tokens": "Token เฉลี่ย",
|
||||
"dominance": "ความสอดคล้อง",
|
||||
"actions": "การกระทำ"
|
||||
},
|
||||
"filters": {
|
||||
"search": "ค้นหาคำถามหรือคำตอบ…",
|
||||
"allAgents": "ตัวแทนทั้งหมด"
|
||||
},
|
||||
"stats": {
|
||||
"summary": "{count} candidate, ถามรวม {asks} ครั้งใน 7 วัน"
|
||||
},
|
||||
"rules": {
|
||||
"selection": "การเลือก hotspot:",
|
||||
"answer": "คำตอบที่ดีที่สุด:",
|
||||
"windowDays": "สถิติ {n} วันล่าสุด tokens_used>0",
|
||||
"minCount": "ถามอย่างน้อย {n} ครั้งต่อคำถาม normalize",
|
||||
"minUsers": "ผู้ใช้ต่างกันอย่างน้อย {n} คน"
|
||||
},
|
||||
"actions": {
|
||||
"refresh": "รีเฟรช",
|
||||
"dryRun": "ดูตัวอย่าง",
|
||||
"promote": "ส่งเสริงเป็น FAQ",
|
||||
"dismiss": "ละเว้น"
|
||||
},
|
||||
"msg": {
|
||||
"refreshed": "รวม hotspot FAQ เสร็จแล้ว",
|
||||
"dryRunDone": "ดูตัวอย่างเสร็จ: promote {promoted} กลุ่ม (สแกน {scanned} log)",
|
||||
"promoted": "ส่งเสริงเป็นคำถามทั่วไป FAQ แล้ว",
|
||||
"dismissed": "ละเว้น hotspot แล้ว"
|
||||
}
|
||||
},
|
||||
"announcement": {
|
||||
|
||||
@@ -198,27 +198,115 @@
|
||||
},
|
||||
"question": {
|
||||
"title": "常用问题",
|
||||
"subtitle": "管理全局常用问题",
|
||||
"subtitle": "管理全局常用问题,可配置标准答案并启用 FAQ 缓存,优先命中、跳过 Dify",
|
||||
"formHint": "启用 FAQ 缓存后,用户提问匹配成功时将直接返回标准答案,不消耗 Token。",
|
||||
"edit": "编辑问题",
|
||||
"add": "添加问题",
|
||||
"noData": "暂无常用问题配置",
|
||||
"headers": {
|
||||
"title": "标题",
|
||||
"agent": "所属应用",
|
||||
"content": "匹配问句",
|
||||
"answer": "标准答案",
|
||||
"cache": "FAQ 缓存",
|
||||
"hits": "命中",
|
||||
"order": "排序",
|
||||
"actions": "操作"
|
||||
},
|
||||
"sections": {
|
||||
"basic": "基础信息",
|
||||
"matching": "问句匹配",
|
||||
"cache": "FAQ 缓存答案"
|
||||
},
|
||||
"fields": {
|
||||
"title": "标题",
|
||||
"titlePlaceholder": "例如:写日报",
|
||||
"titlePlaceholder": "例如:上班时间",
|
||||
"targetAgent": "目标应用",
|
||||
"sortOrder": "排序",
|
||||
"content": "问题内容",
|
||||
"contentPlaceholder": "请输入完整的问题提示词..."
|
||||
"content": "标准问句",
|
||||
"contentPlaceholder": "例如:公司几点上班?",
|
||||
"contentHelp": "用户发送与此问句一致(归一化后)的文本时将命中缓存。",
|
||||
"aliases": "同义问法",
|
||||
"aliasesPlaceholder": "每行一条,例如:\n几点上班\n上班时间是什么",
|
||||
"aliasesHelp": "可选。每行填写一种同义问法,命中后同样返回标准答案。",
|
||||
"answer": "标准答案",
|
||||
"answerPlaceholder": "填写命中后直接返回给用户的完整回答…",
|
||||
"cacheEnabled": "启用 FAQ 缓存(跳过 Dify)",
|
||||
"isEnabled": "在前台展示",
|
||||
"cacheHelp": "开启后,匹配成功的问题将直接返回下方标准答案,不再调用 Dify。",
|
||||
"expiresAt": "过期时间",
|
||||
"expiresAtHelp": "可选。到期后不再命中缓存,留空表示长期有效。"
|
||||
},
|
||||
"filters": {
|
||||
"search": "搜索标题、问句或答案…",
|
||||
"allAgents": "全部应用",
|
||||
"cacheOnly": "仅显示已启用缓存",
|
||||
"resultCount": "共 {count} 条"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "已缓存",
|
||||
"cacheOff": "未缓存",
|
||||
"disabled": "已停用"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} 条同义问法"
|
||||
},
|
||||
"confirmDelete": "确定删除该常用问题吗?",
|
||||
"actions": {
|
||||
"edit": "编辑",
|
||||
"delete": "删除"
|
||||
},
|
||||
"confirmDelete": "确定删除吗?",
|
||||
"msg": {
|
||||
"fillAll": "请填写所有必填项"
|
||||
"fillAll": "请填写标题、问句和目标应用",
|
||||
"answerRequired": "启用 FAQ 缓存时必须填写标准答案",
|
||||
"saved": "保存成功"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "常用问题",
|
||||
"hotDiscovery": "热点发现"
|
||||
}
|
||||
},
|
||||
"hotFaq": {
|
||||
"intro": "系统从近 7 天 ChatLog 自动发现高频问句,写入数据库候选表;审核后可「晋升为 FAQ」,启用常用问题缓存。",
|
||||
"showRules": "查看聚合规则",
|
||||
"hideRules": "收起规则",
|
||||
"redisUnavailable": "Redis 未配置或不可用,无法存储热点候选。请配置 REDIS_URL 后重试。",
|
||||
"noData": "暂无热点候选,可点击「刷新聚合」从 ChatLog 统计。",
|
||||
"headers": {
|
||||
"query": "热点问句",
|
||||
"agent": "所属应用",
|
||||
"answer": "推荐答案",
|
||||
"asks": "7日提问",
|
||||
"users": "独立用户",
|
||||
"tokens": "均Token",
|
||||
"dominance": "答案一致率",
|
||||
"actions": "操作"
|
||||
},
|
||||
"filters": {
|
||||
"search": "搜索问句或答案…",
|
||||
"allAgents": "全部应用"
|
||||
},
|
||||
"stats": {
|
||||
"summary": "共 {count} 条候选,7日合计 {asks} 次提问"
|
||||
},
|
||||
"rules": {
|
||||
"selection": "热点选取:",
|
||||
"answer": "最佳答案:",
|
||||
"windowDays": "统计近 {n} 天且 tokens_used>0 的 Dify 对话",
|
||||
"minCount": "同一归一化问句至少 {n} 次提问",
|
||||
"minUsers": "至少 {n} 个不同用户提问"
|
||||
},
|
||||
"actions": {
|
||||
"refresh": "刷新聚合",
|
||||
"dryRun": "预览统计",
|
||||
"promote": "晋升为 FAQ",
|
||||
"dismiss": "忽略"
|
||||
},
|
||||
"msg": {
|
||||
"refreshed": "热点聚合已完成",
|
||||
"dryRunDone": "预览完成:扫描记录参与统计,晋升 {promoted} 组(扫描 {scanned} 条日志)",
|
||||
"promoted": "已晋升为常用问题 FAQ",
|
||||
"dismissed": "已忽略该热点"
|
||||
}
|
||||
},
|
||||
"announcement": {
|
||||
|
||||
@@ -197,27 +197,115 @@
|
||||
},
|
||||
"question": {
|
||||
"title": "常用問題",
|
||||
"subtitle": "管理全局常用問題",
|
||||
"subtitle": "管理全局常用問題,可配置標準答案並啟用 FAQ 快取,優先命中、跳過 Dify",
|
||||
"formHint": "啟用 FAQ 快取後,使用者提問匹配成功時將直接返回標準答案,不消耗 Token。",
|
||||
"edit": "編輯問題",
|
||||
"add": "添加問題",
|
||||
"noData": "暫無常用問題配置",
|
||||
"headers": {
|
||||
"title": "標題",
|
||||
"agent": "所屬應用",
|
||||
"content": "匹配問句",
|
||||
"answer": "標準答案",
|
||||
"cache": "FAQ 快取",
|
||||
"hits": "命中",
|
||||
"order": "排序",
|
||||
"actions": "操作"
|
||||
},
|
||||
"sections": {
|
||||
"basic": "基礎資訊",
|
||||
"matching": "問句匹配",
|
||||
"cache": "FAQ 快取答案"
|
||||
},
|
||||
"fields": {
|
||||
"title": "標題",
|
||||
"titlePlaceholder": "例如:寫日報",
|
||||
"titlePlaceholder": "例如:上班時間",
|
||||
"targetAgent": "目標應用",
|
||||
"sortOrder": "排序",
|
||||
"content": "問題內容",
|
||||
"contentPlaceholder": "請輸入完整的問題提示詞..."
|
||||
"content": "標準問句",
|
||||
"contentPlaceholder": "例如:公司幾點上班?",
|
||||
"contentHelp": "使用者發送與此問句一致(歸一化後)的文本時將命中快取。",
|
||||
"aliases": "同義問法",
|
||||
"aliasesPlaceholder": "每行一條,例如:\n幾點上班\n上班時間是什麼",
|
||||
"aliasesHelp": "可選。每行填寫一種同義問法,命中後同樣返回標準答案。",
|
||||
"answer": "標準答案",
|
||||
"answerPlaceholder": "填寫命中後直接返回給使用者的完整回答…",
|
||||
"cacheEnabled": "啟用 FAQ 快取(跳過 Dify)",
|
||||
"isEnabled": "在前台展示",
|
||||
"cacheHelp": "開啟後,匹配成功的問題將直接返回下方標準答案,不再呼叫 Dify。",
|
||||
"expiresAt": "過期時間",
|
||||
"expiresAtHelp": "可選。到期後不再命中快取,留空表示長期有效。"
|
||||
},
|
||||
"filters": {
|
||||
"search": "搜尋標題、問句或答案…",
|
||||
"allAgents": "全部應用",
|
||||
"cacheOnly": "僅顯示已啟用快取",
|
||||
"resultCount": "共 {count} 條"
|
||||
},
|
||||
"badges": {
|
||||
"cacheOn": "已快取",
|
||||
"cacheOff": "未快取",
|
||||
"disabled": "已停用"
|
||||
},
|
||||
"labels": {
|
||||
"aliases": "{count} 條同義問法"
|
||||
},
|
||||
"confirmDelete": "確定刪除該常用問題嗎?",
|
||||
"actions": {
|
||||
"edit": "編輯",
|
||||
"delete": "刪除"
|
||||
},
|
||||
"confirmDelete": "確定刪除嗎?",
|
||||
"msg": {
|
||||
"fillAll": "請填寫所有必填項"
|
||||
"fillAll": "請填寫標題、問句和目標應用",
|
||||
"answerRequired": "啟用 FAQ 快取時必須填寫標準答案",
|
||||
"saved": "儲存成功"
|
||||
},
|
||||
"tabs": {
|
||||
"manual": "常用問題",
|
||||
"hotDiscovery": "熱點發現"
|
||||
}
|
||||
},
|
||||
"hotFaq": {
|
||||
"intro": "系統從近 7 天 ChatLog 自動發現高頻問句,寫入資料庫候選表;審核後可「晉升為 FAQ」。",
|
||||
"showRules": "查看聚合規則",
|
||||
"hideRules": "收起規則",
|
||||
"redisUnavailable": "Redis 未配置或不可用,無法儲存熱點候選。",
|
||||
"noData": "暫無熱點候選,可點擊「刷新聚合」。",
|
||||
"headers": {
|
||||
"query": "熱點問句",
|
||||
"agent": "所屬應用",
|
||||
"answer": "推薦答案",
|
||||
"asks": "7日提問",
|
||||
"users": "獨立用戶",
|
||||
"tokens": "均Token",
|
||||
"dominance": "答案一致率",
|
||||
"actions": "操作"
|
||||
},
|
||||
"filters": {
|
||||
"search": "搜尋問句或答案…",
|
||||
"allAgents": "全部應用"
|
||||
},
|
||||
"stats": {
|
||||
"summary": "共 {count} 條候選,7日合計 {asks} 次提問"
|
||||
},
|
||||
"rules": {
|
||||
"selection": "熱點選取:",
|
||||
"answer": "最佳答案:",
|
||||
"windowDays": "統計近 {n} 天且 tokens_used>0 的 Dify 對話",
|
||||
"minCount": "同一歸一化問句至少 {n} 次提問",
|
||||
"minUsers": "至少 {n} 個不同用戶提問"
|
||||
},
|
||||
"actions": {
|
||||
"refresh": "刷新聚合",
|
||||
"dryRun": "預覽統計",
|
||||
"promote": "晉升為 FAQ",
|
||||
"dismiss": "忽略"
|
||||
},
|
||||
"msg": {
|
||||
"refreshed": "熱點聚合已完成",
|
||||
"dryRunDone": "預覽完成:晉升 {promoted} 組(掃描 {scanned} 條日誌)",
|
||||
"promoted": "已晉升為常用問題 FAQ",
|
||||
"dismissed": "已忽略該熱點"
|
||||
}
|
||||
},
|
||||
"announcement": {
|
||||
|
||||
Reference in new issue
Block a user