mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修改强退在线设备接口
This commit is contained in:
@ -20,6 +20,17 @@ export function fetchForceLogout(tokenId: string) {
|
|||||||
method: 'delete'
|
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) {
|
export function fetchGetOnlineDeviceList(params?: Api.Monitor.OnlineUserSearchParams) {
|
||||||
|
10
src/typings/api/system.api.d.ts
vendored
10
src/typings/api/system.api.d.ts
vendored
@ -373,7 +373,15 @@ declare namespace Api {
|
|||||||
type DictDataOperateParams = CommonType.RecordNullable<
|
type DictDataOperateParams = CommonType.RecordNullable<
|
||||||
Pick<
|
Pick<
|
||||||
Api.System.DictData,
|
Api.System.DictData,
|
||||||
'dictCode' | 'dictSort' | 'dictLabel' | 'dictValue' | 'dictType' | 'cssClass' | 'listClass' | 'remark'
|
| 'dictCode'
|
||||||
|
| 'dictSort'
|
||||||
|
| 'dictLabel'
|
||||||
|
| 'dictValue'
|
||||||
|
| 'dictType'
|
||||||
|
| 'cssClass'
|
||||||
|
| 'listClass'
|
||||||
|
| 'isDefault'
|
||||||
|
| 'remark'
|
||||||
>
|
>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { NTime } from 'naive-ui';
|
import { NTime } from 'naive-ui';
|
||||||
import { useLoading } from '@sa/hooks';
|
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 { useAppStore } from '@/store/modules/app';
|
||||||
import { useTable } from '@/hooks/common/table';
|
import { useTable } from '@/hooks/common/table';
|
||||||
|
import { useDict } from '@/hooks/business/dict';
|
||||||
import { getBrowserIcon, getOsIcon } from '@/utils/icon-tag-format';
|
import { getBrowserIcon, getOsIcon } from '@/utils/icon-tag-format';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
|
import DictTag from '@/components/custom/dict-tag.vue';
|
||||||
import ButtonIcon from '@/components/custom/button-icon.vue';
|
import ButtonIcon from '@/components/custom/button-icon.vue';
|
||||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||||
|
|
||||||
@ -13,13 +15,23 @@ defineOptions({
|
|||||||
name: 'OnlineTable'
|
name: 'OnlineTable'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useDict('sys_device_type');
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const { loading: btnLoading, startLoading: startBtnLoading, endLoading: endBtnLoading } = useLoading(false);
|
const { loading: btnLoading, startLoading: startBtnLoading, endLoading: endBtnLoading } = useLoading(false);
|
||||||
|
|
||||||
const { columns, data, loading, getData } = useTable({
|
const { columns, data, loading, getData } = useTable({
|
||||||
apiFn: fetchGetOnlineDeviceList,
|
apiFn: fetchGetOnlineDeviceList,
|
||||||
columns: () => [
|
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: 'IP地址', key: 'ipaddr', align: 'center', minWidth: 120 },
|
||||||
{ title: '登录地点', key: 'loginLocation', 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) {
|
async function forceLogout(tokenId: string) {
|
||||||
startBtnLoading();
|
startBtnLoading();
|
||||||
const { error } = await fetchForceLogout(tokenId);
|
const { error } = await fetchKickOutCurrentDevice(tokenId);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
window.$message?.success('强制下线成功');
|
window.$message?.success('强制下线成功');
|
||||||
await getData();
|
await getData();
|
||||||
|
@ -3,12 +3,13 @@ import { computed, reactive, watch } from 'vue';
|
|||||||
import { NTag } from 'naive-ui';
|
import { NTag } from 'naive-ui';
|
||||||
import { fetchCreateDictData, fetchUpdateDictData } from '@/service/api/system/dict-data';
|
import { fetchCreateDictData, fetchUpdateDictData } from '@/service/api/system/dict-data';
|
||||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||||
|
import { useDict } from '@/hooks/business/dict';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'DictDataOperateDrawer'
|
name: 'DictDataOperateDrawer'
|
||||||
});
|
});
|
||||||
|
useDict('sys_yes_no');
|
||||||
interface Props {
|
interface Props {
|
||||||
/** the type of operation */
|
/** the type of operation */
|
||||||
operateType: NaiveUI.TableOperateType;
|
operateType: NaiveUI.TableOperateType;
|
||||||
@ -63,7 +64,8 @@ function createDefaultModel(): Model {
|
|||||||
dictType: props.dictType,
|
dictType: props.dictType,
|
||||||
cssClass: '',
|
cssClass: '',
|
||||||
listClass: null,
|
listClass: null,
|
||||||
remark: ''
|
remark: '',
|
||||||
|
isDefault: 'N'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ async function handleSubmit() {
|
|||||||
|
|
||||||
// request
|
// request
|
||||||
if (props.operateType === 'add') {
|
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({
|
const { error } = await fetchCreateDictData({
|
||||||
dictSort,
|
dictSort,
|
||||||
dictLabel,
|
dictLabel,
|
||||||
@ -103,13 +105,14 @@ async function handleSubmit() {
|
|||||||
dictType,
|
dictType,
|
||||||
cssClass,
|
cssClass,
|
||||||
listClass,
|
listClass,
|
||||||
|
isDefault,
|
||||||
remark
|
remark
|
||||||
});
|
});
|
||||||
if (error) return;
|
if (error) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.operateType === 'edit') {
|
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({
|
const { error } = await fetchUpdateDictData({
|
||||||
dictCode,
|
dictCode,
|
||||||
dictSort,
|
dictSort,
|
||||||
@ -118,6 +121,7 @@ async function handleSubmit() {
|
|||||||
dictType,
|
dictType,
|
||||||
cssClass,
|
cssClass,
|
||||||
listClass,
|
listClass,
|
||||||
|
isDefault,
|
||||||
remark
|
remark
|
||||||
});
|
});
|
||||||
if (error) return;
|
if (error) return;
|
||||||
@ -179,6 +183,9 @@ function renderTagLabel(option: { label: string; value: string }) {
|
|||||||
<NFormItem :label="$t('page.system.dict.data.dictSort')" path="dictSort">
|
<NFormItem :label="$t('page.system.dict.data.dictSort')" path="dictSort">
|
||||||
<NInputNumber v-model:value="model.dictSort" :placeholder="$t('page.system.dict.form.dictSort.required')" />
|
<NInputNumber v-model:value="model.dictSort" :placeholder="$t('page.system.dict.form.dictSort.required')" />
|
||||||
</NFormItem>
|
</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">
|
<NFormItem :label="$t('page.system.dict.data.remark')" path="remark">
|
||||||
<NInput
|
<NInput
|
||||||
v-model:value="model.remark"
|
v-model:value="model.remark"
|
||||||
|
@ -56,7 +56,7 @@ function createDefaultModel(): Model {
|
|||||||
nickName: '',
|
nickName: '',
|
||||||
email: '',
|
email: '',
|
||||||
phonenumber: '',
|
phonenumber: '',
|
||||||
sex: '',
|
sex: '0',
|
||||||
password: '',
|
password: '',
|
||||||
status: '0',
|
status: '0',
|
||||||
roleIds: [],
|
roleIds: [],
|
||||||
|
Reference in New Issue
Block a user