feat: expand IM admin controls

This commit is contained in:
richjohnrambo
2026-08-21 15:09:39 +08:00
parent c3676f9744
commit 543c7b624e
29 changed files with 1308 additions and 39 deletions
+60 -2
View File
@@ -1,11 +1,16 @@
import { computed, ref } from 'vue';
import { computed, h, ref } from 'vue';
import { NSwitch } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form';
import { defRangeShortcuts } from '@/utils/dateUtil';
import { useDictStore } from '@/store/modules/dict';
import { List as TenantList } from '@/api/imTenant';
import { Status } from '@/api/imUser';
import { usePermission } from '@/hooks/web/usePermission';
const dict = useDictStore();
const { hasPermission } = usePermission();
const $message = window['$message'];
export const tenantOptions = ref<any[]>([]);
@@ -43,6 +48,21 @@ export class State {
}
}
export class DeviceState {
public tenantId = 0;
public tenantName = '';
public userId = '';
public deviceId = '';
public platform = '';
public lang = '';
public lastSeen = '';
public pushProvider = '';
public pushPlatform = '';
public pushAppVersion = '';
public pushTokenConfigured = false;
public pushUpdatedAt = '';
}
export function newState(state: State | Record<string, any> | null): State {
if (state !== null) {
if (state instanceof State) {
@@ -159,7 +179,25 @@ export const columns = [
align: 'left',
width: 110,
render(row: State) {
return dict.getLabel('ImUserStateOptions', row.state);
if (row.state === 20) {
return dict.getLabel('ImUserStateOptions', row.state);
}
return h(NSwitch, {
value: row.state === 0,
checked: '正常',
unchecked: '停用',
disabled: !hasPermission(['/imUser/status']),
onUpdateValue: async (value) => {
const oldState = row.state;
row.state = value ? 0 : 10;
try {
await Status({ tenantId: row.tenantId, userId: row.userId, state: row.state });
$message.success('操作成功');
} catch {
row.state = oldState;
}
},
});
},
},
{
@@ -200,6 +238,26 @@ export const columns = [
},
];
export const deviceColumns = [
{ title: '设备ID', key: 'deviceId', align: 'left', width: 240 },
{ title: '平台', key: 'platform', align: 'left', width: 120 },
{ title: '语言', key: 'lang', align: 'left', width: 90 },
{ title: '最后活跃', key: 'lastSeen', align: 'left', width: 180 },
{ title: 'Push服务商', key: 'pushProvider', align: 'left', width: 120 },
{ title: 'Push平台', key: 'pushPlatform', align: 'left', width: 120 },
{ title: 'App版本', key: 'pushAppVersion', align: 'left', width: 120 },
{
title: 'Push Token',
key: 'pushTokenConfigured',
align: 'left',
width: 120,
render(row: DeviceState) {
return row.pushTokenConfigured ? '已配置' : '未配置';
},
},
{ title: 'Push更新时间', key: 'pushUpdatedAt', align: 'left', width: 180 },
];
// 加载字典数据选项
export function loadOptions() {
dict.loadOptions(['ImUserStateOptions']);