feat: 新功能与配置优化

- QQscTool: 支持多文件和目录解析,通过 GetFileList API 实现递归目录导航
- Home: 从粘贴文本中自动提取分享链接
- DirectoryTree: 目录浏览添加复制直链按钮
- domainName 改为可选,未配置时自动从请求地址推断
- 统一版本号管理,GitHub URL 构建时自动从 git remote origin 识别
- vue.config.js 添加前端构建配置,sync-version.js 构建时同步版本号
This commit is contained in:
yukaidi
2026-05-29 14:21:32 +08:00
parent 17460ff271
commit 0978186679
18 changed files with 418 additions and 135 deletions

View File

@@ -68,7 +68,8 @@ public class ServerApi {
key = keys[0];
pwd = keys[1];
}
return cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent")));
String origin = resolveOrigin(request);
return cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent"), "_requestOrigin", origin));
}
@RouteMapping(value = "/:type/:key", method = RouteMethod.GET)
@@ -80,7 +81,8 @@ public class ServerApi {
key = keys[0];
pwd = keys[1];
}
cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent")))
String origin = resolveOrigin(request);
cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent"), "_requestOrigin", origin))
.onSuccess(res -> ResponseUtil.redirect(
response.putHeader("nfd-cache-hit", res.getCacheHit().toString())
.putHeader("nfd-cache-expires", res.getExpires()),
@@ -89,6 +91,21 @@ public class ServerApi {
return promise.future();
}
/**
* 解析请求来源地址,支持反向代理
*/
private static String resolveOrigin(HttpServerRequest request) {
String forwardedHost = request.getHeader("X-Forwarded-Host");
if (forwardedHost != null && !forwardedHost.isBlank()) {
String proto = request.getHeader("X-Forwarded-Proto");
if (proto == null || proto.isBlank()) {
proto = request.scheme();
}
return proto + "://" + forwardedHost;
}
return request.scheme() + "://" + request.host();
}
/**
* 构建 otherParam包含 UA 和解码后的认证参数
*
@@ -97,7 +114,7 @@ public class ServerApi {
* @return JsonObject
*/
private JsonObject buildOtherParam(HttpServerRequest request, String auth) {
JsonObject otherParam = JsonObject.of("UA", request.headers().get("user-agent"));
JsonObject otherParam = JsonObject.of("UA", request.headers().get("user-agent"), "_requestOrigin", resolveOrigin(request));
// 解码认证参数
if (auth != null && !auth.isEmpty()) {

View File

@@ -4,13 +4,12 @@ server:
contextPath: /
# 使用数据库
enableDatabase: true
# 服务域名或者IP 生成二维码链接时需要
domainName: http://127.0.0.1:6401
# 服务域名或者IP 生成二维码链接时需要,不设置则自动从请求地址获取
# domainName: http://127.0.0.1:6401
# 预览服务URL
previewURL: https://nfd-parser.github.io/nfd-preview/preview.html?src=
# auth参数加密密钥16位AES密钥
authEncryptKey: 'nfd_auth_key2026'
# domainName: https://lz.qaiu.top
# 反向代理服务器配置路径(不用加后缀)
proxyConf: server-proxy