🔨 优化代码逻辑.
This commit is contained in:
@@ -331,7 +331,7 @@
|
||||
// 查询未读消息
|
||||
pullHasUnreadMessage();
|
||||
// 注册未读消息轮询
|
||||
messageIntervalId.value = setInterval(pullHasUnreadMessage, 30000);
|
||||
messageIntervalId.value = window.setInterval(pullHasUnreadMessage, 30000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
// 等待一秒后先查询一下状态
|
||||
setTimeout(pullExecStatus, 1000);
|
||||
// 注册状态轮询
|
||||
pullIntervalId.value = setInterval(pullExecStatus, 5000);
|
||||
pullIntervalId.value = window.setInterval(pullExecStatus, 5000);
|
||||
}
|
||||
// 打开日志
|
||||
nextTick(() => {
|
||||
|
||||
@@ -172,11 +172,11 @@ export default class LogAppender implements ILogAppender {
|
||||
};
|
||||
this.client.onmessage = this.processMessage.bind(this);
|
||||
// 注册持久化
|
||||
this.keepAliveTask = setInterval(() => {
|
||||
this.keepAliveTask = window.setInterval(() => {
|
||||
if (this.client?.readyState === WebSocket.OPEN) {
|
||||
this.client?.send('p');
|
||||
}
|
||||
}, 15000) as unknown as number;
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
// 打开日志
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { FileItem } from '@arco-design/web-vue';
|
||||
import type { IFileUploader, ResponseMessageBody } from './const';
|
||||
import { UploadOperatorType, UploadReceiverType } from './const';
|
||||
import { openFileUploadChannel } from '@/api/system/upload';
|
||||
import { closeFileReader } from '@/utils/file';
|
||||
|
||||
// 512 KB
|
||||
export const PART_SIZE = 512 * 1024;
|
||||
@@ -81,13 +82,14 @@ export default class FileUploader implements IFileUploader {
|
||||
|
||||
// 上传下一块数据
|
||||
private async uploadNextPart() {
|
||||
let reader = undefined as unknown as FileReader;
|
||||
try {
|
||||
if (this.currentPart < this.totalPart) {
|
||||
// 有下一个分片则上传
|
||||
const start = this.currentPart++ * PART_SIZE;
|
||||
const end = Math.min(this.currentFile.size, start + PART_SIZE);
|
||||
const chunk = this.currentFile.slice(start, end);
|
||||
const reader = new FileReader();
|
||||
reader = new FileReader();
|
||||
// 读取数据
|
||||
const arrayBuffer = await new Promise((resolve, reject) => {
|
||||
reader.onload = () => resolve(reader.result);
|
||||
@@ -107,11 +109,15 @@ export default class FileUploader implements IFileUploader {
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
// 读取文件失败
|
||||
// 发送读取文件失败
|
||||
this.client?.send(JSON.stringify({
|
||||
type: UploadOperatorType.ERROR,
|
||||
fileId: this.currentFileItem.uid,
|
||||
}));
|
||||
// 释放资源
|
||||
if (reader) {
|
||||
closeFileReader(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@
|
||||
|
||||
// 设置轮询状态
|
||||
onMounted(() => {
|
||||
pullIntervalId.value = setInterval(pullTaskStatus, 5000);
|
||||
pullIntervalId.value = window.setInterval(pullTaskStatus, 5000);
|
||||
});
|
||||
|
||||
// 卸载状态查询
|
||||
|
||||
@@ -429,7 +429,7 @@
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
// 注册状态轮询
|
||||
pullIntervalId.value = setInterval(pullExecStatus, 10000);
|
||||
pullIntervalId.value = window.setInterval(pullExecStatus, 10000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -417,7 +417,7 @@
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
// 注册状态轮询
|
||||
pullIntervalId.value = setInterval(pullJobStatus, 10000);
|
||||
pullIntervalId.value = window.setInterval(pullJobStatus, 10000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
// 注册状态轮询
|
||||
pullIntervalId.value = setInterval(pullTaskStatus, 10000);
|
||||
pullIntervalId.value = window.setInterval(pullTaskStatus, 10000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager {
|
||||
|
||||
public sessions: Array<ITerminalSession>;
|
||||
|
||||
private readonly keepAliveTaskId?: any;
|
||||
private readonly keepAliveTaskId: number;
|
||||
|
||||
private readonly dispatchFitFn: () => void;
|
||||
|
||||
@@ -33,7 +33,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager {
|
||||
// 注册 resize 事件
|
||||
addEventListen(window, 'resize', this.dispatchFitFn);
|
||||
// 注册 ping 事件
|
||||
this.keepAliveTaskId = setInterval(this.dispatchPing.bind(this), 15000);
|
||||
this.keepAliveTaskId = window.setInterval(this.dispatchPing.bind(this), 15000);
|
||||
}
|
||||
|
||||
// 打开 ssh 会话
|
||||
|
||||
Reference in New Issue
Block a user