🎨 优化项目模块.

This commit is contained in:
lijiahang
2025-01-09 10:02:22 +08:00
parent 41797e41d2
commit 72579c7e83
11 changed files with 94 additions and 19 deletions

View File

@@ -105,4 +105,6 @@ public interface FieldConst {
String ALL = "all";
String CONFIG = "config";
}

View File

@@ -114,6 +114,25 @@ public interface FileClient {
*/
byte[] getContent(String path) throws Exception;
/**
* 获取文件内容
*
* @param path path
* @return content
* @throws Exception Exception
*/
String getContentAsString(String path) throws Exception;
/**
* 获取文件内容
*
* @param path path
* @param charset charset
* @return content
* @throws Exception Exception
*/
String getContentAsString(String path, String charset) throws Exception;
/**
* 获取文件输入流
*

View File

@@ -32,11 +32,11 @@ import org.dromara.visor.common.interfaces.RsaEncryptor;
* @version 1.0.0
* @since 2025/1/5 21:13
*/
public class RsaEncryptorUtils {
public class RsaEncryptUtils {
private static RsaEncryptor delegate;
private RsaEncryptorUtils() {
private RsaEncryptUtils() {
}
/**
@@ -60,11 +60,11 @@ public class RsaEncryptorUtils {
}
public static void setDelegate(RsaEncryptor delegate) {
if (RsaEncryptorUtils.delegate != null) {
if (RsaEncryptUtils.delegate != null) {
// unmodified
throw Exceptions.state();
}
RsaEncryptorUtils.delegate = delegate;
RsaEncryptUtils.delegate = delegate;
}
}

View File

@@ -23,8 +23,10 @@
package org.dromara.visor.framework.biz.operator.log.core.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import cn.orionsec.kit.lang.utils.Strings;
import cn.orionsec.kit.lang.utils.collect.Maps;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeFilter;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.security.LoginUser;
@@ -74,7 +76,7 @@ public class OperatorLogs implements ExtraFieldConst {
* @param value value
*/
public static void addJson(String key, Object value) {
EXTRA_HOLDER.get().put(key, JSON.parseObject(JSON.toJSONString(value, serializeFilters)));
EXTRA_HOLDER.get().put(key, JSON.parseObject(toJsonString(value)));
}
/**
@@ -96,13 +98,25 @@ public class OperatorLogs implements ExtraFieldConst {
if (obj == null) {
return;
}
if (obj instanceof Map) {
if (obj instanceof JSONObject || obj instanceof com.alibaba.fastjson2.JSONObject) {
EXTRA_HOLDER.get().putAll(JSON.parseObject(toJsonString(obj)));
} else if (obj instanceof Map) {
EXTRA_HOLDER.get().putAll((Map<String, ?>) obj);
} else {
EXTRA_HOLDER.get().putAll(JSON.parseObject(JSON.toJSONString(obj, serializeFilters)));
EXTRA_HOLDER.get().putAll(JSON.parseObject(toJsonString(obj)));
}
}
/**
* 获取 json
*
* @param value value
* @return json
*/
public static String toJsonString(Object value) {
return JSON.toJSONString(value, serializeFilters);
}
/**
* 设置不保存
*/
@@ -167,6 +181,29 @@ public class OperatorLogs implements ExtraFieldConst {
USER_HOLDER.remove();
}
/**
* 清空 html tag
*
* @param log log
* @return cleared
*/
public static String clearHtmlTag(String log) {
if (Strings.isBlank(log)) {
return log;
}
return log.replaceAll("<sb 0>", "")
.replaceAll("<sb 2>", "")
.replaceAll("<sb>", "")
.replaceAll("</sb>", "")
.replaceAll("<sr 0>", "")
.replaceAll("<sr 2>", "")
.replaceAll("<sr>", "")
.replaceAll("</sr>", "")
.replaceAll("<b>", "")
.replaceAll("</b>", "")
.replaceAll("<br/>", "\n");
}
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
if (OperatorLogs.serializeFilters != null) {
// unmodified

View File

@@ -27,7 +27,7 @@ import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.interfaces.AesEncryptor;
import org.dromara.visor.common.interfaces.RsaEncryptor;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.RsaEncryptorUtils;
import org.dromara.visor.common.utils.RsaEncryptUtils;
import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
import org.dromara.visor.framework.encrypt.core.impl.AesEncryptorImpl;
import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
@@ -70,7 +70,7 @@ public class OrionEncryptAutoConfiguration {
// 加密器
RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
// 设置工具类
RsaEncryptorUtils.setDelegate(encryptor);
RsaEncryptUtils.setDelegate(encryptor);
return encryptor;
}

View File

@@ -79,6 +79,16 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
}
}
@Override
public String getContentAsString(String path) throws Exception {
return this.getContentAsString(path, Const.UTF_8);
}
@Override
public String getContentAsString(String path, String charset) throws Exception {
return new String(this.getContent(path), charset);
}
@Override
public OutputStream getContentOutputStream(String path) throws Exception {
return this.getContentOutputStream(path, false);

View File

@@ -32,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Profile;
import java.net.InetAddress;
import java.util.function.Supplier;
/**
@@ -52,7 +53,7 @@ public class OrionMockRedisTestConfiguration {
*/
@Bean
public RedisServer redisMockServer(RedisProperties properties) {
RedisServer server = new RedisServer(properties.getPort());
RedisServer server = new RedisServer(properties.getPort(), InetAddress.getLoopbackAddress());
try {
server.start();
} catch (Exception ignore) {

View File

@@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.utils.RsaEncryptorUtils;
import org.dromara.visor.common.utils.RsaEncryptUtils;
import org.dromara.visor.common.utils.Valid;
import java.io.IOException;
@@ -51,7 +51,7 @@ public class ParamDecryptDeserializer extends JsonDeserializer<String> {
return value;
}
// 解密参数
String decrypt = RsaEncryptorUtils.decrypt(value);
String decrypt = RsaEncryptUtils.decrypt(value);
return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
}

View File

@@ -115,7 +115,7 @@ public class ReplaceVersion {
*/
private static void replaceViteEnvFiles() {
for (String file : VITE_ENV_FILES) {
readAndWrite(file, s -> s.replaceAll("VITE_APP_VERSION= '" + TARGET_VERSION + "'", "VITE_APP_VERSION= '" + REPLACE_VERSION + "'"));
readAndWrite(file, s -> s.replaceAll("VITE_APP_VERSION=" + TARGET_VERSION, "VITE_APP_VERSION=" + REPLACE_VERSION));
}
}

View File

@@ -1,3 +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.2.3'
# api 路径
VITE_API_BASE_URL=http://127.0.0.1:9200/orion-visor/api
# websocket 路径
VITE_WS_BASE_URL=ws://127.0.0.1:9200/orion-visor/keep-alive
# 版本号
VITE_APP_VERSION=2.2.3

View File

@@ -1,3 +1,6 @@
VITE_API_BASE_URL= '/orion-visor/api'
VITE_WS_BASE_URL= '/orion-visor/keep-alive'
VITE_APP_VERSION= '2.2.3'
# api 路径
VITE_API_BASE_URL=/orion-visor/api
# websocket 路径
VITE_WS_BASE_URL=/orion-visor/keep-alive
# 版本号
VITE_APP_VERSION=2.2.3