Skip to content

Commit 42ff0c2

Browse files
author
q
committed
1. 默认缓存时间修改
2. 文件夹解析异常处理 3. 首页优化
1 parent fad8e68 commit 42ff0c2

File tree

6 files changed

+69
-46
lines changed

6 files changed

+69
-46
lines changed

bin/build.bat

Lines changed: 0 additions & 22 deletions
This file was deleted.

parser/src/main/java/cn/qaiu/parser/impl/FjTool.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Future<String> parse() {
149149
.setTemplateParam("ts", tsEncode2)
150150
.setTemplateParam("auth", auth)
151151
.setTemplateParam("dataKey", shareId);
152-
System.out.println(httpRequest.toString());
152+
// System.out.println(httpRequest.toString());
153153
httpRequest.send().onSuccess(res2 -> {
154154
MultiMap headers = res2.headers();
155155
if (!headers.contains("Location")) {
@@ -179,7 +179,11 @@ public Future<List<FileInfo>> parseFileList() {
179179
return promise.future();
180180
}
181181
parse().onSuccess(id -> {
182-
parserDir(id, shareId, promise);
182+
if (id != null && id.matches("^[a-zA-Z0-9]+$")) {
183+
parserDir(id, shareId, promise);
184+
} else {
185+
promise.fail("解析目录ID失败");
186+
}
183187
}).onFailure(failRes -> {
184188
log.error("解析目录失败: {}", failRes.getMessage());
185189
promise.fail(failRes);
@@ -198,8 +202,14 @@ private void parserDir(String id, String shareId, Promise<List<FileInfo>> promis
198202
.setTemplateParam("ts", tsEncode)
199203
.setTemplateParam("folderId", id)
200204
.send().onSuccess(res -> {
201-
JsonObject jsonObject = asJson(res);
202-
System.out.println(jsonObject.encodePrettily());
205+
JsonObject jsonObject;
206+
try {
207+
jsonObject = asJson(res);
208+
} catch (Exception e) {
209+
promise.fail(FIRST_REQUEST_URL + " 解析JSON失败: " + res.bodyAsString());
210+
return;
211+
}
212+
// System.out.println(jsonObject.encodePrettily());
203213
JsonArray list = jsonObject.getJsonArray("list");
204214
ArrayList<FileInfo> result = new ArrayList<>();
205215
list.forEach(item->{
@@ -269,7 +279,10 @@ private void parserDir(String id, String shareId, Promise<List<FileInfo>> promis
269279
result.add(fileInfo);
270280
});
271281
promise.complete(result);
272-
});
282+
}).onFailure(failRes -> {
283+
log.error("解析目录请求失败: {}", failRes.getMessage());
284+
promise.fail(failRes);
285+
});;
273286
}
274287

275288
@Override

parser/src/main/java/cn/qaiu/parser/impl/IzTool.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ public Future<List<FileInfo>> parseFileList() {
158158
return promise.future();
159159
}
160160
parse().onSuccess(id -> {
161-
parserDir(id, shareId, promise);
161+
if (id != null && id.matches("^[a-zA-Z0-9]+$")) {
162+
parserDir(id, shareId, promise);
163+
} else {
164+
promise.fail("解析目录ID失败");
165+
}
162166
}).onFailure(failRes -> {
163167
log.error("解析目录失败: {}", failRes.getMessage());
164168
promise.fail(failRes);
@@ -177,8 +181,14 @@ private void parserDir(String id, String shareId, Promise<List<FileInfo>> promis
177181
.setTemplateParam("ts", tsEncode)
178182
.setTemplateParam("folderId", id)
179183
.send().onSuccess(res -> {
180-
JsonObject jsonObject = asJson(res);
181-
System.out.println(jsonObject.encodePrettily());
184+
JsonObject jsonObject;
185+
try {
186+
jsonObject = asJson(res);
187+
} catch (Exception e) {
188+
promise.fail(FIRST_REQUEST_URL + " 解析JSON失败: " + res.bodyAsString());
189+
return;
190+
}
191+
// System.out.println(jsonObject.encodePrettily());
182192
JsonArray list = jsonObject.getJsonArray("list");
183193
ArrayList<FileInfo> result = new ArrayList<>();
184194
list.forEach(item->{
@@ -244,6 +254,9 @@ private void parserDir(String id, String shareId, Promise<List<FileInfo>> promis
244254
result.add(fileInfo);
245255
});
246256
promise.complete(result);
257+
}).onFailure(failRes -> {
258+
log.error("解析目录请求失败: {}", failRes.getMessage());
259+
promise.fail(failRes);
247260
});
248261
}
249262

web-front/src/views/Home.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</div>
4949
<!-- 项目简介移到卡片内 -->
5050
<div class="project-intro">
51-
<div class="intro-title">NFD网盘直链解析0.1.9_bate6</div>
51+
<div class="intro-title">NFD网盘直链解析0.1.9_bate7</div>
5252
<div class="intro-desc">
5353
<div>支持网盘:蓝奏云、蓝奏云优享、小飞机盘、123云盘、奶牛快传、移动云空间、亿方云、文叔叔、QQ邮箱文件中转站等</div>
5454
<div>文件夹解析支持:蓝奏云、蓝奏云优享、小飞机盘、123云盘</div>
@@ -161,6 +161,9 @@
161161
<el-descriptions-item label="302下载链接">
162162
<el-link target="_blank" :href="statisticsData.downLink">{{ statisticsData.downLink }}</el-link>
163163
</el-descriptions-item>
164+
<el-descriptions-item label="302预览链接">
165+
<el-link target="_blank" :href="statisticsData.viewLink">{{ statisticsData.viewLink }}</el-link>
166+
</el-descriptions-item>
164167
<el-descriptions-item label="解析次数">{{ statisticsData.parserTotal }}</el-descriptions-item>
165168
<el-descriptions-item label="缓存命中次数">{{ statisticsData.cacheHitTotal }}</el-descriptions-item>
166169
<el-descriptions-item label="总请求次数">{{ statisticsData.sumTotal }}</el-descriptions-item>
@@ -187,13 +190,19 @@
187190
</el-card>
188191
</el-row>
189192
<!-- 文件解析结果区下方加分享按钮 -->
190-
<div v-if="parseResult.code && downloadUrl" style="margin-top: 10px; text-align: right;">
191-
<el-button type="primary" @click="copyShowFileLink">分享文件直链</el-button>
192-
</div>
193+
<!-- <div v-if="parseResult.code && downloadUrl" style="margin-top: 10px; text-align: right;">-->
194+
<!-- <el-button type="primary" @click="copyShowFileLink">分享文件直链</el-button>-->
195+
<!-- </div>-->
193196
<!-- 目录解析结果区下方加分享按钮 -->
194-
<div v-if="showDirectoryTree && directoryData.length" style="margin-top: 10px; text-align: right;">
195-
<el-button type="primary" @click="copyShowListLink">分享目录直链</el-button>
196-
</div>
197+
<!-- <div v-if="showDirectoryTree && directoryData.length" style="margin-top: 10px; text-align: right;">-->
198+
<!-- <el-input :value="showListLink" readonly style="width: 350px; margin-right: 10px;">-->
199+
<!-- <template #append>-->
200+
<!-- <el-button v-clipboard:copy="showListLink" v-clipboard:success="onCopy" v-clipboard:error="onError">-->
201+
<!-- <el-icon><CopyDocument /></el-icon>复制分享链接-->
202+
<!-- </el-button>-->
203+
<!-- </template>-->
204+
<!-- </el-input>-->
205+
<!-- </div>-->
197206
</div>
198207
</template>
199208

@@ -246,7 +255,8 @@ export default {
246255
directoryViewMode: 'pane', // 新增,目录树展示模式
247256
hasClipboardSuccessTip: false, // 新增,聚焦期间只提示一次
248257
showRiskDialog: false,
249-
baseUrl: location.origin
258+
baseUrl: location.origin,
259+
showListLink: '',
250260
}
251261
},
252262
methods: {
@@ -334,7 +344,9 @@ export default {
334344
const directoryResult = await this.callAPI('/v2/getFileList', params)
335345
this.directoryData = directoryResult.data || []
336346
this.showDirectoryTree = true
337-
347+
// 自动赋值分享链接
348+
this.showListLink = `${this.baseUrl}/showList?url=${encodeURIComponent(this.link)}`
349+
338350
this.$message.success(`目录解析成功!共找到 ${this.directoryData.length} 个文件/文件夹`)
339351
} catch (error) {
340352
console.error('目录解析失败:', error)

web-service/src/main/java/cn/qaiu/lz/web/controller/ParserApi.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public Future<StatisticsInfo> statisticsInfo() {
4646
}
4747

4848
private final CacheManager cacheManager = new CacheManager();
49+
private final ServerApi serverApi = new ServerApi();
4950

5051
@RouteMapping(value = "/linkInfo", method = RouteMethod.GET)
5152
public Future<LinkInfoResp> parse(HttpServerRequest request, String pwd) {
@@ -56,6 +57,7 @@ public Future<LinkInfoResp> parse(HttpServerRequest request, String pwd) {
5657
LinkInfoResp build = LinkInfoResp.builder()
5758
.downLink(getDownLink(parserCreate, false))
5859
.apiLink(getDownLink(parserCreate, true))
60+
.viewLink(getViewLink(parserCreate))
5961
.shareLinkInfo(shareLinkInfo).build();
6062
// 解析次数统计
6163
shareLinkInfo.getOtherParam().put("UA",request.headers().get("user-agent"));
@@ -83,6 +85,15 @@ private static String getDownLink(ParserCreate create, boolean isJson) {
8385
return linkPrefix + (isJson ? "/json/" : "/d/") + create.genPathSuffix();
8486
}
8587

88+
private static String getViewLink(ParserCreate create) {
89+
90+
String linkPrefix = SharedDataUtil.getJsonStringForServerConfig("domainName");
91+
if (StringUtils.isBlank(linkPrefix)) {
92+
return "";
93+
}
94+
return linkPrefix + "/v2/view/" + create.genPathSuffix();
95+
}
96+
8697
/**
8798
* 获取支持的网盘列表
8899
* @return list-map: name: 网盘名, type: 网盘标识, url: 网盘域名地址
@@ -151,7 +162,7 @@ public Future<Void> redirectUrl(HttpServerResponse response, String type, String
151162
@RouteMapping(value = "/view/:type/:key", method = RouteMethod.GET, order = 2)
152163
public void view(HttpServerRequest request, HttpServerResponse response, String type, String key) {
153164
String previewURL = SharedDataUtil.getJsonStringForServerConfig("previewURL");
154-
new ServerApi().parseKeyJson(request, type, key).onSuccess(res -> {
165+
serverApi.parseKeyJson(request, type, key).onSuccess(res -> {
155166
redirect(response, previewURL, res);
156167
}).onFailure(e -> {
157168
ResponseUtil.fireJsonResultResponse(response, JsonResult.error(e.toString()));
@@ -164,7 +175,7 @@ private static void redirect(HttpServerResponse response, String previewURL, Cac
164175
}
165176

166177
/**
167-
* 预览媒体文件
178+
* 预览媒体文件-目录预览
168179
*/
169180
@RouteMapping(value = "/preview", method = RouteMethod.GET, order = 9)
170181
public void viewURL(HttpServerRequest request, HttpServerResponse response, String pwd) {

web-service/src/main/resources/app-dev.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cache:
6363
# 该配置未使用,后续加入其他Cache实现时,区分类型
6464
type: h2db
6565
# 默认时长: 单位分钟,大部分网盘未严格验证,建议不要太大
66-
defaultDuration: 59
66+
defaultDuration: 5
6767
# 具体网盘的缓存配置,如果不加配置则不缓存,每次请求都会请求网盘API,格式:网盘标识: 时长
6868
duration:
6969
ce: 5
@@ -93,7 +93,3 @@ proxy:
9393
# username:
9494
# password:
9595

96-
97-
# 代理池配置
98-
#ip-pool:
99-
# api-url:

0 commit comments

Comments
 (0)