更新任务5

This commit is contained in:
jimmy committed 2025-01-18 23:02:22 +08:00
1 parent 4e3361df39
commit b8697c4ce8
2 files changed
+3 -12

No files matched your search

+1 -12
View File
@@ -11,10 +11,9 @@ export function createSideBar (docsDir: string) {
console.log('createSideBarZH ======================= ')
// console.log(createSideBarEN1())
let dDir = FileUtils.getRoleFolderName(docsDir, -1)
console.log(dDir, '++++++++++++++++++++++++++++++++++++++++++++++++++++++')
let filesRecursively = getFilesRecursively(docsDir)
console.log("===========================================================");
let message = divideSidebar(filesRecursively.contents, dDir)
message.forEach(message => {
// console.log(message)
})
@@ -30,7 +29,6 @@ export function createSideBar (docsDir: string) {
* 要获取的文件夹目录
*/
function getFilesRecursively (dirPath: string) {
console.log(dirPath, '+++++++++++++++++++')
const result: FileOrDir = {
type: 'directory',
path: dirPath,
@@ -39,16 +37,7 @@ function getFilesRecursively (dirPath: string) {
}
// 获取当前目录下的所有文件和文件夹
const items1 = fs.readdirSync("/home/runner/work/duyl328.github.io")
const items2 = fs.readdirSync("/home/runner/work/duyl328.github.io/duyl328.github.io")
const items3 = fs.readdirSync("/home/runner/work/duyl328.github.io/duyl328.github.io/docs")
const items4 = fs.readdirSync("/home/runner/work/duyl328.github.io/duyl328.github.io/docs/notes")
console.log(items1,'----1-----------------');
console.log(items2,'------2-------------------');
console.log(items3,'---3---2-------------------');
console.log(items4,'----4--2-------------------');
const items = fs.readdirSync(dirPath)
console.log(items,'--------3-----------------');
items.forEach(item => {
const fullPath = path.join(dirPath, item)
const stats = fs.statSync(fullPath)
+2
View File
@@ -15,6 +15,7 @@ export class FileUtils {
* @param url
*/
static getFileName (url: string) {
console.log(url,"文件名称");
const parsedUrl = new URL(url)
let pathname = parsedUrl.pathname
pathname = pathname.replace(/\\/g, '/')
@@ -27,6 +28,7 @@ export class FileUtils {
* @param url
*/
static getLastFolderName (url: string): string {
console.log(url,"文件夹名称");
const parsedUrl = new URL(url)
let pathname = parsedUrl.pathname
// 统一路径分隔符为 '/'