完善通讯录群详情展示:补齐群公告/群主/群管理信息
变更项: 1. 数据层新增群资料聚合查询,直接复用 is_owner/is_admin 字段返回群主与管理员列表。 2. 同步群信息时兼容提取群公告并落库,历史库启动时自动补齐 chat_room_announcement 字段。 3. 新增 /contacts/api/group_profile/<roomid> 接口,统一返回群公告、群主、管理员、成员数。 4. 通讯录群详情弹窗新增群主/群成员数/群管理/群公告展示,并在打开详情时自动加载。 5. 补充群成员精简查询头像字段,更新初始化 SQL 中 t_chatrooms 公告字段定义。
This commit is contained in:
@@ -427,6 +427,23 @@ def api_group_members(roomid):
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@contacts_bp.route('/api/group_profile/<roomid>', methods=['GET'])
|
||||
@login_required
|
||||
def api_group_profile(roomid):
|
||||
"""获取指定群的资料信息(群公告、群主、管理员、成员数)"""
|
||||
try:
|
||||
server = current_app.dashboard_server
|
||||
# 直接复用联系人库中已有身份字段,按群聚合成页面可展示的资料结构。
|
||||
profile = server.contact_db.get_chatroom_profile(roomid)
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": profile
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"获取群资料失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@contacts_bp.route('/api/group_member_context/<roomid>/<wxid>', methods=['GET'])
|
||||
@login_required
|
||||
def api_group_member_context(roomid, wxid):
|
||||
|
||||
@@ -187,6 +187,31 @@
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="群ID">{% raw %}{{ currentGroup.wxid }}{% endraw %}</el-descriptions-item>
|
||||
<el-descriptions-item label="群名称">{% raw %}{{ currentGroup.name }}{% endraw %}</el-descriptions-item>
|
||||
<el-descriptions-item label="群主">
|
||||
<span>{% raw %}{{ currentGroupProfile.owner_name || currentGroupProfile.owner_wxid || '未知' }}{% endraw %}</span>
|
||||
<span class="detail-inline-note" v-if="currentGroupProfile.owner_wxid && currentGroupProfile.owner_name && currentGroupProfile.owner_name !== currentGroupProfile.owner_wxid">
|
||||
({% raw %}{{ currentGroupProfile.owner_wxid }}{% endraw %})
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="群成员数">
|
||||
{% raw %}{{ currentGroupProfile.member_count || 0 }}{% endraw %}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="群管理">
|
||||
<div class="feature-chip-list">
|
||||
<el-tag
|
||||
v-for="admin in (currentGroupProfile.admins || [])"
|
||||
:key="admin.wxid"
|
||||
size="small"
|
||||
type="warning"
|
||||
effect="plain">
|
||||
{% raw %}{{ admin.display_name }}{% endraw %}
|
||||
</el-tag>
|
||||
<span v-if="!(currentGroupProfile.admins || []).length" class="empty-inline">暂无管理员数据</span>
|
||||
</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="群公告">
|
||||
<span class="group-announcement">{% raw %}{{ currentGroupProfile.announcement || '暂无群公告' }}{% endraw %}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="机器人状态">
|
||||
<el-tag :type="currentGroup.robot_status === 'enabled' ? 'success' : 'info'">
|
||||
{% raw %}{{ currentGroup.robot_status === 'enabled' ? '已启用' : '未启用' }}{% endraw %}
|
||||
@@ -751,6 +776,8 @@
|
||||
managedGroupMap: {},
|
||||
groupPermissions: [],
|
||||
groupPermissionsLoading: false,
|
||||
// 当前群基础资料:用于展示群主、群公告、管理员、成员数等信息。
|
||||
currentGroupProfile: { owner_wxid: '', owner_name: '', announcement: '', member_count: 0, admin_count: 0, admins: [] },
|
||||
groupInsight: null,
|
||||
groupInsightLoading: false,
|
||||
groupMembersList: [], groupMembersCurrentPage: 1, groupMembersPageSize: 10, groupMemberSearchQuery: '', groupMembersLoading: false,
|
||||
@@ -866,6 +893,8 @@
|
||||
viewGroupDetails(group) {
|
||||
this.currentGroup = { ...group };
|
||||
this.groupDetailDialogVisible = true;
|
||||
// 进入群详情时先加载群资料,保证群主/公告/管理员信息第一时间可见。
|
||||
this.loadGroupProfile(group.wxid);
|
||||
this.loadGroupMembers(group.wxid);
|
||||
this.loadGroupPermissions(group.wxid);
|
||||
this.loadGroupInsights(group.wxid);
|
||||
@@ -915,6 +944,22 @@
|
||||
})
|
||||
.finally(() => { this.groupInsightLoading = false; });
|
||||
},
|
||||
loadGroupProfile(groupId) {
|
||||
// 每次进入详情都拉最新资料,避免“更新通讯录后页面仍是旧数据”的错觉。
|
||||
this.currentGroupProfile = { owner_wxid: '', owner_name: '', announcement: '', member_count: 0, admin_count: 0, admins: [] };
|
||||
axios.get(`/contacts/api/group_profile/${groupId}`)
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.currentGroupProfile = response.data.data || this.currentGroupProfile;
|
||||
} else {
|
||||
this.$message.error('加载群资料失败');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('加载群资料失败:', error);
|
||||
this.$message.error('加载群资料失败');
|
||||
});
|
||||
},
|
||||
toggleGroupPermission(permission) {
|
||||
const newStatus = permission.statusBool ? 'enabled' : 'disabled';
|
||||
axios.post(`/robot/api/group/${this.currentGroup.wxid}/permissions`, {
|
||||
@@ -1494,6 +1539,7 @@
|
||||
.detail-card-sub { font-size: 12px; color: #94a3b8; font-weight: 500; }
|
||||
.feature-chip-list { display: flex; gap: 8px; flex-wrap: wrap; min-height: 60px; align-items: flex-start; }
|
||||
.empty-inline, .detail-inline-note { font-size: 12px; color: #64748b; }
|
||||
.group-announcement { white-space: pre-wrap; line-height: 1.7; color: #334155; }
|
||||
.detail-inline-note { margin-top: 12px; line-height: 1.6; }
|
||||
.suggestion-list { display: flex; flex-direction: column; gap: 12px; }
|
||||
.suggestion-item { border-radius: 14px; }
|
||||
|
||||
Reference in New Issue
Block a user