Reapply "后台插件管理页展示前后台执行方式"

This reverts commit 9d2054a83d.
This commit is contained in:
Liu
2026-05-01 12:45:31 +08:00
parent 3141550bbb
commit 6bee4b86f5
2 changed files with 264 additions and 4 deletions

View File

@@ -253,6 +253,18 @@
</div>
</template>
</el-table-column>
<el-table-column label="执行方式" width="180" align="center">
<template slot-scope="scope">
<div class="governance-cell">
<el-tag :type="dispatchModeTagType((scope.row.dispatch_summary || {}).mode)" size="small">
{% raw %}{{ (scope.row.dispatch_summary || {}).label || dispatchModeLabel(scope.row.dispatch_mode) }}{% endraw %}
</el-tag>
<div class="governance-note">
{% raw %}{{ buildDispatchSummaryBrief(scope.row) }}{% endraw %}
</div>
</div>
</template>
</el-table-column>
<el-table-column label="命令 / 权限" min-width="180">
<template slot-scope="scope">
<div class="entity-subtitle">
@@ -315,6 +327,10 @@
<span>成功率:{% raw %}{{ formatPercent((plugin.execution_summary || {}).success_rate) }}{% endraw %}</span>
<span>耗时:{% raw %}{{ formatDurationMs((plugin.execution_summary || {}).last_process_time_ms) }}{% endraw %}</span>
</div>
<div class="mobile-plugin-card__meta">
<span>执行方式:{% raw %}{{ (plugin.dispatch_summary || {}).label || dispatchModeLabel(plugin.dispatch_mode) }}{% endraw %}</span>
<span>{% raw %}{{ buildDispatchSummaryBrief(plugin) }}{% endraw %}</span>
</div>
<div class="mobile-plugin-card__desc">
{% raw %}{{ plugin.description || '暂无描述' }}{% endraw %}
</div>
@@ -367,6 +383,14 @@
<el-descriptions-item label="命令前缀" :span="1" v-if="selectedPlugin.command_prefix !== undefined">
{% raw %}{{ selectedPlugin.command_prefix || '无' }}{% endraw %}
</el-descriptions-item>
<el-descriptions-item label="执行方式" :span="1">
<el-tag :type="dispatchModeTagType((selectedPlugin.dispatch_summary || {}).mode)" size="small">
{% raw %}{{ (selectedPlugin.dispatch_summary || {}).label || dispatchModeLabel(selectedPlugin.dispatch_mode) }}{% endraw %}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="分发说明" :span="2">
{% raw %}{{ buildDispatchSummaryText(selectedPlugin) }}{% endraw %}
</el-descriptions-item>
<el-descriptions-item label="描述" :span="2">{% raw %}{{ selectedPlugin.description }}{% endraw %}</el-descriptions-item>
<el-descriptions-item label="能力类型" :span="2" v-if="selectedPlugin.plugin_types && selectedPlugin.plugin_types.length > 0">
<div class="command-tags">
@@ -445,6 +469,24 @@
</el-tag>
</div>
</el-descriptions-item>
<el-descriptions-item
label="命令分发预览"
:span="2"
v-if="selectedPlugin.dispatch_summary && selectedPlugin.dispatch_summary.command_modes && selectedPlugin.dispatch_summary.command_modes.length > 0">
<div class="command-tags">
<el-tag
v-for="dispatchCommand in selectedPlugin.dispatch_summary.command_modes"
:key="`dispatch-${dispatchCommand.command}`"
:type="dispatchModeTagType(dispatchCommand.mode)"
size="mini"
effect="plain">
{% raw %}{{ `${dispatchCommand.command} · ${dispatchCommand.label}` }}{% endraw %}
</el-tag>
</div>
<div class="entity-subtitle" style="margin-top: 8px;" v-if="(selectedPlugin.dispatch_summary.preview_failed_count || 0) > 0">
{% raw %}{{ `另有 ${selectedPlugin.dispatch_summary.preview_failed_count} 条预览样本无法识别,可能依赖更完整的运行时上下文。` }}{% endraw %}
</div>
</el-descriptions-item>
<el-descriptions-item label="配置概览" :span="2" v-if="selectedPlugin.config_overview">
<div class="config-overview-grid">
<div class="config-overview-item">
@@ -891,6 +933,50 @@
};
return mapping[normalizedLevel] || '暂无样本';
},
dispatchModeTagType(mode) {
const normalizedMode = String(mode || '').toLowerCase();
if (normalizedMode === 'sync') return 'success';
if (normalizedMode === 'background') return 'warning';
if (normalizedMode === 'mixed') return '';
return 'info';
},
dispatchModeLabel(mode) {
const normalizedMode = String(mode || '').toLowerCase();
const mapping = {
sync: '前台同步',
background: '后台任务',
mixed: '混合模式',
non_message: '非消息插件',
unknown: '未知'
};
return mapping[normalizedMode] || '未知';
},
buildDispatchSummaryBrief(plugin) {
const dispatchSummary = (plugin && plugin.dispatch_summary) || {};
const mode = String(dispatchSummary.mode || plugin.dispatch_mode || '').toLowerCase();
const syncCount = Number(dispatchSummary.sync_command_count || 0);
const backgroundCount = Number(dispatchSummary.background_command_count || 0);
if (mode === 'mixed') {
return `前台 ${syncCount} / 后台 ${backgroundCount}`;
}
if (mode === 'background') {
return backgroundCount > 0 ? `后台命令 ${backgroundCount}` : '默认后台执行';
}
if (mode === 'sync') {
return syncCount > 0 ? `前台命令 ${syncCount}` : '默认前台执行';
}
if (mode === 'non_message') {
return '不参与消息链路';
}
return '暂未识别';
},
buildDispatchSummaryText(plugin) {
const dispatchSummary = (plugin && plugin.dispatch_summary) || {};
if (dispatchSummary.description) {
return dispatchSummary.description;
}
return this.dispatchModeLabel(dispatchSummary.mode || plugin.dispatch_mode);
},
governanceIssueSummary(plugin) {
const errorCount = Number((plugin && plugin.governance_error_count) || 0);
const warningCount = Number((plugin && plugin.governance_warning_count) || 0);