插件管理新增群状态按钮与群开关明细弹窗,后端补充按插件查询群启用状态接口

This commit is contained in:
liuwei
2026-04-20 14:09:00 +08:00
parent f18e4329d2
commit 634fb4d67e
2 changed files with 215 additions and 1 deletions

View File

@@ -93,6 +93,9 @@
<el-button size="mini" type="info" plain @click="showPluginInfo(scope.row)">
详情
</el-button>
<el-button size="mini" type="warning" plain @click="showPluginGroupStatus(scope.row)">
群状态
</el-button>
</div>
</template>
</el-table-column>
@@ -148,6 +151,75 @@
</el-descriptions>
</div>
</el-dialog>
<el-dialog title="插件群状态" :visible.sync="pluginGroupStatusVisible" width="72%" top="5vh">
<div class="plugin-group-status-dialog" v-loading="groupStatusLoading">
<div v-if="pluginGroupStatusData" class="group-status-header">
<div class="group-status-title">
{% raw %}{{ pluginGroupStatusData.plugin_name || '未知插件' }}{% endraw %}
<span class="group-status-subtitle">
{% raw %}{{ `共 ${pluginGroupStatusData.total_group_count || 0} 个群` }}{% endraw %}
</span>
</div>
<div class="group-status-summary">
<el-tag size="small" type="success">已开启 {% raw %}{{ pluginGroupStatusData.enabled_count || 0 }}{% endraw %}</el-tag>
<el-tag size="small" type="info">未开启 {% raw %}{{ pluginGroupStatusData.disabled_count || 0 }}{% endraw %}</el-tag>
</div>
</div>
<el-alert
v-if="pluginGroupStatusData && !pluginGroupStatusData.supports_group_switch"
title="该插件未接入群级开关能力,当前仅展示群列表,状态默认为未开启。"
type="warning"
:closable="false"
show-icon
class="group-status-alert">
</el-alert>
<el-row :gutter="16" v-if="pluginGroupStatusData">
<el-col :span="12">
<el-card shadow="never" class="group-status-card">
<div slot="header" class="group-status-card-header">
<span>已开启群</span>
<el-tag size="mini" type="success">{% raw %}{{ pluginGroupStatusData.enabled_count || 0 }}{% endraw %}</el-tag>
</div>
<el-table
:data="pluginGroupStatusData.enabled_groups || []"
size="mini"
max-height="420"
empty-text="暂无已开启群">
<el-table-column label="群名称" min-width="170">
<template slot-scope="scope">
{% raw %}{{ scope.row.group_name || scope.row.group_id }}{% endraw %}
</template>
</el-table-column>
<el-table-column prop="group_id" label="群ID" min-width="210" show-overflow-tooltip></el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="12">
<el-card shadow="never" class="group-status-card">
<div slot="header" class="group-status-card-header">
<span>未开启群</span>
<el-tag size="mini" type="info">{% raw %}{{ pluginGroupStatusData.disabled_count || 0 }}{% endraw %}</el-tag>
</div>
<el-table
:data="pluginGroupStatusData.disabled_groups || []"
size="mini"
max-height="420"
empty-text="暂无未开启群">
<el-table-column label="群名称" min-width="170">
<template slot-scope="scope">
{% raw %}{{ scope.row.group_name || scope.row.group_id }}{% endraw %}
</template>
</el-table-column>
<el-table-column prop="group_id" label="群ID" min-width="210" show-overflow-tooltip></el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</div>
</el-dialog>
</div>
{% endblock %}
@@ -165,7 +237,10 @@
isEditingConfig: false,
editedConfig: '',
configError: '',
configFormat: 'toml'
configFormat: 'toml',
pluginGroupStatusVisible: false,
groupStatusLoading: false,
pluginGroupStatusData: null
}
},
computed: {
@@ -344,6 +419,43 @@
console.error('获取插件详情出错:', error);
this.$message.error('获取插件详情出错');
});
},
showPluginGroupStatus(plugin) {
// 打开弹窗前先进入加载态,避免用户在慢接口场景下看到旧数据。
this.pluginGroupStatusVisible = true;
this.groupStatusLoading = true;
this.pluginGroupStatusData = null;
// 统一使用插件模块名查询,和启用/禁用/重载接口参数保持一致。
axios.get('/api/plugins/group_status', {
params: {
plugin_name: plugin.module_name
}
})
.then(response => {
if (response.data.success) {
// 接口返回已按“已开启/未开启”拆分好,前端仅做展示。
this.pluginGroupStatusData = response.data.data || {
enabled_groups: [],
disabled_groups: [],
enabled_count: 0,
disabled_count: 0,
total_group_count: 0,
supports_group_switch: false
};
} else {
this.$message.error(response.data.message || '获取插件群状态失败');
this.pluginGroupStatusVisible = false;
}
})
.catch(error => {
console.error('获取插件群状态出错:', error);
this.$message.error('获取插件群状态出错');
this.pluginGroupStatusVisible = false;
})
.finally(() => {
this.groupStatusLoading = false;
});
}
}
});
@@ -421,5 +533,26 @@
.config-actions { margin-bottom: 10px; display: flex; gap: 10px; }
.config-editor { font-family: monospace; font-size: 12px; }
.config-error { color: #ef4444; font-size: 12px; margin-top: 5px; }
.plugin-group-status-dialog { min-height: 240px; }
.group-status-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
gap: 10px;
flex-wrap: wrap;
}
.group-status-title { font-size: 16px; font-weight: 600; color: #0f172a; }
.group-status-subtitle { margin-left: 8px; font-size: 12px; color: #64748b; font-weight: 500; }
.group-status-summary { display: flex; align-items: center; gap: 8px; }
.group-status-alert { margin-bottom: 12px; }
.group-status-card { border-radius: 12px; }
.group-status-card-header {
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 600;
color: #334155;
}
</style>
{% endblock %}