diff --git a/client/package.json b/client/package.json
index 93eb292..413500f 100644
--- a/client/package.json
+++ b/client/package.json
@@ -1,7 +1,7 @@
{
"name": "device-management-client",
"private": true,
- "version": "2.1.0",
+ "version": "2.2.0",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 8d64e20..eff22ff 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -127,7 +127,7 @@ function App() {
{ key: 'personnel', icon: , label: '人员管理' },
...(user?.role === 'admin' ? [{ key: 'accounts', icon: , label: '账户管理' }] : []),
{ key: 'notifications', icon: , label: '通知管理' },
- { key: 'download', icon: , label: '软件下载' },
+ { key: 'download', icon: , label: '软件下载' }
]
// 移动端底部导航(5个核心入口)
diff --git a/client/src/pages/About.jsx b/client/src/pages/About.jsx
index 849cc5b..5803afd 100644
--- a/client/src/pages/About.jsx
+++ b/client/src/pages/About.jsx
@@ -5,7 +5,7 @@ function About() {
return (
- 影视星河 · 设备管理系统 v2.1
+ 影视星河 · 设备管理系统 v2.2
软件概述
@@ -62,12 +62,17 @@ function About() {
版本信息
- - 当前版本:v2.1
+ - 当前版本:v2.2
- 发布日期:2026年8月
- 许可证:MIT License
更新日志
+ v2.2(2026年8月)
+
+ - 添加群聊删除人员的功能
+ - 修复创建群聊显示框闪退的bug
+
v2.1(2026年8月)
- 添加用户修改密码功能
diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsx
index da83da7..39da754 100644
--- a/client/src/pages/Dashboard.jsx
+++ b/client/src/pages/Dashboard.jsx
@@ -120,7 +120,7 @@ function Dashboard({ onNavigate }) {
系统信息
- 系统版本:v2.1
+ 系统版本:v2.2
系统名称:设备管理系统
diff --git a/client/src/pages/Messages.jsx b/client/src/pages/Messages.jsx
index 4c31073..ad51a1a 100644
--- a/client/src/pages/Messages.jsx
+++ b/client/src/pages/Messages.jsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from 'react'
import { Card, Button, Input, List, Badge, Modal, Form, Select, Tabs, Avatar, Empty, message, Popconfirm, Space, Tag, Tooltip } from 'antd'
-import { PlusOutlined, SendOutlined, TeamOutlined, UserOutlined, ArrowLeftOutlined, DeleteOutlined } from '@ant-design/icons'
+import { PlusOutlined, SendOutlined, TeamOutlined, UserOutlined, ArrowLeftOutlined, DeleteOutlined, SettingOutlined, UserDeleteOutlined } from '@ant-design/icons'
import axios from 'axios'
const { TextArea } = Input
@@ -25,6 +25,7 @@ function Messages({ user }) {
const [inputValue, setInputValue] = useState('')
const [sending, setSending] = useState(false)
const [createVisible, setCreateVisible] = useState(false)
+ const [membersVisible, setMembersVisible] = useState(false)
const [createForm] = Form.useForm()
const [creating, setCreating] = useState(false)
const bottomRef = useRef(null)
@@ -148,6 +149,31 @@ function Messages({ user }) {
const canDelete = (conv) => conv.type === 'direct' || conv.creator_id === user?.id
+ // 群主移除群成员
+ const handleRemoveMember = async (memberId) => {
+ try {
+ const res = await axios.delete(`/api/chat/conversations/${activeConv.id}/members/${memberId}`)
+ if (res.data.success) {
+ message.success(res.data.message)
+ setMembersVisible(false)
+ // 刷新会话列表与当前会话
+ const list = await axios.get('/api/chat/conversations')
+ if (list.data.success) {
+ setConversations(list.data.data)
+ const conv = list.data.data.find(c => c.id === activeConv.id)
+ if (conv) {
+ setActiveConv(conv)
+ activeConvRef.current = conv
+ } else {
+ closeConversation()
+ }
+ }
+ }
+ } catch (err) {
+ message.error(err.response?.data?.message || '操作失败')
+ }
+ }
+
const otherOptions = allUsers.filter(u => u.id !== user?.id).map(u => ({
value: u.id,
label: (
@@ -234,6 +260,11 @@ function Messages({ user }) {
{activeConv.member_count}人
)}
+ {activeConv.type === 'group' && activeConv.creator_id === user?.id && (
+ } onClick={() => setMembersVisible(true)} style={{ marginLeft: 'auto' }}>
+ 成员管理
+
+ )}
{messages.length === 0 && }
@@ -267,6 +298,103 @@ function Messages({ user }) {
)
+ // ============ 发起对话 / 建群弹窗 ============
+ // 注意:这里必须用普通 JSX 变量而非内部函数组件,
+ // 否则轮询重新渲染时组件类型变化会导致弹窗被卸载重建(闪退)
+ const createModal = (
+ setCreateVisible(false)}
+ footer={null}
+ width={480}
+ >
+
+
+
+
+ )
+ },
+ {
+ key: 'group',
+ label: '创建群聊',
+ children: (
+ <>
+
+
+
+
+
+
+ >
+ )
+ }
+ ]}
+ />
+
+
+
+
+
+
+
+
+
+ )
+
+ // ============ 群成员管理弹窗(仅群主可见) ============
+ const membersModal = (
+ setMembersVisible(false)}
+ footer={null}
+ width={420}
+ >
+ (
+ handleRemoveMember(m.id)}
+ okText="确定"
+ cancelText="取消"
+ >
+ } />
+
+ ]
+ : []
+ }
+ >
+ } />}
+ title={
+
+ {m.display_name || m.username}
+ {m.id === activeConv?.creator_id && 群主}
+ {m.id === user?.id && 我}
+
+ }
+ />
+
+ )}
+ />
+
+ )
+
// ============ 布局 ============
if (isMobile) {
return (
@@ -275,7 +403,8 @@ function Messages({ user }) {
{activeConv ? chatWindow : conversationList}
-
+ {createModal}
+ {membersModal}
)
}
@@ -289,61 +418,10 @@ function Messages({ user }) {
-
+ {createModal}
+ {membersModal}
)
-
- // ============ 发起对话 / 建群弹窗 ============
- function CreateConvModal() {
- return (
- setCreateVisible(false)}
- footer={null}
- width={480}
- >
-
-
-
-
- )
- },
- {
- key: 'group',
- label: '创建群聊',
- children: (
- <>
-
-
-
-
-
-
- >
- )
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
- )
- }
}
export default Messages
diff --git a/package.json b/package.json
index de67089..9b9e5b5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "device-management-system",
- "version": "2.1.0",
+ "version": "2.2.0",
"description": "影视星河设备管理系统 - Device Management System",
"main": "electron/main.js",
"scripts": {
diff --git a/server.js b/server.js
index fe2b015..d6faacd 100644
--- a/server.js
+++ b/server.js
@@ -867,6 +867,29 @@ app.delete('/api/chat/conversations/:id', (req, res) => {
res.json({ success: true, message: conv.type === 'group' ? '群组已解散' : '会话已删除' });
});
+// 移除群成员(群主可移除任意成员,群主本人不可被移除)
+app.delete('/api/chat/conversations/:id/members/:userId', (req, res) => {
+ const conv = db.prepare('SELECT * FROM conversations WHERE id = ?').get(req.params.id);
+ if (!conv || conv.type !== 'group') {
+ return res.status(404).json({ success: false, message: '群聊不存在' });
+ }
+ if (!isConversationMember(conv.id, req.user.id)) {
+ return res.status(403).json({ success: false, message: '您不是该群聊的成员' });
+ }
+ const targetId = req.params.userId;
+ if (targetId === conv.creator_id) {
+ return res.status(400).json({ success: false, message: '群主不能被移除' });
+ }
+ if (!isConversationMember(conv.id, targetId)) {
+ return res.status(404).json({ success: false, message: '该用户不在群聊中' });
+ }
+ if (req.user.id !== conv.creator_id) {
+ return res.status(403).json({ success: false, message: '只有群主可以移除群成员' });
+ }
+ db.prepare('DELETE FROM conversation_members WHERE conversation_id = ? AND user_id = ?').run(conv.id, targetId);
+ res.json({ success: true, message: '已将该成员移出群聊' });
+});
+
// ==================== 认证 API ====================
// 登录