fix(projects): 修改强退在线设备接口

This commit is contained in:
AN 2025-06-27 21:26:47 +08:00
parent 3628c2496a
commit dbcf8d422a
5 changed files with 47 additions and 9 deletions

View File

@ -20,6 +20,17 @@ export function fetchForceLogout(tokenId: string) {
method: 'delete'
});
}
/**
* 退线
*
* @param tokenId - ID
*/
export function fetchKickOutCurrentDevice(tokenId: string) {
return request<boolean>({
url: `/monitor/online/myself/${tokenId}`,
method: 'delete'
});
}
/** 获取在线设备列表 */
export function fetchGetOnlineDeviceList(params?: Api.Monitor.OnlineUserSearchParams) {

View File

@ -373,7 +373,15 @@ declare namespace Api {
type DictDataOperateParams = CommonType.RecordNullable<
Pick<
Api.System.DictData,
'dictCode' | 'dictSort' | 'dictLabel' | 'dictValue' | 'dictType' | 'cssClass' | 'listClass' | 'remark'
| 'dictCode'
| 'dictSort'
| 'dictLabel'
| 'dictValue'
| 'dictType'
| 'cssClass'
| 'listClass'
| 'isDefault'
| 'remark'
>
>;

View File

@ -1,11 +1,13 @@
<script setup lang="tsx">
import { NTime } from 'naive-ui';
import { useLoading } from '@sa/hooks';
import { fetchForceLogout, fetchGetOnlineDeviceList } from '@/service/api/monitor';
import { fetchGetOnlineDeviceList, fetchKickOutCurrentDevice } from '@/service/api/monitor';
import { useAppStore } from '@/store/modules/app';
import { useTable } from '@/hooks/common/table';
import { useDict } from '@/hooks/business/dict';
import { getBrowserIcon, getOsIcon } from '@/utils/icon-tag-format';
import { $t } from '@/locales';
import DictTag from '@/components/custom/dict-tag.vue';
import ButtonIcon from '@/components/custom/button-icon.vue';
import SvgIcon from '@/components/custom/svg-icon.vue';
@ -13,13 +15,23 @@ defineOptions({
name: 'OnlineTable'
});
useDict('sys_device_type');
const appStore = useAppStore();
const { loading: btnLoading, startLoading: startBtnLoading, endLoading: endBtnLoading } = useLoading(false);
const { columns, data, loading, getData } = useTable({
apiFn: fetchGetOnlineDeviceList,
columns: () => [
{ title: '用户名', key: 'userName', align: 'center', minWidth: 120 },
{
title: '设备类型',
key: 'deviceType',
align: 'center',
minWidth: 120,
render: row => {
return <DictTag size="small" value={row.deviceType} dict-code="sys_device_type" />;
}
},
{ title: 'IP地址', key: 'ipaddr', align: 'center', minWidth: 120 },
{ title: '登录地点', key: 'loginLocation', align: 'center', minWidth: 120 },
{
@ -86,7 +98,7 @@ const { columns, data, loading, getData } = useTable({
/** 强制下线 */
async function forceLogout(tokenId: string) {
startBtnLoading();
const { error } = await fetchForceLogout(tokenId);
const { error } = await fetchKickOutCurrentDevice(tokenId);
if (!error) {
window.$message?.success('强制下线成功');
await getData();

View File

@ -3,12 +3,13 @@ import { computed, reactive, watch } from 'vue';
import { NTag } from 'naive-ui';
import { fetchCreateDictData, fetchUpdateDictData } from '@/service/api/system/dict-data';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import { useDict } from '@/hooks/business/dict';
import { $t } from '@/locales';
defineOptions({
name: 'DictDataOperateDrawer'
});
useDict('sys_yes_no');
interface Props {
/** the type of operation */
operateType: NaiveUI.TableOperateType;
@ -63,7 +64,8 @@ function createDefaultModel(): Model {
dictType: props.dictType,
cssClass: '',
listClass: null,
remark: ''
remark: '',
isDefault: 'N'
};
}
@ -95,7 +97,7 @@ async function handleSubmit() {
// request
if (props.operateType === 'add') {
const { dictSort, dictLabel, dictValue, dictType, cssClass, listClass, remark } = model;
const { dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, remark } = model;
const { error } = await fetchCreateDictData({
dictSort,
dictLabel,
@ -103,13 +105,14 @@ async function handleSubmit() {
dictType,
cssClass,
listClass,
isDefault,
remark
});
if (error) return;
}
if (props.operateType === 'edit') {
const { dictCode, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, remark } = model;
const { dictCode, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, remark } = model;
const { error } = await fetchUpdateDictData({
dictCode,
dictSort,
@ -118,6 +121,7 @@ async function handleSubmit() {
dictType,
cssClass,
listClass,
isDefault,
remark
});
if (error) return;
@ -179,6 +183,9 @@ function renderTagLabel(option: { label: string; value: string }) {
<NFormItem :label="$t('page.system.dict.data.dictSort')" path="dictSort">
<NInputNumber v-model:value="model.dictSort" :placeholder="$t('page.system.dict.form.dictSort.required')" />
</NFormItem>
<NFormItem :label="$t('page.system.dict.data.isDefault')" path="isDefault">
<DictRadio v-model:value="model.isDefault" dict-code="sys_yes_no" />
</NFormItem>
<NFormItem :label="$t('page.system.dict.data.remark')" path="remark">
<NInput
v-model:value="model.remark"

View File

@ -56,7 +56,7 @@ function createDefaultModel(): Model {
nickName: '',
email: '',
phonenumber: '',
sex: '',
sex: '0',
password: '',
status: '0',
roleIds: [],