up. 使用状态管理器管理设备
This commit is contained in:
parent
64e91f1f5c
commit
7fff0b31b4
@ -18,7 +18,7 @@
|
||||
placeholder="请输入临时锁定密码/为空则使用默认使用账号密码"
|
||||
/>
|
||||
<div style="margin-top: 20px">
|
||||
<el-button class="ele-fluid" type="primary" @click="confirmLock"
|
||||
<el-button class="ele-fluid" type="primary" :loading="lockLoading" @click="confirmLock"
|
||||
>锁定客户端</el-button
|
||||
>
|
||||
</div>
|
||||
@ -27,23 +27,39 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { useMobile } from '@/utils/use-mobile';
|
||||
import { wsInstance, WsSendEventType } from '@/plugins/websocket';
|
||||
import { ElMessage } from "element-plus";
|
||||
import {LockScreenStatus, useClientStore} from "@/store/modules/client";
|
||||
|
||||
/** 弹窗是否打开 */
|
||||
const visible = defineModel({ type: Boolean });
|
||||
|
||||
/** 是否是移动端 */
|
||||
const { mobile } = useMobile();
|
||||
const lockLoading = ref<boolean>(false);
|
||||
const lockPassword = ref<string>('');
|
||||
|
||||
const lockLoading = ref(false);
|
||||
const lockPassword = ref('');
|
||||
/**
|
||||
* 确定锁屏
|
||||
*/
|
||||
const confirmLock = () => {
|
||||
if(lockLoading.value){
|
||||
return;
|
||||
}
|
||||
lockLoading.value = true;
|
||||
if(wsInstance) {
|
||||
/*
|
||||
* 先快速锁定当前窗口的
|
||||
*/
|
||||
useClientStore().setLockScreen(LockScreenStatus.LOCK)
|
||||
/*
|
||||
* 通知设备下的窗口全部锁屏
|
||||
*/
|
||||
wsInstance.sendMessage(WsSendEventType.LOCK_CLIENT_SCREEN, {
|
||||
lockPassword: lockPassword.value
|
||||
});
|
||||
visible.value = false;
|
||||
lockPassword.value = '';
|
||||
lockPassword.value = ''; // 清空密码
|
||||
}else{
|
||||
ElMessage.error("锁屏功能不可用");
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -8,13 +8,21 @@ import { API_BASE_URL, LAYOUT_PATH } from '@/config/setting';
|
||||
import type { ApiResult } from '@/api';
|
||||
import router from '@/router';
|
||||
import { isWhiteList } from '@/router/routes';
|
||||
import {getClientInfo, getToken, setToken} from './token-util';
|
||||
import { getToken, setToken } from './token-util';
|
||||
import {logout, showLogoutConfirm, toURLSearch} from './common';
|
||||
import {useClientStore} from "@/store/modules/client";
|
||||
|
||||
/**
|
||||
* 请求拦截处理
|
||||
*/
|
||||
export function requestInterceptor(config: InternalAxiosRequestConfig<any>) {
|
||||
// 添加客户端信息到header
|
||||
const client = useClientStore();
|
||||
if(config.headers) {
|
||||
config.headers['Client'] = client.clientName
|
||||
config.headers['Client-Id'] = client.clientId;
|
||||
config.headers['Client-Version'] = client.clientVersion;
|
||||
}
|
||||
// 添加token到header
|
||||
const token = getToken();
|
||||
if (token && config.headers) {
|
||||
@ -25,13 +33,6 @@ export function requestInterceptor(config: InternalAxiosRequestConfig<any>) {
|
||||
config.url = toURLSearch(config.params, config.url);
|
||||
config.params = {};
|
||||
}
|
||||
// 客户端信息
|
||||
let clientInfo = getClientInfo();
|
||||
if(clientInfo) {
|
||||
config.headers['Client'] = clientInfo.name;
|
||||
config.headers['Client-Id'] = clientInfo.id;
|
||||
config.headers['Client-Version'] = clientInfo.version;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user