From 4b060a864a40ca72e325bb899df352ca9f4aa721 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Tue, 11 Jun 2024 12:28:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:zap:=20=E7=99=BB=E5=BD=95=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=8F=82=E6=95=B0=E5=8C=96.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 +++++++------ .../visor/framework/common/constant/Const.java | 2 -- .../module/infra/controller/MineController.java | 4 ++-- .../infra/controller/SystemUserController.java | 5 +++-- .../visor/module/infra/service/MineService.java | 3 ++- .../module/infra/service/OperatorLogService.java | 3 ++- .../module/infra/service/impl/MineServiceImpl.java | 4 ++-- .../infra/service/impl/OperatorLogServiceImpl.java | 8 +++++--- orion-visor-ui/src/api/user/mine.ts | 4 ++-- orion-visor-ui/src/api/user/user.ts | 4 ++-- .../views/user/info/components/login-history.vue | 10 +++++----- orion-visor-ui/src/views/user/info/types/const.ts | 3 +++ 12 files changed, 35 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9a50c424..acd3e7e5 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,13 @@ ## 演示环境 -演示地址: http://101.43.254.243:1081/ -演示账号: admin/admin - -⭐ 体验后可以点一下 `star` 这对我很重要! -🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目! -[github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor) +* 🔗 演示地址: http://101.43.254.243:1081/ +* 🔏 演示账号: admin/admin +* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor) +* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目! +* 🎭 演示环境部分功能不可用, 完整功能请本地部署! +* 📛 演示环境请不要随便删除数据! +* 📧 如果演示环境不可用请联系我! ## 快速开始 diff --git a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/Const.java b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/Const.java index d91c838c..6e2c0e8e 100644 --- a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/Const.java +++ b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/Const.java @@ -25,8 +25,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons Integer DEFAULT_SORT = 10; - int LOGIN_HISTORY_COUNT = 30; - Long NONE_ID = -1L; Integer DEFAULT_VERSION = 1; diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/MineController.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/MineController.java index a320a149..153fdf1b 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/MineController.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/MineController.java @@ -70,8 +70,8 @@ public class MineController { @IgnoreLog(IgnoreLogMode.RET) @GetMapping("/login-history") @Operation(summary = "查询当前用户登录日志") - public List getCurrentLoginHistory() { - return mineService.getCurrentLoginHistory(); + public List getCurrentLoginHistory(@RequestParam("count") Integer count) { + return mineService.getCurrentLoginHistory(count); } @IgnoreLog(IgnoreLogMode.RET) diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java index 30ed137d..c386b044 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java @@ -182,8 +182,9 @@ public class SystemUserController { @GetMapping("/login-history") @Operation(summary = "查询用户登录日志") @PreAuthorize("@ss.hasPermission('infra:system-user:login-history')") - public List getLoginHistory(@RequestParam("username") String username) { - return operatorLogService.getLoginHistory(username); + public List getLoginHistory(@RequestParam("username") String username, + @RequestParam("count") Integer count) { + return operatorLogService.getLoginHistory(username, count); } } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/MineService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/MineService.java index d744f570..3286e261 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/MineService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/MineService.java @@ -46,9 +46,10 @@ public interface MineService { /** * 获取当前用户登录日志 * + * @param count count * @return 登录日志 */ - List getCurrentLoginHistory(); + List getCurrentLoginHistory(Integer count); /** * 获取当前用户会话列表 diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/OperatorLogService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/OperatorLogService.java index 78a6d5c7..e60827b3 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/OperatorLogService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/OperatorLogService.java @@ -60,8 +60,9 @@ public interface OperatorLogService { * 查询用户登录日志 * * @param username username + * @param count count * @return rows */ - List getLoginHistory(String username); + List getLoginHistory(String username, Integer count); } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/MineServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/MineServiceImpl.java index 1bea7dfd..9fde8a95 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/MineServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/MineServiceImpl.java @@ -77,9 +77,9 @@ public class MineServiceImpl implements MineService { } @Override - public List getCurrentLoginHistory() { + public List getCurrentLoginHistory(Integer count) { String username = SecurityUtils.getLoginUsername(); - return operatorLogService.getLoginHistory(username); + return operatorLogService.getLoginHistory(username, count); } @Override diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/OperatorLogServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/OperatorLogServiceImpl.java index e2ac7db6..37fe8062 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/OperatorLogServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/OperatorLogServiceImpl.java @@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Arrays1; +import com.orion.lang.utils.Valid; import com.orion.visor.framework.biz.operator.log.core.model.OperatorLogModel; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; -import com.orion.visor.framework.common.constant.Const; +import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.module.infra.convert.OperatorLogConvert; import com.orion.visor.module.infra.dao.OperatorLogDAO; import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType; @@ -81,7 +82,8 @@ public class OperatorLogServiceImpl implements OperatorLogService { } @Override - public List getLoginHistory(String username) { + public List getLoginHistory(String username, Integer count) { + Valid.gt(count, 0, ErrorMessage.PARAM_ERROR); // 条件 OperatorLogQueryRequest request = new OperatorLogQueryRequest(); request.setUsername(username); @@ -89,7 +91,7 @@ public class OperatorLogServiceImpl implements OperatorLogService { LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); // 查询 return operatorLogDAO.of(wrapper) - .limit(Const.LOGIN_HISTORY_COUNT) + .limit(count) .list(OperatorLogConvert.MAPPER::toLoginHistory); } diff --git a/orion-visor-ui/src/api/user/mine.ts b/orion-visor-ui/src/api/user/mine.ts index 0192299e..b768ba55 100644 --- a/orion-visor-ui/src/api/user/mine.ts +++ b/orion-visor-ui/src/api/user/mine.ts @@ -35,8 +35,8 @@ export function updateCurrentUser(request: UserUpdateRequest) { /** * 查询当前用户登录日志 */ -export function getCurrentLoginHistory() { - return axios.get('/infra/mine/login-history'); +export function getCurrentLoginHistory(count: number) { + return axios.get('/infra/mine/login-history', { params: { count } }); } /** diff --git a/orion-visor-ui/src/api/user/user.ts b/orion-visor-ui/src/api/user/user.ts index 819502bb..00a81eaf 100644 --- a/orion-visor-ui/src/api/user/user.ts +++ b/orion-visor-ui/src/api/user/user.ts @@ -192,6 +192,6 @@ export function offlineUserSession(request: UserSessionOfflineRequest) { /** * 查询登录日志 */ -export function getLoginHistory(username: string) { - return axios.get('/infra/system-user/login-history', { params: { username } }); +export function getLoginHistory(username: string, count: number) { + return axios.get('/infra/system-user/login-history', { params: { username, count } }); } diff --git a/orion-visor-ui/src/views/user/info/components/login-history.vue b/orion-visor-ui/src/views/user/info/components/login-history.vue index 10f1ef85..9aa38597 100644 --- a/orion-visor-ui/src/views/user/info/components/login-history.vue +++ b/orion-visor-ui/src/views/user/info/components/login-history.vue @@ -2,10 +2,10 @@
@@ -62,7 +62,7 @@ import type { UserQueryResponse, LoginHistoryQueryResponse } from '@/api/user/user'; import { ref, onBeforeMount } from 'vue'; import useLoading from '@/hooks/loading'; - import { ResultStatus } from '../types/const'; + import { historyCount, ResultStatus } from '../types/const'; import { getCurrentLoginHistory } from '@/api/user/mine'; import { getLoginHistory } from '@/api/user/user'; import { dateFormat } from '@/utils'; @@ -82,11 +82,11 @@ setLoading(true); if (props.user) { // 查询其他用户 - const { data } = await getLoginHistory(props.user.username); + const { data } = await getLoginHistory(props.user.username, historyCount); list.value = data; } else { // 查询当前用户 - const { data } = await getCurrentLoginHistory(); + const { data } = await getCurrentLoginHistory(historyCount); list.value = data; } } catch (e) { diff --git a/orion-visor-ui/src/views/user/info/types/const.ts b/orion-visor-ui/src/views/user/info/types/const.ts index 7ad76c5c..d76e60ec 100644 --- a/orion-visor-ui/src/views/user/info/types/const.ts +++ b/orion-visor-ui/src/views/user/info/types/const.ts @@ -5,3 +5,6 @@ export const ResultStatus = { // 成功 SUCCESS: 1, }; + +// 历史数量 +export const historyCount = 30; From ae03460a337c76042111b7b8c6cb265038228298 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Tue, 11 Jun 2024 12:31:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=85=B3=E9=97=AD=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orion-visor-ui/src/api/asset/host-sftp.ts | 4 +- orion-visor-ui/src/utils/file.ts | 21 +++++ .../views/exec/exec-command/types/const.ts | 4 +- .../terminal/handler/sftp-transfer-manager.ts | 18 ++++- .../host/terminal/handler/terminal-channel.ts | 81 +++++++------------ .../handler/terminal-output-processor.ts | 2 +- .../handler/terminal-session-manager.ts | 6 +- .../host/terminal/types/terminal.const.ts | 3 + .../host/terminal/types/terminal.protocol.ts | 54 +++++++++++++ .../host/terminal/types/terminal.type.ts | 3 + 10 files changed, 131 insertions(+), 65 deletions(-) diff --git a/orion-visor-ui/src/api/asset/host-sftp.ts b/orion-visor-ui/src/api/asset/host-sftp.ts index fda18c3d..d874bbd8 100644 --- a/orion-visor-ui/src/api/asset/host-sftp.ts +++ b/orion-visor-ui/src/api/asset/host-sftp.ts @@ -65,7 +65,7 @@ export function deleteHostSftpLog(idList: Array) { /** * 下载文件 */ -export function downloadWithTransferToken(channelId: string, transferToken: string) { - window.open(`${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`, 'newWindow'); +export function getDownloadTransferUrl(channelId: string, transferToken: string) { + return `${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`; } diff --git a/orion-visor-ui/src/utils/file.ts b/orion-visor-ui/src/utils/file.ts index dcc80f41..bdcdec9b 100644 --- a/orion-visor-ui/src/utils/file.ts +++ b/orion-visor-ui/src/utils/file.ts @@ -84,6 +84,27 @@ export function getParentPath(path: string) { return parent; } +/** + * 打开下载文件 + */ +export function openDownloadFile(url: string) { + try { + // 创建隐藏的可下载链接 + let element = document.createElement('a'); + element.setAttribute('href', url); + element.setAttribute('download', ''); + element.style.display = 'none'; + // 将其附加到文档中 + document.body.appendChild(element); + // 点击该下载链接 + element.click(); + // 移除已下载的链接 + document.body.removeChild(element); + } catch (e) { + window.open(url, 'newWindow'); + } +} + /** * 下载文件 */ diff --git a/orion-visor-ui/src/views/exec/exec-command/types/const.ts b/orion-visor-ui/src/views/exec/exec-command/types/const.ts index b88ef694..38302e24 100644 --- a/orion-visor-ui/src/views/exec/exec-command/types/const.ts +++ b/orion-visor-ui/src/views/exec/exec-command/types/const.ts @@ -1,2 +1,2 @@ -// 执行 -export const historyCount = 20; +// 历史数量 +export const historyCount = 15; diff --git a/orion-visor-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts b/orion-visor-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts index 2aeffa3f..ed395cd5 100644 --- a/orion-visor-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts +++ b/orion-visor-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts @@ -1,12 +1,13 @@ import type { ISftpTransferManager, ISftpTransferUploader, SftpTransferItem } from '../types/terminal.type'; import { ISftpTransferDownloader, SftpFile, TransferOperatorResponse } from '../types/terminal.type'; -import { TransferReceiverType, TransferStatus, TransferType } from '../types/terminal.const'; +import { sessionCloseMsg, TransferReceiverType, TransferStatus, TransferType } from '../types/terminal.const'; import { Message } from '@arco-design/web-vue'; import { getTerminalAccessToken, openHostTransferChannel } from '@/api/asset/host-terminal'; import { nextId } from '@/utils'; -import { downloadWithTransferToken } from '@/api/asset/host-sftp'; +import { getDownloadTransferUrl } from '@/api/asset/host-sftp'; import SftpTransferUploader from './sftp-transfer-uploader'; import SftpTransferDownloader from './sftp-transfer-downloader'; +import { openDownloadFile } from '@/utils/file'; // sftp 传输管理器实现 export default class SftpTransferManager implements ISftpTransferManager { @@ -257,7 +258,10 @@ export default class SftpTransferManager implements ISftpTransferManager { // 接收开始下载响应 private resolveDownloadStart(data: TransferOperatorResponse) { - downloadWithTransferToken(data.channelId as string, data.transferToken as string); + // 获取下载 url + const url = getDownloadTransferUrl(data.channelId as string, data.transferToken as string); + // 打开 + openDownloadFile(url); } // 接收下载进度响应 @@ -287,6 +291,14 @@ export default class SftpTransferManager implements ISftpTransferManager { this.run = false; // 关闭传输进度 clearInterval(this.progressIntervalId); + // 进行中和等待中的文件改为失败 + this.transferList.forEach(s => { + if (s.status === TransferStatus.WAITING || + s.status === TransferStatus.TRANSFERRING) { + s.status = TransferStatus.ERROR; + s.errorMessage = sessionCloseMsg; + } + }); } } diff --git a/orion-visor-ui/src/views/host/terminal/handler/terminal-channel.ts b/orion-visor-ui/src/views/host/terminal/handler/terminal-channel.ts index c589b3c7..1fde2bd8 100644 --- a/orion-visor-ui/src/views/host/terminal/handler/terminal-channel.ts +++ b/orion-visor-ui/src/views/host/terminal/handler/terminal-channel.ts @@ -1,5 +1,6 @@ -import type { InputPayload, ITerminalChannel, ITerminalOutputProcessor, ITerminalSessionManager, OutputPayload, Protocol, } from '../types/terminal.type'; -import { OutputProtocol } from '../types/terminal.protocol'; +import type { InputPayload, ITerminalChannel, ITerminalOutputProcessor, ITerminalSessionManager, Protocol, } from '../types/terminal.type'; +import { format, OutputProtocol, parse } from '../types/terminal.protocol'; +import { sessionCloseMsg } from '../types/terminal.const'; import { getTerminalAccessToken, openHostTerminalChannel } from '@/api/asset/host-terminal'; import { Message } from '@arco-design/web-vue'; import TerminalOutputProcessor from './terminal-output-processor'; @@ -9,9 +10,12 @@ export default class TerminalChannel implements ITerminalChannel { private client?: WebSocket; + private readonly sessionManager: ITerminalSessionManager; + private readonly processor: ITerminalOutputProcessor; constructor(sessionManager: ITerminalSessionManager) { + this.sessionManager = sessionManager; this.processor = new TerminalOutputProcessor(sessionManager, this); } @@ -29,6 +33,8 @@ export default class TerminalChannel implements ITerminalChannel { } this.client.onclose = event => { console.warn('terminal close', event); + // 关闭回调 + this.closeCallback(); }; this.client.onmessage = this.handlerMessage.bind(this); } @@ -66,6 +72,25 @@ export default class TerminalChannel implements ITerminalChannel { } } + // 关闭回调 + private closeCallback(): void { + // 关闭时将手动触发 close 消息, 有可能是其他原因关闭的, 没有接收到 close 消息, 导致已断开是终端还是显示已连接 + Object.values(this.sessionManager.sessions).forEach(s => { + if (!s?.connected) { + return; + } + // close 消息 + const data = format(OutputProtocol.CLOSE, { + type: OutputProtocol.CLOSE.type, + sessionId: s.sessionId, + forceClose: 0, + msg: sessionCloseMsg, + }); + // 触发 close 消息 + this.handlerMessage({ data } as MessageEvent); + }); + } + // 关闭 close(): void { // 关闭 client @@ -78,55 +103,3 @@ export default class TerminalChannel implements ITerminalChannel { } } - -// 分隔符 -export const SEPARATOR = '|'; - -// 解析参数 -export const parse = (payload: string) => { - const protocols = Object.values(OutputProtocol); - const useProtocol = protocols.find(p => payload.startsWith(p.type + SEPARATOR) || p.type === payload); - if (!useProtocol) { - return undefined; - } - const template = useProtocol.template; - const res = {} as OutputPayload; - let curr = 0; - let len = payload.length; - for (let i = 0, pl = template.length; i < pl; i++) { - if (i == pl - 1) { - // 最后一次 - res[template[i]] = payload.substring(curr, len); - } else { - // 非最后一次 - let tmp = ''; - for (; curr < len; curr++) { - const c = payload.charAt(curr); - if (c == SEPARATOR) { - res[template[i]] = tmp; - curr++; - break; - } else { - tmp += c; - } - } - } - } - return res; -}; - -// 格式化参数 -export const format = (protocol: Protocol, payload: InputPayload) => { - payload.type = protocol.type; - return protocol.template - .map(i => getPayloadValueString(payload[i])) - .join(SEPARATOR); -}; - -// 获取默认值 -export const getPayloadValueString = (value: unknown): any => { - if (value === undefined || value === null) { - return ''; - } - return value; -}; diff --git a/orion-visor-ui/src/views/host/terminal/handler/terminal-output-processor.ts b/orion-visor-ui/src/views/host/terminal/handler/terminal-output-processor.ts index 4cd68581..2a3a563d 100644 --- a/orion-visor-ui/src/views/host/terminal/handler/terminal-output-processor.ts +++ b/orion-visor-ui/src/views/host/terminal/handler/terminal-output-processor.ts @@ -85,7 +85,7 @@ export default class TerminalOutputProcessor implements ITerminalOutputProcessor } // 处理关闭消息 - processClose({ sessionId, msg, forceClose }: OutputPayload): void { + processClose({ sessionId, forceClose, msg }: OutputPayload): void { const session = this.sessionManager.getSession(sessionId); // 无需处理 (直接关闭 tab) if (!session) { diff --git a/orion-visor-ui/src/views/host/terminal/handler/terminal-session-manager.ts b/orion-visor-ui/src/views/host/terminal/handler/terminal-session-manager.ts index 52309f4d..3bcd820e 100644 --- a/orion-visor-ui/src/views/host/terminal/handler/terminal-session-manager.ts +++ b/orion-visor-ui/src/views/host/terminal/handler/terminal-session-manager.ts @@ -19,17 +19,17 @@ import SftpSession from './sftp-session'; // 终端会话管理器实现 export default class TerminalSessionManager implements ITerminalSessionManager { - private readonly channel: ITerminalChannel; + public sessions: Record; - private sessions: Record; + private readonly channel: ITerminalChannel; private keepAliveTaskId?: any; private readonly dispatchResizeFn: () => {}; constructor() { - this.channel = new TerminalChannel(this); this.sessions = {}; + this.channel = new TerminalChannel(this); this.dispatchResizeFn = useDebounceFn(this.dispatchResize).bind(this); } diff --git a/orion-visor-ui/src/views/host/terminal/types/terminal.const.ts b/orion-visor-ui/src/views/host/terminal/types/terminal.const.ts index 6c0452e0..b48918d1 100644 --- a/orion-visor-ui/src/views/host/terminal/types/terminal.const.ts +++ b/orion-visor-ui/src/views/host/terminal/types/terminal.const.ts @@ -352,6 +352,9 @@ export const TransferReceiverType = { DOWNLOAD_ERROR: 'downloadError', }; +// 会话关闭信息 +export const sessionCloseMsg = 'session closed...'; + // 打开 settingModal key export const openSettingModalKey = Symbol(); diff --git a/orion-visor-ui/src/views/host/terminal/types/terminal.protocol.ts b/orion-visor-ui/src/views/host/terminal/types/terminal.protocol.ts index a56a3142..a9abebdf 100644 --- a/orion-visor-ui/src/views/host/terminal/types/terminal.protocol.ts +++ b/orion-visor-ui/src/views/host/terminal/types/terminal.protocol.ts @@ -1,3 +1,8 @@ +import type { InputPayload, OutputPayload, Protocol } from './terminal.type'; + +// 分隔符 +export const SEPARATOR = '|'; + // 输入协议 export const InputProtocol = { // 主机连接检查 @@ -164,3 +169,52 @@ export const OutputProtocol = { processMethod: 'processSftpSetContent' }, }; + +// 解析参数 +export const parse = (payload: string) => { + const protocols = Object.values(OutputProtocol); + const useProtocol = protocols.find(p => payload.startsWith(p.type + SEPARATOR) || p.type === payload); + if (!useProtocol) { + return undefined; + } + const template = useProtocol.template; + const res = {} as OutputPayload; + let curr = 0; + let len = payload.length; + for (let i = 0, pl = template.length; i < pl; i++) { + if (i == pl - 1) { + // 最后一次 + res[template[i]] = payload.substring(curr, len); + } else { + // 非最后一次 + let tmp = ''; + for (; curr < len; curr++) { + const c = payload.charAt(curr); + if (c == SEPARATOR) { + res[template[i]] = tmp; + curr++; + break; + } else { + tmp += c; + } + } + } + } + return res; +}; + +// 格式化参数 +export const format = (protocol: Protocol, payload: InputPayload | OutputPayload) => { + payload.type = protocol.type; + return protocol.template + .map(i => getPayloadValueString(payload[i])) + .join(SEPARATOR); +}; + +// 获取默认值 +export const getPayloadValueString = (value: unknown): any => { + if (value === undefined || value === null) { + return ''; + } + return value; +}; diff --git a/orion-visor-ui/src/views/host/terminal/types/terminal.type.ts b/orion-visor-ui/src/views/host/terminal/types/terminal.type.ts index a8acb4bf..e1668a8d 100644 --- a/orion-visor-ui/src/views/host/terminal/types/terminal.type.ts +++ b/orion-visor-ui/src/views/host/terminal/types/terminal.type.ts @@ -153,6 +153,9 @@ export interface ITerminalPanelManager { // 终端会话管理器定义 export interface ITerminalSessionManager { + // 全部会话 + sessions: Record; + // 打开 ssh 会话 openSsh: (tab: TerminalPanelTabItem, domRef: XtermDomRef) => Promise; // 打开 sftp 会话 From c9cbc5fd557516fa47ed25f0e6293e5585c038b5 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Tue, 11 Jun 2024 12:50:42 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bookmark:=20=E5=8D=87=E7=BA=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 6 +++--- docker/orion-visor-mysql/build.sh | 2 +- docker/orion-visor-redis/build.sh | 2 +- docker/orion-visor-service/build.sh | 2 +- orion-visor-dependencies/pom.xml | 2 +- .../com/orion/visor/framework/common/constant/AppConst.java | 2 +- orion-visor-ui/.env.development | 3 ++- orion-visor-ui/.env.production | 3 ++- orion-visor-ui/package.json | 2 +- orion-visor-ui/src/components/app/app-footer/index.vue | 3 ++- orion-visor-ui/src/env.d.ts | 1 + pom.xml | 2 +- 12 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 85085b05..705b773b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.3' services: orion-visor-service: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.5 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.6 ports: - 1081:80 environment: @@ -20,7 +20,7 @@ services: - orion-visor-mysql - orion-visor-redis orion-visor-mysql: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.5 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.6 privileged: true ports: - 3307:3306 @@ -34,7 +34,7 @@ services: - /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql-files:/var/lib/mysql-files - /data/orion-visor-space/docker-volumes/orion-visor-mysql/etc-mysql:/etc/mysql orion-visor-redis: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.5 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.6 privileged: true ports: - 6380:6379 diff --git a/docker/orion-visor-mysql/build.sh b/docker/orion-visor-mysql/build.sh index 4f267ddb..960d3eda 100644 --- a/docker/orion-visor-mysql/build.sh +++ b/docker/orion-visor-mysql/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.5 +version=2.0.6 cp -r ../../sql ./sql docker build -t orion-visor-mysql:${version} . rm -rf ./sql diff --git a/docker/orion-visor-redis/build.sh b/docker/orion-visor-redis/build.sh index 61ab0bad..cef014d5 100644 --- a/docker/orion-visor-redis/build.sh +++ b/docker/orion-visor-redis/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.5 +version=2.0.6 docker build -t orion-visor-redis:${version} . docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version} docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version} diff --git a/docker/orion-visor-service/build.sh b/docker/orion-visor-service/build.sh index 13bafc9d..f8fea604 100644 --- a/docker/orion-visor-service/build.sh +++ b/docker/orion-visor-service/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.5 +version=2.0.6 mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar mv ../../orion-visor-ui/dist ./dist docker build -t orion-visor-service:${version} . diff --git a/orion-visor-dependencies/pom.xml b/orion-visor-dependencies/pom.xml index eaf501a6..10503d6c 100644 --- a/orion-visor-dependencies/pom.xml +++ b/orion-visor-dependencies/pom.xml @@ -14,7 +14,7 @@ https://github.com/lijiahangmax/orion-visor - 2.0.5 + 2.0.6 2.7.17 2.7.15 1.5.0 diff --git a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java index fbec7e9b..33851407 100644 --- a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java +++ b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java @@ -14,7 +14,7 @@ public interface AppConst extends OrionConst { /** * 同 ${orion.version} 迭代时候需要手动更改 */ - String VERSION = "2.0.5"; + String VERSION = "2.0.6"; String ORION_VISOR = "orion-visor"; diff --git a/orion-visor-ui/.env.development b/orion-visor-ui/.env.development index 6067f583..ad5823d0 100644 --- a/orion-visor-ui/.env.development +++ b/orion-visor-ui/.env.development @@ -1,5 +1,6 @@ VITE_API_BASE_URL= 'http://127.0.0.1:9200/orion-visor/api' VITE_WS_BASE_URL= 'ws://127.0.0.1:9200/orion-visor/keep-alive' -VITE_APP_VERSION= '2.0.5' +VITE_APP_VERSION= '2.0.6' +VITE_APP_RELEASE= 'Community' VITE_SFTP_PREVIEW_MB= 2 VITE_DEMO_MODE= false diff --git a/orion-visor-ui/.env.production b/orion-visor-ui/.env.production index 080e62ee..dc1245e0 100644 --- a/orion-visor-ui/.env.production +++ b/orion-visor-ui/.env.production @@ -1,5 +1,6 @@ VITE_API_BASE_URL= '/orion-visor/api' VITE_WS_BASE_URL= '/orion-visor/keep-alive' -VITE_APP_VERSION= '2.0.5' +VITE_APP_VERSION= '2.0.6' +VITE_APP_RELEASE= 'Community' VITE_SFTP_PREVIEW_MB= 2 VITE_DEMO_MODE= false diff --git a/orion-visor-ui/package.json b/orion-visor-ui/package.json index 1ed44479..30435206 100644 --- a/orion-visor-ui/package.json +++ b/orion-visor-ui/package.json @@ -1,7 +1,7 @@ { "name": "orion-visor-ui", "description": "Orion Visor UI", - "version": "2.0.5", + "version": "2.0.6", "private": true, "author": "Jiahang Li", "license": "Apache 2.0", diff --git a/orion-visor-ui/src/components/app/app-footer/index.vue b/orion-visor-ui/src/components/app/app-footer/index.vue index e99d2c52..50257901 100644 --- a/orion-visor-ui/src/components/app/app-footer/index.vue +++ b/orion-visor-ui/src/components/app/app-footer/index.vue @@ -6,7 +6,7 @@ gitee 文档 License - v{{ version }} Community + v{{ version }} {{ release }} Copyright 2023 - {{ new Date().getFullYear() }} Li Jiahang, All rights reserved. @@ -17,6 +17,7 @@