From b4a49a4405ee0066268ac52ffa330fa783233c2a Mon Sep 17 00:00:00 2001 From: mac Date: Mon, 18 Nov 2024 18:00:53 +0800 Subject: [PATCH] commit --- .env | 4 +- env | 3 +- src/api/chat.ts | 6 +- src/app.css | 4 - src/components/MyTable/index.tsx | 21 +++- src/pages/chat/group-list/index.tsx | 14 ++- src/pages/chat/group-member/index.tsx | 138 ++++++++++++++++++++++++++ src/pages/chat/user-list/index.tsx | 8 -- src/route/routes.ts | 11 ++ src/utils/index.ts | 8 ++ 10 files changed, 194 insertions(+), 23 deletions(-) create mode 100644 src/pages/chat/group-member/index.tsx diff --git a/.env b/.env index 9a0ce4d..6b97639 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -REACT_APP_BASE_URL=http://162.254.37.253:8082/api/v1 -SKIP_PREFLIGHT_CHECK=true \ No newline at end of file +SKIP_PREFLIGHT_CHECK=true +GENERATE_SOURCEMAP=false \ No newline at end of file diff --git a/env b/env index 1a6f907..6b97639 100644 --- a/env +++ b/env @@ -1 +1,2 @@ -REACT_APP_BASE_URL=http://14.29.101.215:30303/api/v1 \ No newline at end of file +SKIP_PREFLIGHT_CHECK=true +GENERATE_SOURCEMAP=false \ No newline at end of file diff --git a/src/api/chat.ts b/src/api/chat.ts index aeea21f..9679499 100644 --- a/src/api/chat.ts +++ b/src/api/chat.ts @@ -1,4 +1,8 @@ import $axios from '@/utils/axios' export const chat_userList = (params) => $axios.post('/admin/openImUserList', params) -export const chat_groupList = (params) => $axios.post('/admin/openImGroupList', params) \ No newline at end of file +export const chat_groupList = (params) => $axios.post('/admin/openImGroupList', params) +export const chat_groupMemberList = (params) => $axios.post('/admin/openImGroupMemberList', params) + +export const chat_inviteUsetToGroup = (params) => $axios.post('/admin/openImInviteUserToGroup', params) +export const chat_kickGroup = (params) => $axios.post('/admin/openImKickGroup', params) \ No newline at end of file diff --git a/src/app.css b/src/app.css index 1cb9eb1..715ed18 100644 --- a/src/app.css +++ b/src/app.css @@ -1,7 +1,3 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - .text-overflow { display: -webkit-box; -webkit-box-orient: vertical; diff --git a/src/components/MyTable/index.tsx b/src/components/MyTable/index.tsx index 3267365..e1c2738 100644 --- a/src/components/MyTable/index.tsx +++ b/src/components/MyTable/index.tsx @@ -46,7 +46,8 @@ interface TableProps { sortConfig?: (arg0?: object) => any; expandedRowRender?: () => ReactNode; onExpand?: () => void; - header?: JSX.Element + header?: JSX.Element; + disableKeys?: string[] } const MyTable: FC = forwardRef( @@ -73,7 +74,8 @@ const MyTable: FC = forwardRef( sortConfig, expandedRowRender, onExpand, - header + header, + disableKeys } = props // 搜索参数,如果有特殊需要处理的参数,就处理 @@ -134,6 +136,11 @@ const MyTable: FC = forwardRef( total = validData.total; } + if (validData.members) { + tableData = validData.members; + total = validData.total; + } + // const validData = response?.data ? response.data : {} // const { rows: tableData = [], total } = validData @@ -180,7 +187,12 @@ const MyTable: FC = forwardRef( // 复选框配置 const rowSelection = { selectedRowKeys: selectedKeys, - onChange: onSelectChange + onChange: onSelectChange, + getCheckboxProps: (record: any) => { + return ({ + disabled: disableKeys && disableKeys.indexOf(record.userID) > -1 ? true : false, // Column configuration not to be checked + }) + }, } // 判断是否有复选框显示 const showCheckbox = onSelectRow ? { rowSelection } : {} @@ -243,6 +255,9 @@ const MyTable: FC = forwardRef( ? searchForm.current.resetFields([...field]) : searchForm.current.resetFields() }, + getSelectedKeys(): CommonObjectType[] { + return selectedKeys + }, // 获取当前列表数据 getTableData(): CommonObjectType[] { return tableData diff --git a/src/pages/chat/group-list/index.tsx b/src/pages/chat/group-list/index.tsx index 7fcc0d8..55a3bdd 100644 --- a/src/pages/chat/group-list/index.tsx +++ b/src/pages/chat/group-list/index.tsx @@ -4,9 +4,13 @@ import BuzzFaceURL from "@/components/buzzup/BuzzFaceURL"; import MyTable from "@/components/MyTable" import { getTime, isGender, isPlatformId } from "@/utils"; import React from "react" +import { useLocation, useHistory } from "react-router-dom"; + const ChatGroupList = () => { + const history = useHistory() + const columns = [ { title: '头像', @@ -70,11 +74,13 @@ const ChatGroupList = () => { { title: 'options', fixed: 'right', - width: 100, + width: 250, render: (item) => ( -
-
群成员
-
群成员
+
+
history.push(`/group-member?id=${item.groupInfo.groupID}`)}>群成员
+
群聊设置
+
全体禁言
+
解散群组
) } diff --git a/src/pages/chat/group-member/index.tsx b/src/pages/chat/group-member/index.tsx new file mode 100644 index 0000000..03cb97a --- /dev/null +++ b/src/pages/chat/group-member/index.tsx @@ -0,0 +1,138 @@ +import { chat_groupMemberList, chat_inviteUsetToGroup, chat_userList } from "@/api/chat"; +import BuzzFaceURL from "@/components/buzzup/BuzzFaceURL"; +import MyTable from "@/components/MyTable"; +import { getTime, GRole, isPlatformId, joinGR } from "@/utils"; +import { Button, Modal, notification } from "antd"; +import React, { useRef, useState } from "react" +import { useParams, useHistory } from "react-router-dom" + +const GroupMember = () => { + + const hash = window.location.hash + const queryString = hash.split('?')[1]; + const queryParams = new URLSearchParams(queryString) + + const tableUserRef = useRef(null) + const tableMemberRef = useRef(null) + + const [visible, setVisible] = useState(false) + + const columns = [ + { + title: '头像', + dataIndex: "", + width: 100, + render: (row) => ( +
+ +
+ ) + }, + { + title: '用户ID', + dataIndex: "userID", + width: 150 + }, + { + title: '群员角色', + dataIndex: "roleLevel", + width: 150, + render: (role) =>
{GRole[role]}
+ }, + { + title: '群昵称', + dataIndex: "nickname", + width: 150 + }, + { + title: '入群方式', + dataIndex: "joinSource", + width: 150, + render: (type) =>
{joinGR[type]}
+ }, + { + title: '入群时间', + dataIndex: "joinTime", + render: (time) =>
{getTime(time)}
+ }, + { + title: 'options', + fixed: 'right', + width: 200, + render: (item) => ( +
+
设置群身份
+
禁言
+
移除
+
+ ) + } + ] + + const userColumnData = [ + { + title: '头像', + dataIndex: "", + width: 100, + render: (row) => ( +
+ +
+ ) + }, + { + title: '用户昵称', + dataIndex: "nickname", + width: 200 + }, + { + title: '用户ID', + dataIndex: "userID", + }, + ] + + const joinG = async () => { + const keys = tableUserRef.current.getSelectedKeys() + setVisible(false) + const res: any = await chat_inviteUsetToGroup({ + groupID: queryParams.get('id'), + reason: '', + invitedUserIDs: keys + }) + if (res.code === 0) { + tableMemberRef.current.update() + notification.success({ + message: '添加成功' + }) + } + } + + return ( + <> + + +
+ } + ref={tableMemberRef} + apiFun={chat_groupMemberList} + columns={columns} + extraProps={{ + groupID: queryParams.get('id') + }} + /> + {visible && setVisible(false)} onOk={joinG}> + v.userID)} + /> + } + + ) +} + +export default GroupMember \ No newline at end of file diff --git a/src/pages/chat/user-list/index.tsx b/src/pages/chat/user-list/index.tsx index b62964a..83c3a46 100644 --- a/src/pages/chat/user-list/index.tsx +++ b/src/pages/chat/user-list/index.tsx @@ -29,14 +29,6 @@ const ChatUserList = () => { dataIndex: "userID", width: 300 }, - { - title: '性别', - dataIndex: "gender", - width: 200, - render: (gender) => ( -
{isGender(gender)}
- ) - }, { title: 'BuzzID', dataIndex: "publicKey", diff --git a/src/route/routes.ts b/src/route/routes.ts index f1d48e8..2263471 100644 --- a/src/route/routes.ts +++ b/src/route/routes.ts @@ -8,6 +8,7 @@ import LotteryTime from "@/pages/lotteryTime" import WalletVersion from "@/pages/walletVersion" import ChatUserList from "@/pages/chat/user-list" import ChatGroupList from "@/pages/chat/group-list" +import GroupMember from "@/pages/chat/group-member" const routes = [ { @@ -19,6 +20,16 @@ const routes = [ component: Home, routes: [] }, + { + path: '/group-member', + name: '群组成员', + exact: false, + key: 'group-member', + icon: HomeOutlined, + component: GroupMember, + remove: true, + routes: [] + }, { path: '/chat', name: 'IM模块', diff --git a/src/utils/index.ts b/src/utils/index.ts index 36c4e54..b9b4b1b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -5,6 +5,14 @@ import { store } from '@/store'; const genders = ['保密', '男', '女'] const platformId = ['-', 'IOS', 'Android', 'Windows', 'OSX', 'Web', 'MiniWeb', 'Linux', 'APad', 'IPad', 'Admin'] +export const joinGR = { + 0: '0', + 2: '邀请入群' +} + +export const GRole = { + 100: '群主', 60: '群管理员', 20: '普通群员' +} export const isGender = (index: number | string) => { let _idx = typeof index === 'string' ? Number(index) : index