mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
feat: 新功能与配置优化
- QQscTool: 支持多文件和目录解析,通过 GetFileList API 实现递归目录导航 - Home: 从粘贴文本中自动提取分享链接 - DirectoryTree: 目录浏览添加复制直链按钮 - domainName 改为可选,未配置时自动从请求地址推断 - 统一版本号管理,GitHub URL 构建时自动从 git remote origin 识别 - vue.config.js 添加前端构建配置,sync-version.js 构建时同步版本号
This commit is contained in:
@@ -16,6 +16,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
@@ -62,7 +64,12 @@ public final class Deploy {
|
||||
path.append("-").append(args[0].replace("app-",""));
|
||||
}
|
||||
|
||||
// 读取yml配置
|
||||
// 读取yml配置,优先当前目录,其次 resources/ 子目录
|
||||
String configFile = path + ".yml";
|
||||
if (!Files.exists(Path.of(configFile)) && Files.exists(Path.of("resources", configFile))) {
|
||||
path.insert(0, "resources/");
|
||||
LOGGER.info("从 resources/ 目录加载配置: {}", path + ".yml");
|
||||
}
|
||||
ConfigUtil.readYamlConfig(path.toString(), tempVertx)
|
||||
.onSuccess(this::readConf)
|
||||
.onFailure(err -> {
|
||||
|
||||
@@ -153,7 +153,7 @@ public class CommonUtil {
|
||||
appVersion = properties.getProperty("app.version") + "build" + properties.getProperty("build");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("读取app.properties失败", e);
|
||||
}
|
||||
}
|
||||
return appVersion;
|
||||
|
||||
@@ -10,6 +10,8 @@ import io.vertx.core.json.JsonObject;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* 异步读取配置工具类
|
||||
@@ -62,12 +64,35 @@ public class ConfigUtil {
|
||||
// 异步获取配置
|
||||
// 成功直接完成 promise
|
||||
retriever.getConfig()
|
||||
.onSuccess(promise::complete)
|
||||
.onFailure(err -> {
|
||||
// 配置读取失败,直接返回失败 Future
|
||||
promise.fail(new RuntimeException(
|
||||
"读取配置文件失败: " + path, err));
|
||||
.onSuccess(config -> {
|
||||
promise.complete(config);
|
||||
retriever.close();
|
||||
})
|
||||
.onFailure(err -> {
|
||||
retriever.close();
|
||||
// 读取失败时,尝试从 resources/ 子目录读取(兼容 Docker 卷挂载场景)
|
||||
String resourcesPath = "resources/" + path;
|
||||
if (!path.startsWith("resources/") && Files.exists(Path.of(resourcesPath))) {
|
||||
ConfigStoreOptions fallbackStore = new ConfigStoreOptions()
|
||||
.setType("file")
|
||||
.setFormat(format)
|
||||
.setConfig(new JsonObject().put("path", resourcesPath));
|
||||
ConfigRetriever fallbackRetriever = ConfigRetriever
|
||||
.create(vertx, new ConfigRetrieverOptions().addStore(fallbackStore));
|
||||
fallbackRetriever.getConfig()
|
||||
.onSuccess(config -> {
|
||||
promise.complete(config);
|
||||
fallbackRetriever.close();
|
||||
})
|
||||
.onFailure(e2 -> {
|
||||
promise.fail(new RuntimeException(
|
||||
"读取配置文件失败: " + path + " (也尝试了 " + resourcesPath + ")", e2));
|
||||
fallbackRetriever.close();
|
||||
});
|
||||
} else {
|
||||
promise.fail(new RuntimeException(
|
||||
"读取配置文件失败: " + path, err));
|
||||
}
|
||||
});
|
||||
|
||||
return promise.future();
|
||||
|
||||
@@ -25,6 +25,9 @@ import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
|
||||
|
||||
/**
|
||||
@@ -36,6 +39,8 @@ import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
|
||||
*/
|
||||
public final class ReflectionUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionUtil.class);
|
||||
|
||||
// 缓存Reflections实例,避免重复扫描(每次扫描约35K+值,耗时1-3秒,占用大量内存)
|
||||
private static final Map<String, Reflections> REFLECTIONS_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
|
||||
|
||||
@@ -128,7 +133,7 @@ public final class ReflectionUtil {
|
||||
parameterTypes[j - k]));
|
||||
}
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("获取方法参数失败", e);
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
@@ -183,7 +188,7 @@ public final class ReflectionUtil {
|
||||
try {
|
||||
return DateUtils.parseDate(value, fmt);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("日期解析失败: {}", value, e);
|
||||
throw new RuntimeException("无法将格式化日期");
|
||||
}
|
||||
default:
|
||||
@@ -215,7 +220,7 @@ public final class ReflectionUtil {
|
||||
}
|
||||
return arr;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("数组类型转换失败: {}", value, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class HttpProxyVerticle extends AbstractVerticle {
|
||||
);
|
||||
})
|
||||
.onFailure(err -> {
|
||||
err.printStackTrace();
|
||||
LOGGER.error("HTTP请求失败", err);
|
||||
clientRequest.response().setStatusCode(502).end("Bad Gateway: Request failed");
|
||||
});
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class HttpProxyVerticle extends AbstractVerticle {
|
||||
}
|
||||
return port;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("提取端口失败: {}", urlString, e);
|
||||
// 出现异常时返回 -1,表示提取失败
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user