From 7274e40893619249d9a775e63eecae4a8c971852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Sun, 21 May 2023 18:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=89=93=E5=BC=80=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E7=9B=AE=E5=BD=95=20#182?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/filesystem/baidu/baidu.ts | 8 ++++++++ pkg/filesystem/filesystem.ts | 2 ++ pkg/filesystem/onedrive/onedrive.ts | 4 ++++ pkg/filesystem/webdav/webdav.ts | 10 +++++++++- pkg/filesystem/zip/zip.ts | 4 ++++ src/pages/options/routes/Tools.tsx | 27 ++++++++++++++++++++++++++- 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/pkg/filesystem/baidu/baidu.ts b/pkg/filesystem/baidu/baidu.ts index f710cc19..be5318ec 100644 --- a/pkg/filesystem/baidu/baidu.ts +++ b/pkg/filesystem/baidu/baidu.ts @@ -138,4 +138,12 @@ export default class BaiduFileSystem implements FileSystem { return list; }); } + + getDirUrl(): Promise { + return Promise.resolve( + `https://pan.baidu.com/disk/main#/index?category=all&path=${encodeURIComponent( + this.path + )}` + ); + } } diff --git a/pkg/filesystem/filesystem.ts b/pkg/filesystem/filesystem.ts index e677e76f..0ee1847a 100644 --- a/pkg/filesystem/filesystem.ts +++ b/pkg/filesystem/filesystem.ts @@ -43,4 +43,6 @@ export default interface FileSystem { delete(path: string): Promise; // 文件列表 list(): Promise; + // getDirUrl 获取目录的url + getDirUrl(): Promise; } diff --git a/pkg/filesystem/onedrive/onedrive.ts b/pkg/filesystem/onedrive/onedrive.ts index eaeb2afe..e381bafb 100644 --- a/pkg/filesystem/onedrive/onedrive.ts +++ b/pkg/filesystem/onedrive/onedrive.ts @@ -142,4 +142,8 @@ export default class OneDriveFileSystem implements FileSystem { return list; }); } + + getDirUrl(): Promise { + throw new Error("Method not implemented."); + } } diff --git a/pkg/filesystem/webdav/webdav.ts b/pkg/filesystem/webdav/webdav.ts index fe501b50..de326043 100644 --- a/pkg/filesystem/webdav/webdav.ts +++ b/pkg/filesystem/webdav/webdav.ts @@ -6,6 +6,8 @@ import { WebDAVFileReader, WebDAVFileWriter } from "./rw"; export default class WebDAVFileSystem implements FileSystem { client: WebDAVClient; + url: string; + basePath: string = "/"; constructor( @@ -17,7 +19,9 @@ export default class WebDAVFileSystem implements FileSystem { if (typeof authType === "object") { this.client = authType; this.basePath = joinPath(url || ""); + this.url = username!; } else { + this.url = url!; this.client = createClient(url!, { authType, username, @@ -39,7 +43,7 @@ export default class WebDAVFileSystem implements FileSystem { openDir(path: string): Promise { return Promise.resolve( - new WebDAVFileSystem(this.client, joinPath(this.basePath, path)) + new WebDAVFileSystem(this.client, joinPath(this.basePath, path), this.url) ); } @@ -77,4 +81,8 @@ export default class WebDAVFileSystem implements FileSystem { }); return Promise.resolve(ret); } + + getDirUrl(): Promise { + return Promise.resolve(this.url + this.basePath); + } } diff --git a/pkg/filesystem/zip/zip.ts b/pkg/filesystem/zip/zip.ts index 312bfd1b..47467b90 100644 --- a/pkg/filesystem/zip/zip.ts +++ b/pkg/filesystem/zip/zip.ts @@ -61,4 +61,8 @@ export default class ZipFileSystem implements FileSystem { }); return Promise.resolve(files); } + + getDirUrl(): Promise { + throw new Error("Method not implemented."); + } } diff --git a/src/pages/options/routes/Tools.tsx b/src/pages/options/routes/Tools.tsx index b9e6751f..e88ae100 100644 --- a/src/pages/options/routes/Tools.tsx +++ b/src/pages/options/routes/Tools.tsx @@ -153,7 +153,32 @@ function Tools() { /> 备份列表} + title={ +
+ 备份列表 + +
+ } visible={backupFileList.length !== 0} onOk={() => { setBackupFileList([]);