diff --git a/parser/src/main/java/cn/qaiu/parser/PanBase.java b/parser/src/main/java/cn/qaiu/parser/PanBase.java
index 7742b4b..45d0d93 100644
--- a/parser/src/main/java/cn/qaiu/parser/PanBase.java
+++ b/parser/src/main/java/cn/qaiu/parser/PanBase.java
@@ -116,12 +116,21 @@ public abstract class PanBase implements IPanTool {
*/
protected void fail(Throwable t, String errorMsg, Object... args) {
try {
+ // 判断是否已经完成
+ if (promise.future().isComplete()) {
+ log.warn("Promise 已经完成, 无法再次失败: {}, {}", errorMsg, promise.future().cause());
+ return;
+ }
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
log.error("解析异常: " + s, t.fillInStackTrace());
promise.fail(baseMsg() + ": 解析异常: " + s + " -> " + t);
} catch (Exception e) {
log.error("ErrorMsg format fail. The parameter has been discarded", e);
log.error("解析异常: " + errorMsg, t.fillInStackTrace());
+ if (promise.future().isComplete()) {
+ log.warn("ErrorMsg format. Promise 已经完成, 无法再次失败: {}", errorMsg);
+ return;
+ }
promise.fail(baseMsg() + ": 解析异常: " + errorMsg + " -> " + t);
}
}
@@ -134,9 +143,18 @@ public abstract class PanBase implements IPanTool {
*/
protected void fail(String errorMsg, Object... args) {
try {
+ // 判断是否已经完成
+ if (promise.future().isComplete()) {
+ log.warn("Promise 已经完成, 无法再次失败: {}, {}", errorMsg, promise.future().cause());
+ return;
+ }
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
promise.fail(baseMsg() + " - 解析异常: " + s);
} catch (Exception e) {
+ if (promise.future().isComplete()) {
+ log.warn("ErrorMsg format. Promise 已经完成, 无法再次失败: {}", errorMsg);
+ return;
+ }
log.error("ErrorMsg format fail. The parameter has been discarded", e);
promise.fail(baseMsg() + " - 解析异常: " + errorMsg);
}
diff --git a/parser/src/main/java/cn/qaiu/parser/impl/FjTool.java b/parser/src/main/java/cn/qaiu/parser/impl/FjTool.java
index 949178d..54028ad 100644
--- a/parser/src/main/java/cn/qaiu/parser/impl/FjTool.java
+++ b/parser/src/main/java/cn/qaiu/parser/impl/FjTool.java
@@ -115,9 +115,17 @@ public class FjTool extends PanBase {
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
return;
}
+ if (!resJson.containsKey("list") || resJson.getJsonArray("list").isEmpty()) {
+ fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
+ return;
+ }
// 文件Id
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
// 如果是目录返回目录ID
+ if (!fileInfo.containsKey("fileList") || fileInfo.getJsonArray("fileList").isEmpty()) {
+ fail(FIRST_REQUEST_URL + " 文件列表为空: " + fileInfo);
+ return;
+ }
JsonObject fileList = fileInfo.getJsonArray("fileList").getJsonObject(0);
if (fileList.getInteger("fileType") == 2) {
promise.complete(fileList.getInteger("folderId").toString());
@@ -172,6 +180,9 @@ public class FjTool extends PanBase {
}
parse().onSuccess(id -> {
parserDir(id, shareId, promise);
+ }).onFailure(failRes -> {
+ log.error("解析目录失败: {}", failRes.getMessage());
+ promise.fail(failRes);
});
return promise.future();
}
diff --git a/parser/src/main/java/cn/qaiu/parser/impl/IzTool.java b/parser/src/main/java/cn/qaiu/parser/impl/IzTool.java
index d061806..7ad6890 100644
--- a/parser/src/main/java/cn/qaiu/parser/impl/IzTool.java
+++ b/parser/src/main/java/cn/qaiu/parser/impl/IzTool.java
@@ -101,9 +101,17 @@ public class IzTool extends PanBase {
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
return;
}
+ if (!resJson.containsKey("list") || resJson.getJsonArray("list").isEmpty()) {
+ fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
+ return;
+ }
// 文件Id
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
// 如果是目录返回目录ID
+ if (!fileInfo.containsKey("fileList") || fileInfo.getJsonArray("fileList").isEmpty()) {
+ fail(FIRST_REQUEST_URL + " 文件列表为空: " + fileInfo);
+ return;
+ }
JsonObject fileList = fileInfo.getJsonArray("fileList").getJsonObject(0);
if (fileList.getInteger("fileType") == 2) {
promise.complete(fileList.getInteger("folderId").toString());
@@ -151,6 +159,9 @@ public class IzTool extends PanBase {
}
parse().onSuccess(id -> {
parserDir(id, shareId, promise);
+ }).onFailure(failRes -> {
+ log.error("解析目录失败: {}", failRes.getMessage());
+ promise.fail(failRes);
});
return promise.future();
}
diff --git a/web-front/src/App.vue b/web-front/src/App.vue
index 3d94b4f..b82dd68 100644
--- a/web-front/src/App.vue
+++ b/web-front/src/App.vue
@@ -10,7 +10,7 @@
-
@@ -296,10 +296,27 @@ export default {
})
const data = response.data.data
const panList = ["iz", "lz", "fj"];
- const listUrl = `${window.location.origin}/list.html?url=${encodeURIComponent(this.link)}&pwd=${this.password}`
- if (panList.includes(data.shareLinkInfo.type)) {
- window.open(listUrl, '_blank');
+
+ if (!panList.includes(data.shareLinkInfo.type)) {
+ this.$message.error("当前网盘不支持目录解析")
}
+ let listUrl = `${window.location.origin}/list.html?url=${encodeURIComponent(this.link)}`
+ let apiUrl = new URL(data.apiLink).origin + `/v2/getFileList?url=${this.link}`;
+ // 动态添加密码参数
+ if (this.password) {
+ listUrl += `&pwd=${this.password}`;
+ apiUrl += `&pwd=${this.password}`;
+ }
+ this.$alert(
+ `目录解析API: ${apiUrl}
打开文件列表: 点击这里`,
+ '目录解析信息',
+ {
+ dangerouslyUseHTMLString: true,
+ confirmButtonText: '确定',
+ type: 'info'
+ }
+ );
+
} else {
this.$message.error(response.data.msg)
}