mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-10-15 11:08:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aed555aee | ||
|
|
aab7d900b0 |
@@ -82,24 +82,31 @@ public class LzTool extends PanBase {
|
|||||||
Pattern.compile("(?s)文件描述:</span><br>(.*?)</td>|class=\"n_box_des\">(.*?)</div>");
|
Pattern.compile("(?s)文件描述:</span><br>(.*?)</td>|class=\"n_box_des\">(.*?)</div>");
|
||||||
private static final Pattern P_FI_ID = Pattern.compile("\\?f=(.*?)&|fid = (.*?);");
|
private static final Pattern P_FI_ID = Pattern.compile("\\?f=(.*?)&|fid = (.*?);");
|
||||||
private static final Pattern P_FI_TIME = Pattern.compile(">上传时间:</span>(.*?)<");
|
private static final Pattern P_FI_TIME = Pattern.compile(">上传时间:</span>(.*?)<");
|
||||||
/** 分享页导航头,只读共享;需要改写时先 addAll 到新 MultiMap。 */
|
/**
|
||||||
private static final MultiMap PAGE_HEADERS = HeaderUtils.parseHeaders("""
|
* 蓝奏全部对外 HTTP 共用的移动端身份。
|
||||||
|
* 桌面 Chrome UA 拉分享页常返回 off0 下线空壳(~665B,空 title,无 filemoreajax)。
|
||||||
|
*/
|
||||||
|
private static final String MOBILE_UA = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 "
|
||||||
|
+ "(KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36";
|
||||||
|
|
||||||
|
/** 分享页 / iframe / 下载域导航头,只读共享;需要改写时先 addAll 到新 MultiMap。 */
|
||||||
|
private static final MultiMap PAGE_HEADERS = applyMobileIdentity(HeaderUtils.parseHeaders("""
|
||||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
|
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
|
||||||
Accept-Encoding: identity
|
Accept-Encoding: identity
|
||||||
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
|
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
|
||||||
Cache-Control: max-age=0
|
Cache-Control: max-age=0
|
||||||
DNT: 1
|
DNT: 1
|
||||||
Priority: u=0, i
|
Priority: u=0, i
|
||||||
Sec-CH-UA: "Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"
|
Sec-CH-UA: "Chromium";v="111", "Not:A-Brand";v="24", "Google Chrome";v="111"
|
||||||
Sec-CH-UA-Mobile: ?0
|
Sec-CH-UA-Mobile: ?1
|
||||||
Sec-CH-UA-Platform: "Windows"
|
Sec-CH-UA-Platform: "Android"
|
||||||
Sec-Fetch-Dest: document
|
Sec-Fetch-Dest: document
|
||||||
Sec-Fetch-Mode: navigate
|
Sec-Fetch-Mode: navigate
|
||||||
Sec-Fetch-Site: cross-site
|
Sec-Fetch-Site: cross-site
|
||||||
Sec-Fetch-User: ?1
|
Sec-Fetch-User: ?1
|
||||||
Upgrade-Insecure-Requests: 1
|
Upgrade-Insecure-Requests: 1
|
||||||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
|
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36
|
||||||
""");
|
"""));
|
||||||
|
|
||||||
private static final String DOWN_AJAX_HEADERS = """
|
private static final String DOWN_AJAX_HEADERS = """
|
||||||
Accept: application/json, text/javascript, */*; q=0.01
|
Accept: application/json, text/javascript, */*; q=0.01
|
||||||
@@ -111,11 +118,7 @@ public class LzTool extends PanBase {
|
|||||||
Sec-Fetch-Dest: empty
|
Sec-Fetch-Dest: empty
|
||||||
Sec-Fetch-Mode: cors
|
Sec-Fetch-Mode: cors
|
||||||
Sec-Fetch-Site: same-origin
|
Sec-Fetch-Site: same-origin
|
||||||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
|
|
||||||
X-Requested-With: XMLHttpRequest
|
X-Requested-With: XMLHttpRequest
|
||||||
sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"
|
|
||||||
sec-ch-ua-mobile: ?0
|
|
||||||
sec-ch-ua-platform: "Windows"
|
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private static final String VERIFY_AJAX_HEADERS = """
|
private static final String VERIFY_AJAX_HEADERS = """
|
||||||
@@ -412,7 +415,7 @@ public class LzTool extends PanBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 页面里提取出的 ajax 调用:相对路径 + 表单参数。 */
|
/** 页面里提取出的 ajax 调用:相对路径 + 表单参数。 */
|
||||||
private record AjaxCall(String path, Map<String, String> form) {
|
record AjaxCall(String path, Map<String, String> form) {
|
||||||
MultiMap toForm() {
|
MultiMap toForm() {
|
||||||
MultiMap m = MultiMap.caseInsensitiveMultiMap();
|
MultiMap m = MultiMap.caseInsensitiveMultiMap();
|
||||||
form.forEach(m::set);
|
form.forEach(m::set);
|
||||||
@@ -485,7 +488,7 @@ public class LzTool extends PanBase {
|
|||||||
return new AjaxCall("/" + ajaxPath, data);
|
return new AjaxCall("/" + ajaxPath, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AjaxCall extractFolderAjax(String html, String pwd) {
|
static AjaxCall extractFolderAjax(String html, String pwd) {
|
||||||
if (html == null || html.isEmpty()) {
|
if (html == null || html.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -575,7 +578,7 @@ public class LzTool extends PanBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getDownURL(String referer, AjaxCall call) {
|
private void getDownURL(String referer, AjaxCall call) {
|
||||||
MultiMap headers = HeaderUtils.parseHeaders(DOWN_AJAX_HEADERS);
|
MultiMap headers = applyMobileIdentity(HeaderUtils.parseHeaders(DOWN_AJAX_HEADERS));
|
||||||
// 个性域名 ajaxfile.php 会立刻 inf=已超时;POST 必须打 wwww。iframe 请求 Referer 用 iframe 地址。
|
// 个性域名 ajaxfile.php 会立刻 inf=已超时;POST 必须打 wwww。iframe 请求 Referer 用 iframe 地址。
|
||||||
headers.set("referer", referer != null && !referer.isBlank() ? referer : resolveShareUrl());
|
headers.set("referer", referer != null && !referer.isBlank() ? referer : resolveShareUrl());
|
||||||
String url = joinUrl(SHARE_ORIGIN + "/", call.path());
|
String url = joinUrl(SHARE_ORIGIN + "/", call.path());
|
||||||
@@ -616,7 +619,7 @@ public class LzTool extends PanBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 中间链:部分出口仍 302;多数(含机房 IP)固定出「验证并下载」页。
|
* 中间链:部分出口仍 302;多数(含机房 IP)固定出「验证并下载」页。
|
||||||
* dmpdmp 等下载域仍会出 arg1 挑战(Windows UA 更常见),必须算 acw_sc__v2 再请求。
|
* dmpdmp 等下载域仍会出 arg1 挑战,必须算 acw_sc__v2 再请求。
|
||||||
* 必须等约 2s 后 POST /file/ajax.php el=2 拿 CDN 直链;立刻 POST 会 ?SignError。
|
* 必须等约 2s 后 POST /file/ajax.php el=2 拿 CDN 直链;立刻 POST 会 ?SignError。
|
||||||
* 中间页不能当成功结果返回——用户侧裸打开永远是验证 HTML。
|
* 中间页不能当成功结果返回——用户侧裸打开永远是验证 HTML。
|
||||||
*/
|
*/
|
||||||
@@ -748,20 +751,17 @@ public class LzTool extends PanBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 最后一步 GET 用完整浏览器导航头,裸 curl / 无 UA 会固定落到验证页。 */
|
/** 最后一步 GET 用完整浏览器导航头,裸 curl / 无 UA 会固定落到验证页。 */
|
||||||
private static MultiMap lanrarPageHeaders(String referer) {
|
static MultiMap lanrarPageHeaders(String referer) {
|
||||||
MultiMap h = MultiMap.caseInsensitiveMultiMap();
|
MultiMap h = MultiMap.caseInsensitiveMultiMap();
|
||||||
h.addAll(PAGE_HEADERS);
|
h.addAll(PAGE_HEADERS);
|
||||||
h.set("referer", referer);
|
h.set("referer", referer);
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiMap lanrarAjaxHeaders(String referer) {
|
static MultiMap lanrarAjaxHeaders(String referer) {
|
||||||
MultiMap h = HeaderUtils.parseHeaders(VERIFY_AJAX_HEADERS);
|
MultiMap h = applyMobileIdentity(HeaderUtils.parseHeaders(VERIFY_AJAX_HEADERS));
|
||||||
h.set("referer", referer);
|
h.set("referer", referer);
|
||||||
copyHeader(h, "User-Agent", "User-Agent");
|
|
||||||
copyHeader(h, "Sec-CH-UA", "sec-ch-ua");
|
copyHeader(h, "Sec-CH-UA", "sec-ch-ua");
|
||||||
copyHeader(h, "Sec-CH-UA-Mobile", "sec-ch-ua-mobile");
|
|
||||||
copyHeader(h, "Sec-CH-UA-Platform", "sec-ch-ua-platform");
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,18 +871,45 @@ public class LzTool extends PanBase {
|
|||||||
complete(downloadUrl);
|
complete(downloadUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 目录列表 filemoreajax.php 用移动端 UA。 */
|
/** 蓝奏对外请求统一写成 Android Mobile,避免桌面 UA 落到 off0 空壳。 */
|
||||||
private static MultiMap folderListHeaders(String referer) {
|
static MultiMap applyMobileIdentity(MultiMap headers) {
|
||||||
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
|
headers.set("User-Agent", MOBILE_UA);
|
||||||
headers.set("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 "
|
headers.set("Sec-CH-UA-Mobile", "?1");
|
||||||
+ "(KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36");
|
headers.set("Sec-CH-UA-Platform", "\"Android\"");
|
||||||
headers.set("referer", referer);
|
|
||||||
headers.set("sec-ch-ua-platform", "Android");
|
|
||||||
headers.set("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
|
||||||
headers.set("sec-ch-ua-mobile", "?1");
|
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MultiMap folderListHeaders(String referer) {
|
||||||
|
MultiMap headers = applyMobileIdentity(MultiMap.caseInsensitiveMultiMap());
|
||||||
|
headers.set("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
||||||
|
headers.set("referer", referer);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String mobileUserAgent() {
|
||||||
|
return MOBILE_UA;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MultiMap sharePageHeaders() {
|
||||||
|
return PAGE_HEADERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MultiMap downAjaxHeaders() {
|
||||||
|
return applyMobileIdentity(HeaderUtils.parseHeaders(DOWN_AJAX_HEADERS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 蓝奏 off0 / off1 下线空壳:桌面 UA 拉分享页时常只有这个,没有 filemoreajax。 */
|
||||||
|
static boolean isLzOfflineStub(String html) {
|
||||||
|
if (html == null || html.isBlank()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (html.contains("class=\"off0\"") || html.contains("class='off0'")
|
||||||
|
|| html.contains("id=\"off0\"") || html.contains("id='off0'")
|
||||||
|
|| html.contains("class=\"off1\"") || html.contains("class='off1'")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return P_OFF_MSG.matcher(html).find();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Future<List<FileInfo>> parseFileList() {
|
public Future<List<FileInfo>> parseFileList() {
|
||||||
@@ -958,7 +985,7 @@ public class LzTool extends PanBase {
|
|||||||
return path.charAt(0) == 'b' || path.charAt(0) == 'B';
|
return path.charAt(0) == 'b' || path.charAt(0) == 'B';
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLzFolderHtml(String html) {
|
static boolean isLzFolderHtml(String html) {
|
||||||
if (html == null || html.isBlank()) {
|
if (html == null || html.isBlank()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package cn.qaiu.parser.impl;
|
||||||
|
|
||||||
|
import io.vertx.core.MultiMap;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 蓝奏 LzTool 对外请求一律移动 UA:桌面 Chrome 会触发 off0 下线空壳。
|
||||||
|
* 不访问真实蓝奏,只回归请求头与空壳/目录页识别。
|
||||||
|
*/
|
||||||
|
public class LzToolFolderPageTest {
|
||||||
|
|
||||||
|
private static final String FOLDER_URL = "https://pan.lanzoux.com/b66477";
|
||||||
|
private static final String FILE_URL = "https://wwww.lanzoux.com/iULV2n4361c";
|
||||||
|
|
||||||
|
/** 桌面 UA 实测会落到的 off0 空壳(空 title,无 filemoreajax)。 */
|
||||||
|
private static final String OFF0_STUB = """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head><meta charset="utf-8"><title></title></head>
|
||||||
|
<body>
|
||||||
|
<div class="off">
|
||||||
|
<div class="off0"></div>
|
||||||
|
<div class="off1"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""";
|
||||||
|
|
||||||
|
/** 移动 UA 才能拿到的目录页片段。 */
|
||||||
|
private static final String FOLDER_HTML = """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head><title>全网最全软件合集</title></head>
|
||||||
|
<body>
|
||||||
|
<div id="infos"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$.ajax({
|
||||||
|
url : '/filemoreajax.php?file=66477',
|
||||||
|
data : {
|
||||||
|
'lx':2,
|
||||||
|
'fid':66477,
|
||||||
|
'uid':'u1',
|
||||||
|
'pg':1,
|
||||||
|
'rep':'0',
|
||||||
|
't':t,
|
||||||
|
'k':k,
|
||||||
|
'up':1,
|
||||||
|
'pwd':pwd
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var t = 'TIME_TOKEN';
|
||||||
|
var k = 'KEY_TOKEN';
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAllOutboundHeadersUseAndroidMobileUa() {
|
||||||
|
String mobileUa = LzTool.mobileUserAgent();
|
||||||
|
assertTrue(mobileUa.contains("Android"));
|
||||||
|
assertTrue(mobileUa.contains("Mobile Safari"));
|
||||||
|
assertFalse("蓝奏路径不应再带桌面 Chrome UA", mobileUa.contains("Windows NT"));
|
||||||
|
|
||||||
|
List<MultiMap> outbound = List.of(
|
||||||
|
LzTool.sharePageHeaders(),
|
||||||
|
LzTool.folderListHeaders(FOLDER_URL),
|
||||||
|
LzTool.downAjaxHeaders(),
|
||||||
|
LzTool.lanrarPageHeaders("https://developer2.lanrar.com"),
|
||||||
|
LzTool.lanrarAjaxHeaders(FILE_URL)
|
||||||
|
);
|
||||||
|
for (MultiMap headers : outbound) {
|
||||||
|
assertEquals(mobileUa, headers.get("User-Agent"));
|
||||||
|
assertEquals("?1", headers.get("Sec-CH-UA-Mobile"));
|
||||||
|
assertFalse(String.valueOf(headers.get("User-Agent")).contains("Windows NT"));
|
||||||
|
assertFalse("?0".equals(headers.get("Sec-CH-UA-Mobile")));
|
||||||
|
}
|
||||||
|
assertEquals("\"Android\"", LzTool.sharePageHeaders().get("Sec-CH-UA-Platform"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOff0StubDetectedWithoutFilemoreajax() {
|
||||||
|
assertTrue(LzTool.isLzOfflineStub(OFF0_STUB));
|
||||||
|
assertTrue(LzTool.isLzOfflineStub(""));
|
||||||
|
assertTrue(LzTool.isLzOfflineStub(null));
|
||||||
|
assertFalse(LzTool.isLzOfflineStub(FOLDER_HTML));
|
||||||
|
assertFalse(LzTool.isLzFolderHtml(OFF0_STUB));
|
||||||
|
assertNull(LzTool.extractFolderAjax(OFF0_STUB, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRealFolderHtmlExtractsFilemoreajax() {
|
||||||
|
assertTrue(LzTool.isLzFolderHtml(FOLDER_HTML));
|
||||||
|
assertFalse(LzTool.isLzOfflineStub(FOLDER_HTML));
|
||||||
|
assertTrue(LzTool.isLzFolderUrl(FOLDER_URL));
|
||||||
|
assertFalse(LzTool.isLzFolderUrl(FILE_URL));
|
||||||
|
|
||||||
|
LzTool.AjaxCall call = LzTool.extractFolderAjax(FOLDER_HTML, "pwd1");
|
||||||
|
assertNotNull(call);
|
||||||
|
assertEquals("/filemoreajax.php?file=66477", call.path());
|
||||||
|
assertEquals("66477", call.form().get("fid"));
|
||||||
|
assertEquals("TIME_TOKEN", call.form().get("t"));
|
||||||
|
assertEquals("KEY_TOKEN", call.form().get("k"));
|
||||||
|
assertEquals("pwd1", call.form().get("pwd"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -139,114 +139,113 @@
|
|||||||
style="background:transparent;"
|
style="background:transparent;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<TreeBatchActionBar
|
<div v-if="batchMode" class="tree-sidebar-footer">
|
||||||
v-if="batchMode"
|
<span class="tree-sidebar-count">已勾选 {{ selectedFiles.length }} 个文件</span>
|
||||||
class="tree-sidebar-footer"
|
<div class="tree-sidebar-actions">
|
||||||
v-bind="treeBatchBarBind"
|
<el-button
|
||||||
@browser-download="batchBrowserDownload"
|
type="primary"
|
||||||
@send-downloader="batchSendToDownloader"
|
size="small"
|
||||||
@cancel="toggleBatchMode"
|
:disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding || batchBrowserDownloadDisabled"
|
||||||
/>
|
:loading="batchDownloading"
|
||||||
|
@click="batchBrowserDownload"
|
||||||
|
:title="batchBrowserDownloadDisabled ? '所选文件需使用下载器下载' : ''"
|
||||||
|
>
|
||||||
|
浏览器下载
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
:disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding"
|
||||||
|
:loading="batchDownloading"
|
||||||
|
@click="batchSendToDownloader"
|
||||||
|
>
|
||||||
|
发送到下载器
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
@click="toggleBatchMode"
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<div v-if="batchDownloading" class="batch-progress-info">
|
||||||
|
<el-progress :percentage="batchProgressPercent" :status="batchProgressStatus" />
|
||||||
|
<p>{{ batchProgress.current }} / {{ batchProgress.total }}
|
||||||
|
<span v-if="batchProgress.failed > 0" style="color:#f56c6c;"> ({{ batchProgress.failed }} 失败)</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</pane>
|
</pane>
|
||||||
<pane>
|
<pane>
|
||||||
<div class="tree-content">
|
<div class="tree-content">
|
||||||
<div class="tree-toolbar tree-content-toolbar">
|
<div v-if="selectedNode" class="file-detail-panel">
|
||||||
<span class="tree-toolbar-title">
|
<div class="file-detail-icon-wrap">
|
||||||
<i class="fas fa-file-alt" aria-hidden="true"></i> 详情
|
<i :class="getFileIcon(selectedNode)" class="file-detail-icon"></i>
|
||||||
</span>
|
</div>
|
||||||
<el-button
|
<h4 class="file-detail-name">{{ selectedNode.fileName }}</h4>
|
||||||
v-if="!batchMode"
|
<div v-if="selectedNode.fileType !== 'folder'" class="file-detail-meta">
|
||||||
type="warning"
|
<p>类型: {{ selectedNode.fileType === 'url' ? '超链接' : getFileTypeClass(selectedNode) }}</p>
|
||||||
size="small"
|
<p v-if="selectedNode.fileType !== 'url'">大小: {{ selectedNode.sizeStr || '0B' }}</p>
|
||||||
@click="toggleBatchMode"
|
<p v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl" class="file-detail-link">
|
||||||
>
|
链接: {{ selectedNode.previewUrl }}
|
||||||
|
</p>
|
||||||
|
<p v-if="formatDate(selectedNode.createTime)">创建时间: {{ formatDate(selectedNode.createTime) }}</p>
|
||||||
|
<p v-if="formatDate(selectedNode.updateTime)">更新时间: {{ formatDate(selectedNode.updateTime) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="file-detail-actions">
|
||||||
|
<el-button
|
||||||
|
v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl"
|
||||||
|
type="primary" size="small"
|
||||||
|
@click="openExternalLink(selectedNode)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-external-link-alt"></i> 打开链接
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-else-if="selectedNode.parserUrl || selectedNode.previewUrl"
|
||||||
|
size="small"
|
||||||
|
@click="previewFile(selectedNode)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-external-link-alt"></i> 打开
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
type="success" size="small"
|
||||||
|
@click="handleDownload(selectedNode)"
|
||||||
|
:loading="downloadLoading"
|
||||||
|
:disabled="needsDownloader(selectedNode)"
|
||||||
|
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器下载' : ''"
|
||||||
|
>
|
||||||
|
<i class="fas fa-download"></i> 下载
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
type="primary" size="small"
|
||||||
|
@click="sendSingleToDownloader(selectedNode)"
|
||||||
|
:loading="singleSendLoading"
|
||||||
|
>
|
||||||
|
<i class="fas fa-paper-plane"></i> 发送到下载器
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
size="small"
|
||||||
|
@click="copyDirectLink(selectedNode)"
|
||||||
|
:loading="copyLinkLoading"
|
||||||
|
:disabled="needsDownloader(selectedNode)"
|
||||||
|
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器,无法直接复制直链' : ''"
|
||||||
|
>
|
||||||
|
<i class="fas fa-link"></i> 复制直链
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="file-detail-empty">
|
||||||
|
<i class="fas fa-hand-pointer" style="font-size:32px;color:#bbb;margin-bottom:12px;"></i>
|
||||||
|
<p>请在左侧选择文件查看详情</p>
|
||||||
|
</div>
|
||||||
|
<div v-if="!batchMode" class="tree-batch-trigger">
|
||||||
|
<el-button type="warning" size="small" @click="toggleBatchMode">
|
||||||
<i class="fas fa-check-double"></i> 批量下载
|
<i class="fas fa-check-double"></i> 批量下载
|
||||||
</el-button>
|
</el-button>
|
||||||
<span v-else class="tree-toolbar-hint">
|
|
||||||
{{ treeExpanding ? '正在展开并收集文件…' : `勾选左侧文件夹将自动展开(最多 ${effectiveBatchMaxDepth} 层)` }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="tree-content-body">
|
|
||||||
<div v-if="selectedNode" class="file-detail-panel">
|
|
||||||
<div class="file-detail-icon-wrap">
|
|
||||||
<i :class="getFileIcon(selectedNode)" class="file-detail-icon"></i>
|
|
||||||
</div>
|
|
||||||
<h4 class="file-detail-name">{{ selectedNode.fileName }}</h4>
|
|
||||||
<div v-if="selectedNode.fileType !== 'folder'" class="file-detail-meta">
|
|
||||||
<p>类型: {{ selectedNode.fileType === 'url' ? '超链接' : getFileTypeClass(selectedNode) }}</p>
|
|
||||||
<p v-if="selectedNode.fileType !== 'url'">大小: {{ selectedNode.sizeStr || '0B' }}</p>
|
|
||||||
<p v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl" class="file-detail-link">
|
|
||||||
链接: {{ selectedNode.previewUrl }}
|
|
||||||
</p>
|
|
||||||
<p v-if="formatDate(selectedNode.createTime)">创建时间: {{ formatDate(selectedNode.createTime) }}</p>
|
|
||||||
<p v-if="formatDate(selectedNode.updateTime)">更新时间: {{ formatDate(selectedNode.updateTime) }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="file-detail-actions">
|
|
||||||
<el-button
|
|
||||||
v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl"
|
|
||||||
type="primary" size="small"
|
|
||||||
@click="openExternalLink(selectedNode)"
|
|
||||||
>
|
|
||||||
<i class="fas fa-external-link-alt"></i> 打开链接
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-else-if="selectedNode.parserUrl || selectedNode.previewUrl"
|
|
||||||
size="small"
|
|
||||||
@click="previewFile(selectedNode)"
|
|
||||||
>
|
|
||||||
<i class="fas fa-external-link-alt"></i> 打开
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
type="success" size="small"
|
|
||||||
@click="handleDownload(selectedNode)"
|
|
||||||
:loading="downloadLoading"
|
|
||||||
:disabled="needsDownloader(selectedNode)"
|
|
||||||
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器下载' : ''"
|
|
||||||
>
|
|
||||||
<i class="fas fa-download"></i> 下载
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
type="primary" size="small"
|
|
||||||
@click="sendSingleToDownloader(selectedNode)"
|
|
||||||
:loading="singleSendLoading"
|
|
||||||
>
|
|
||||||
<i class="fas fa-paper-plane"></i> 发送到下载器
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
size="small"
|
|
||||||
@click="copyDirectLink(selectedNode)"
|
|
||||||
:loading="copyLinkLoading"
|
|
||||||
:disabled="needsDownloader(selectedNode)"
|
|
||||||
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器,无法直接复制直链' : ''"
|
|
||||||
>
|
|
||||||
<i class="fas fa-link"></i> 复制直链
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else class="file-detail-empty">
|
|
||||||
<i class="fas fa-hand-pointer" style="font-size:32px;color:#bbb;margin-bottom:12px;"></i>
|
|
||||||
<p>请在左侧选择文件查看详情</p>
|
|
||||||
<p v-if="!batchMode" class="file-detail-empty-hint">或直接点击「批量下载」勾选多个文件</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="tree-content-footer" :class="{ 'is-batch': batchMode }">
|
|
||||||
<template v-if="!batchMode">
|
|
||||||
<span class="tree-content-footer-hint">可直接勾选多个文件下载</span>
|
|
||||||
<el-button type="warning" size="small" @click="toggleBatchMode">
|
|
||||||
<i class="fas fa-check-double"></i> 批量下载
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
<TreeBatchActionBar
|
|
||||||
v-else
|
|
||||||
v-bind="treeBatchBarBind"
|
|
||||||
@browser-download="batchBrowserDownload"
|
|
||||||
@send-downloader="batchSendToDownloader"
|
|
||||||
@cancel="toggleBatchMode"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</pane>
|
</pane>
|
||||||
@@ -354,21 +353,26 @@
|
|||||||
<div v-else class="file-detail-empty">
|
<div v-else class="file-detail-empty">
|
||||||
<i class="fas fa-hand-pointer" style="font-size:24px;color:#bbb;margin-bottom:8px;"></i>
|
<i class="fas fa-hand-pointer" style="font-size:24px;color:#bbb;margin-bottom:8px;"></i>
|
||||||
<p>请在上方选择文件查看详情</p>
|
<p>请在上方选择文件查看详情</p>
|
||||||
<p v-if="!batchMode" class="file-detail-empty-hint">或直接点击「批量下载」勾选多个文件</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!batchMode" class="mobile-batch-trigger">
|
<div v-if="!batchMode" class="mobile-batch-trigger">
|
||||||
<el-button type="warning" size="small" @click="toggleBatchMode">
|
<el-button type="warning" size="small" @click="toggleBatchMode">
|
||||||
<i class="fas fa-check-double"></i> 批量下载
|
<i class="fas fa-check-double"></i> 批量下载
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<TreeBatchActionBar
|
<div v-if="batchMode" class="mobile-batch-footer">
|
||||||
v-if="batchMode"
|
<span class="tree-sidebar-count">已勾选 {{ selectedFiles.length }} 个文件</span>
|
||||||
class="mobile-batch-footer"
|
<div class="tree-sidebar-actions">
|
||||||
v-bind="treeBatchBarBind"
|
<el-button type="primary" size="small" :disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding || batchBrowserDownloadDisabled" :loading="batchDownloading" @click="batchBrowserDownload" :title="batchBrowserDownloadDisabled ? '所选文件需使用下载器下载' : ''">浏览器下载</el-button>
|
||||||
@browser-download="batchBrowserDownload"
|
<el-button type="success" size="small" :disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding" :loading="batchDownloading" @click="batchSendToDownloader">发送到下载器</el-button>
|
||||||
@send-downloader="batchSendToDownloader"
|
<el-button size="small" @click="toggleBatchMode">取消</el-button>
|
||||||
@cancel="toggleBatchMode"
|
</div>
|
||||||
/>
|
<div v-if="batchDownloading" class="batch-progress-info">
|
||||||
|
<el-progress :percentage="batchProgressPercent" :status="batchProgressStatus" />
|
||||||
|
<p>{{ batchProgress.current }} / {{ batchProgress.total }}
|
||||||
|
<span v-if="batchProgress.failed > 0" style="color:#f56c6c;"> ({{ batchProgress.failed }} 失败)</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -449,7 +453,6 @@ import { Splitpanes, Pane } from 'splitpanes'
|
|||||||
import 'splitpanes/dist/splitpanes.css'
|
import 'splitpanes/dist/splitpanes.css'
|
||||||
import fileTypeUtils from '@/utils/fileTypeUtils'
|
import fileTypeUtils from '@/utils/fileTypeUtils'
|
||||||
import DownloadDialog from '@/components/DownloadDialog.vue'
|
import DownloadDialog from '@/components/DownloadDialog.vue'
|
||||||
import TreeBatchActionBar from '@/components/TreeBatchActionBar.vue'
|
|
||||||
import { testConnection, autoDetect, addDownload, batchAddDownload, getConfig, saveConfig } from '@/utils/downloaderService'
|
import { testConnection, autoDetect, addDownload, batchAddDownload, getConfig, saveConfig } from '@/utils/downloaderService'
|
||||||
import batchTreeCollect from '@/utils/batchTreeCollect'
|
import batchTreeCollect from '@/utils/batchTreeCollect'
|
||||||
|
|
||||||
@@ -463,7 +466,7 @@ const {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DirectoryTree',
|
name: 'DirectoryTree',
|
||||||
components: { ElTree, Splitpanes, Pane, DownloadDialog, TreeBatchActionBar },
|
components: { ElTree, Splitpanes, Pane, DownloadDialog },
|
||||||
props: {
|
props: {
|
||||||
fileList: {
|
fileList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -563,19 +566,6 @@ export default {
|
|||||||
effectiveBatchMaxDepth() {
|
effectiveBatchMaxDepth() {
|
||||||
const depth = Number(this.batchMaxDepth)
|
const depth = Number(this.batchMaxDepth)
|
||||||
return Number.isFinite(depth) && depth >= 0 ? depth : DEFAULT_BATCH_MAX_DEPTH
|
return Number.isFinite(depth) && depth >= 0 ? depth : DEFAULT_BATCH_MAX_DEPTH
|
||||||
},
|
|
||||||
treeBatchBarBind() {
|
|
||||||
return {
|
|
||||||
selectedCount: this.selectedFiles.length,
|
|
||||||
batchDownloading: this.batchDownloading,
|
|
||||||
treeExpanding: this.treeExpanding,
|
|
||||||
browserDisabled: this.batchBrowserDownloadDisabled,
|
|
||||||
progressPercent: this.batchProgressPercent,
|
|
||||||
progressStatus: this.batchProgressStatus,
|
|
||||||
progressCurrent: this.batchProgress.current,
|
|
||||||
progressTotal: this.batchProgress.total,
|
|
||||||
progressFailed: this.batchProgress.failed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -1650,21 +1640,10 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
.batch-progress-info {
|
.batch-progress-info {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
.tree-content-footer-hint {
|
.tree-batch-trigger {
|
||||||
font-size: 12px;
|
position: absolute;
|
||||||
color: #909399;
|
bottom: 12px;
|
||||||
line-height: 1.4;
|
right: 12px;
|
||||||
}
|
|
||||||
.dark-theme .tree-content-footer-hint {
|
|
||||||
color: #bdc3c7;
|
|
||||||
}
|
|
||||||
.file-detail-empty-hint {
|
|
||||||
margin-top: 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
.dark-theme .file-detail-empty-hint {
|
|
||||||
color: #bdc3c7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats {
|
.stats {
|
||||||
@@ -1735,7 +1714,8 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
}
|
}
|
||||||
.tree-content {
|
.tree-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
padding: 16px;
|
||||||
|
overflow-y: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2028,46 +2008,10 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
|
||||||
padding: 0;
|
|
||||||
align-items: stretch;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-content-toolbar {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-content-body {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
display: flex;
|
padding: 24px 16px 16px 16px;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 24px 16px 16px;
|
position: relative;
|
||||||
}
|
|
||||||
|
|
||||||
.tree-content-footer {
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border-top: 1px solid #eaeaea;
|
|
||||||
background: #f8f9fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-content-footer.is-batch {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark-theme .tree-content-footer {
|
|
||||||
border-top-color: #404040;
|
|
||||||
background: #232323;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-detail-panel {
|
.file-detail-panel {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<span class="tree-sidebar-count">已勾选 {{ selectedCount }} 个文件</span>
|
|
||||||
<div class="tree-sidebar-actions">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
:disabled="selectedCount === 0 || batchDownloading || treeExpanding || browserDisabled"
|
|
||||||
:loading="batchDownloading"
|
|
||||||
:title="browserDisabled ? '所选文件需使用下载器下载' : ''"
|
|
||||||
@click="$emit('browser-download')"
|
|
||||||
>
|
|
||||||
浏览器下载
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
size="small"
|
|
||||||
:disabled="selectedCount === 0 || batchDownloading || treeExpanding"
|
|
||||||
:loading="batchDownloading"
|
|
||||||
@click="$emit('send-downloader')"
|
|
||||||
>
|
|
||||||
发送到下载器
|
|
||||||
</el-button>
|
|
||||||
<el-button size="small" @click="$emit('cancel')">取消</el-button>
|
|
||||||
</div>
|
|
||||||
<div v-if="batchDownloading" class="batch-progress-info">
|
|
||||||
<el-progress :percentage="progressPercent" :status="progressStatus" />
|
|
||||||
<p>{{ progressCurrent }} / {{ progressTotal }}
|
|
||||||
<span v-if="progressFailed > 0" style="color:#f56c6c;"> ({{ progressFailed }} 失败)</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'TreeBatchActionBar',
|
|
||||||
props: {
|
|
||||||
selectedCount: { type: Number, default: 0 },
|
|
||||||
batchDownloading: { type: Boolean, default: false },
|
|
||||||
treeExpanding: { type: Boolean, default: false },
|
|
||||||
browserDisabled: { type: Boolean, default: false },
|
|
||||||
progressPercent: { type: Number, default: 0 },
|
|
||||||
progressStatus: { type: String, default: '' },
|
|
||||||
progressCurrent: { type: Number, default: 0 },
|
|
||||||
progressTotal: { type: Number, default: 0 },
|
|
||||||
progressFailed: { type: Number, default: 0 }
|
|
||||||
},
|
|
||||||
emits: ['browser-download', 'send-downloader', 'cancel']
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user