feat: add friend add and curfew controls

This commit is contained in:
richjohnrambo
2026-09-18 10:55:33 +08:00
parent 348cbcaf96
commit 7c8b4d9b7c
12 changed files with 270 additions and 1 deletions
+32 -1
View File
@@ -218,6 +218,7 @@
BatchCreate,
Create,
DownloadTemplate,
FriendAdd,
ImportUsers,
IPWhitelist,
IPWhitelistSave,
@@ -287,7 +288,7 @@
}
const actionColumn = reactive({
width: 600,
width: 700,
title: '操作',
key: 'action',
fixed: 'right',
@@ -322,6 +323,13 @@
auth: ['/imUser/adjustGroup'],
ifShow: record.state !== 20,
},
{
label: record.friendAddEnabled === 0 ? '允许加好友' : '禁止加好友',
type: record.friendAddEnabled === 0 ? 'default' : 'error',
onClick: handleFriendAddToggle.bind(null, record),
auth: ['/imUser/friendAdd'],
ifShow: record.state !== 20,
},
{
label: record.state === 0 ? '封禁' : '解封',
type: record.state === 0 ? 'error' : 'default',
@@ -399,6 +407,29 @@
resetPasswordRef.value.openModal(record);
}
function handleFriendAddToggle(record: State) {
const nextEnabled = record.friendAddEnabled === 0 ? 1 : 0;
dialog.warning({
title: nextEnabled === 1 ? '允许加好友' : '禁止加好友',
content:
nextEnabled === 1
? `确定允许用户“${record.username}”发起加好友吗?`
: `确定禁止用户“${record.username}”发起加好友吗?`,
positiveText: '确认',
negativeText: '取消',
onPositiveClick: async () => {
await FriendAdd({
tenantId: record.tenantId,
userId: Number(record.userId),
enabled: nextEnabled,
reason: nextEnabled === 1 ? '' : '后台禁止该用户发起加好友',
});
message.success(nextEnabled === 1 ? '已允许加好友' : '已禁止加好友');
reloadTable();
},
});
}
async function openIPWhitelist(record: State) {
operationUser.value = record;
const result = await IPWhitelist({ tenantId: record.tenantId, userId: Number(record.userId) });
+14
View File
@@ -26,6 +26,7 @@ export class State {
public state = 0; // 账号状态
public policyGroupId = 0; // 用户策略分组ID
public policyGroupName = ''; // 用户策略分组名称
public friendAddEnabled = 1; // 是否允许发起加好友
public authVersion = 0; // 认证版本
public passwordUpdatedAt = ''; // 密码更新时间
public authNames = ''; // 登录标识
@@ -206,6 +207,19 @@ export const columns = [
return row.policyGroupName || '--';
},
},
{
title: '加好友',
key: 'friendAddEnabled',
align: 'left',
width: 100,
render(row: State) {
return h(
NTag,
{ type: row.friendAddEnabled === 0 ? 'error' : 'success' },
{ default: () => (row.friendAddEnabled === 0 ? '禁止' : '允许') }
);
},
},
{
title: '最近登录',
key: 'lastSeen',