🔨 重构终端前端逻辑

This commit is contained in:
lijiahangmax
2024-02-02 01:07:03 +08:00
parent 697de97473
commit ae52a556d9
20 changed files with 413 additions and 119 deletions

View File

@@ -1,5 +1,7 @@
package com.orion.ops.module.asset.handler.host.terminal.handler;
import com.orion.lang.exception.argument.InvalidArgumentException;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.collect.Maps;
import com.orion.ops.framework.biz.operator.log.core.service.OperatorLogFrameworkService;
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogFiller;
@@ -79,9 +81,12 @@ public class TerminalCheckHandler extends AbstractTerminalHandler<TerminalCheckR
// 设置到缓存中
channel.getAttributes().put(sessionId, connect);
log.info("TerminalCheckHandler-handle success userId: {}, hostId: {}, sessionId: {}", userId, hostId, sessionId);
} catch (Exception e) {
} catch (InvalidArgumentException e) {
ex = e;
log.error("TerminalCheckHandler-handle error userId: {}, hostId: {}, sessionId: {}", userId, hostId, sessionId, e);
} catch (Exception e) {
ex = Exceptions.runtime(ErrorMessage.CONNECT_ERROR);
log.error("TerminalCheckHandler-handle exception userId: {}, hostId: {}, sessionId: {}", userId, hostId, sessionId, e);
}
// 记录主机日志
this.saveTerminalLog(channel, userId, host, startTime, ex, sessionId);

View File

@@ -2,7 +2,6 @@
{
"name": "catppuccin-mocha",
"dark": true,
"headerBackgroundColor": "#121222",
"schema": {
"background": "#1E1E2E",
"foreground": "#CDD6F4",
@@ -27,7 +26,6 @@
{
"name": "MaterialDesignColors",
"dark": true,
"headerBackgroundColor": "#111A1E",
"schema": {
"background": "#1D262A",
"foreground": "#E7EBED",
@@ -52,7 +50,6 @@
{
"name": "catppuccin-macchiato",
"dark": true,
"headerBackgroundColor": "#181B2E",
"schema": {
"background": "#24273A",
"foreground": "#CAD3F5",
@@ -77,7 +74,6 @@
{
"name": "OneHalfDark",
"dark": true,
"headerBackgroundColor": "#1C2028",
"schema": {
"background": "#282C34",
"foreground": "#DCDFE4",
@@ -102,7 +98,6 @@
{
"name": "Dracula",
"dark": true,
"headerBackgroundColor": "#12131D",
"schema": {
"background": "#1E1F29",
"foreground": "#F8F8F2",
@@ -127,7 +122,6 @@
{
"name": "Atom",
"dark": true,
"headerBackgroundColor": "#0A0B0D",
"schema": {
"background": "#161719",
"foreground": "#C5C8C6",
@@ -152,7 +146,6 @@
{
"name": "Apple System Colors",
"dark": true,
"headerBackgroundColor": "#121212",
"schema": {
"background": "#1E1E1E",
"foreground": "#FFFFFF",
@@ -177,7 +170,6 @@
{
"name": "Builtin Tango Light",
"dark": false,
"headerBackgroundColor": "#F3F3F3",
"schema": {
"background": "#FFFFFF",
"foreground": "#000000",
@@ -202,7 +194,6 @@
{
"name": "Duotone Dark",
"dark": true,
"headerBackgroundColor": "#13111B",
"schema": {
"background": "#1F1D27",
"foreground": "#B7A1FF",
@@ -227,7 +218,6 @@
{
"name": "BlulocoLight",
"dark": false,
"headerBackgroundColor": "#EDEDED",
"schema": {
"background": "#F9F9F9",
"foreground": "#373A41",
@@ -252,7 +242,6 @@
{
"name": "Chester",
"dark": true,
"headerBackgroundColor": "#202A37",
"schema": {
"background": "#2C3643",
"foreground": "#FFFFFF",
@@ -277,7 +266,6 @@
{
"name": "CLRS",
"dark": false,
"headerBackgroundColor": "#F3F3F3",
"schema": {
"background": "#FFFFFF",
"foreground": "#262626",
@@ -302,7 +290,6 @@
{
"name": "Calamity",
"dark": true,
"headerBackgroundColor": "#231C27",
"schema": {
"background": "#2F2833",
"foreground": "#D5CED9",
@@ -327,7 +314,6 @@
{
"name": "Tomorrow",
"dark": false,
"headerBackgroundColor": "#F3F3F3",
"schema": {
"background": "#FFFFFF",
"foreground": "#4D4D4C",

View File

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.orion.lang.utils.Colors;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.io.FileReaders;
import com.orion.lang.utils.io.Files1;
@@ -59,8 +58,6 @@ public class TerminalThemeGenerator {
TerminalTheme theme = new TerminalTheme();
theme.setName(schema.getString("name"));
theme.setDark(Colors.isDarkColor(background));
// header 颜色为深 12
theme.setHeaderBackgroundColor(adjustColor(background, -12));
theme.setSchema(JSON.parseObject(JSON.toJSONString(schema), TerminalThemeSchema.class));
return theme;
}).collect(Collectors.toList());
@@ -113,8 +110,6 @@ public class TerminalThemeGenerator {
@JSONField(ordinal = 1)
private Boolean dark;
@JSONField(ordinal = 2)
private String headerBackgroundColor;
@JSONField(ordinal = 3)
private TerminalThemeSchema schema;
}
@@ -162,26 +157,4 @@ public class TerminalThemeGenerator {
private String brightWhite;
}
/**
* 调整颜色
*
* @param color color
* @param range 正数越浅 负数越深
* @return color
*/
private static String adjustColor(String color, int range) {
StringBuilder newColor = new StringBuilder("#");
for (int i = 0; i < 3; i++) {
int c = Integer.parseInt(color.substring(i * 2 + 1, i * 2 + 3), 16);
c += range;
if (c < 0) {
c = 0;
} else if (c > 255) {
c = 255;
}
newColor.append(Strings.leftPad(Integer.toString(c, 16), 2, "0"));
}
return newColor.toString();
}
}