Skip to content

Commit

Permalink
1. Update
Browse files Browse the repository at this point in the history
  • Loading branch information
red0orange committed Aug 10, 2023
1 parent b9dd5a4 commit 9a90aa3
Show file tree
Hide file tree
Showing 3 changed files with 578 additions and 53 deletions.
53 changes: 2 additions & 51 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,55 +37,6 @@ import * as fs from 'fs';
import * as pathModule from 'path';


interface FilePath {
path: string;
basename: string;
}


function createFileTreeFromObsidian(app: any, rootFolderPath: string): any {
// 获取所有文件
const allFiles = app.vault.getFiles();
console.log(allFiles);

// 过滤出指定文件夹下的文件
const filesInFolder = allFiles.filter((file: TFile) => {
return file.path.startsWith(rootFolderPath);
});

// 创建树的根
const fileTree: any = {};

// 为每个文件和目录在树中创建位置
for (const file of filesInFolder) {
const relativePath = file.path.substr(rootFolderPath.length); // 获取相对于根文件夹的路径
const parts = relativePath.split('/');
let currentLocation = fileTree;

// 跳过空字符串(第一个斜杠之前的部分)
for (let i = 1; i < parts.length; i++) {
const part = parts[i];

// 如果我们还没有到达文件名,则创建或导航到目录
if (i < parts.length - 1) {
if (!currentLocation[part]) {
currentLocation[part] = {};
}

currentLocation = currentLocation[part];
}

// 如果我们到达了文件名,则添加文件
else {
currentLocation[part] = file;
}
}
}

return fileTree;
}


function createFileTreeFromWebdav(files: any[]) {
// 创建树的根
const fileTree: any = {};
Expand Down Expand Up @@ -419,12 +370,12 @@ interface WebdavFileExplorerData {
const DEFAULT_DATA: WebdavFileExplorerData = {
rootFolderPath: '0_Webdav',
webdavConfig: {
address: 'http://red0orange.plus:8080',
address: 'http://127.0.0.1:8080',
username: 'admin',
password: 'admin',
authType: 'basic',
manualRecursive: false,
remoteBaseDir: '2023_下半年',
remoteBaseDir: 'obsidian',
},
};

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"id": "webdav-file-explorer",
"name": "Webdav File Explorer",
"version": "1.1.1",
"minAppVersion": "0.15.0",
"minAppVersion": "1.3.5",
"description": "A webdav file explorer for Obsidian.",
"author": "red0orange",
"authorUrl": "https://github.com/red0orange",
"fundingUrl": "",
"isDesktopOnly": false
"isDesktopOnly": true
}
Loading

0 comments on commit 9a90aa3

Please sign in to comment.