fix(chat): 智能体支持配置分级显示
This commit is contained in:
1 parent
a451951e7a
commit
70d7435b5f
27 files changed
+645
-76
No files matched your search
@@ -16,6 +16,14 @@ import AgentPermissionModal from './components/AgentPermissionModal.vue';
|
||||
import AgentTestModal from './components/AgentTestModal.vue';
|
||||
import { useAgentsAdmin } from './composables/useAgentsAdmin';
|
||||
|
||||
const formatAgentCategory = (agent: { extra_config?: Record<string, unknown> }) => {
|
||||
const extra = agent.extra_config && typeof agent.extra_config === 'object' ? agent.extra_config : {};
|
||||
const category = String(extra.category || '').trim();
|
||||
const subCategory = String(extra.sub_category || '').trim();
|
||||
if (category && subCategory) return `${category} / ${subCategory}`;
|
||||
return category || subCategory || '—';
|
||||
};
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
@@ -111,8 +119,9 @@ onMounted(() => {
|
||||
</div>
|
||||
<table v-else class="admin-table table-fixed w-full">
|
||||
<colgroup>
|
||||
<col class="w-72" />
|
||||
<col class="w-64" />
|
||||
<col class="w-[4.5rem]" />
|
||||
<col class="w-36" />
|
||||
<col class="w-32" />
|
||||
<col class="w-[5.5rem]" />
|
||||
<col />
|
||||
@@ -121,6 +130,7 @@ onMounted(() => {
|
||||
<tr>
|
||||
<th class="px-4 py-4 text-sm">{{ t('admin.agent.headers.name') }}</th>
|
||||
<th class="px-2 py-4 text-sm">{{ t('admin.agent.headers.type') }}</th>
|
||||
<th class="px-2 py-4 text-sm">{{ t('admin.agent.headers.category') }}</th>
|
||||
<th class="px-2 py-4 text-sm">{{ t('admin.agent.headers.config') }}</th>
|
||||
<th class="px-2 py-4 text-sm">{{ t('admin.agent.headers.status') }}</th>
|
||||
<th class="px-4 py-4 text-sm text-right">{{ t('admin.agent.headers.actions') }}</th>
|
||||
@@ -143,6 +153,9 @@ onMounted(() => {
|
||||
{{ agent.type }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-2 py-5 text-xs text-secondary max-w-36 truncate" :title="formatAgentCategory(agent)">
|
||||
{{ formatAgentCategory(agent) }}
|
||||
</td>
|
||||
<td class="px-2 py-5 font-mono text-xs text-muted max-w-32 truncate">
|
||||
<span v-if="agent.type === 'api'" class="truncate" :title="String(agent.dify_app_id)">
|
||||
<span class="text-muted">{{ t('admin.agent.idLabel') }}:</span> {{ agent.dify_app_id }}
|
||||
|
||||
@@ -107,6 +107,41 @@ const { t } = useI18n();
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-4 text-xs font-bold uppercase tracking-wider text-muted">{{ t('admin.agent.sections.category') }}</div>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.category') }}</label>
|
||||
<input
|
||||
v-model="form.category"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.categoryPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.subCategory') }}</label>
|
||||
<input
|
||||
v-model="form.sub_category"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.subCategoryPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.fields.sortOrder') }}</label>
|
||||
<input
|
||||
v-model.number="form.sort_order"
|
||||
type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
class="w-full input-field text-sm"
|
||||
:placeholder="t('admin.agent.fields.sortOrderPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">常见问题</label>
|
||||
|
||||
@@ -91,6 +91,28 @@ const applyToolRunProgressToExtra = (extraConfig: Record<string, unknown>, form:
|
||||
delete extraConfig.tool_run_progress;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将表单分类字段写入 extra_config(P1 轻量方案)。
|
||||
*/
|
||||
const applyAgentCategoryToExtra = (extraConfig: Record<string, unknown>, form: AgentFormState): void => {
|
||||
const category = String(form.category || '').trim();
|
||||
const subCategory = String(form.sub_category || '').trim();
|
||||
const sortRaw = Number(form.sort_order);
|
||||
const sortOrder = Number.isFinite(sortRaw) && sortRaw >= 0 ? Math.floor(sortRaw) : 0;
|
||||
|
||||
if (category) {
|
||||
extraConfig.category = category;
|
||||
} else {
|
||||
delete extraConfig.category;
|
||||
}
|
||||
if (subCategory) {
|
||||
extraConfig.sub_category = subCategory;
|
||||
} else {
|
||||
delete extraConfig.sub_category;
|
||||
}
|
||||
extraConfig.sort_order = sortOrder;
|
||||
};
|
||||
|
||||
export function useAgentsAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
@@ -177,6 +199,11 @@ export function useAgentsAdmin() {
|
||||
suggested_questions_style: agent.extra_config?.suggested_questions_style === 'styled' ? 'styled' : 'plain',
|
||||
suggested_questions: normalizeSuggestedQuestions(agent.extra_config?.suggested_questions),
|
||||
is_active: agent.is_active,
|
||||
category: String(extra.category || ''),
|
||||
sub_category: String(extra.sub_category || ''),
|
||||
sort_order: Number(extra.sort_order) >= 0 && Number.isFinite(Number(extra.sort_order))
|
||||
? Math.floor(Number(extra.sort_order))
|
||||
: 0,
|
||||
...toolRunProgress,
|
||||
};
|
||||
isEditing.value = true;
|
||||
@@ -252,6 +279,7 @@ export function useAgentsAdmin() {
|
||||
} else {
|
||||
applyToolRunProgressToExtra(extra_config, { ...form.value, tool_run_progress_enabled: false });
|
||||
}
|
||||
applyAgentCategoryToExtra(extra_config, form.value);
|
||||
|
||||
try {
|
||||
const editingId = isEditing.value ? Number(form.value.id) : null;
|
||||
|
||||
Reference in new issue
Block a user