⚰️ 删除无用代码

This commit is contained in:
BTMuli
2023-11-02 17:14:16 +08:00
parent 38ef0bfcca
commit 4aa9319799

View File

@@ -1,11 +1,10 @@
/**
* @file utils toolFunc.ts
* @description 一些工具函数
* @since Beta v0.3.4
* @since Beta v0.3.5
*/
import { fs, os, path } from "@tauri-apps/api";
import type { FileEntry } from "@tauri-apps/api/fs";
import { os, path } from "@tauri-apps/api";
import { v4 } from "uuid";
/**
@@ -68,33 +67,6 @@ export function bytesToSize(bytes: number): string {
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
}
/**
* @description 获取文件夹大小
* @since Beta v0.3.4
* @param {FileEntry[]} cacheInfo - 文件夹信息
* @param {boolean} isRoot - 是否是根目录
* @returns {Promise<number>} 文件夹大小
*/
export async function getDirSize(cacheInfo: FileEntry[], isRoot: false): Promise<number>;
export async function getDirSize(cacheInfo: FileEntry[], isRoot?: true): Promise<string>;
export async function getDirSize(
cacheInfo: FileEntry[],
isRoot?: boolean,
): Promise<number | string> {
let size = 0;
for (const item of cacheInfo) {
if (item.children) {
const dir = await fs.readDir(item.path);
size += await getDirSize(dir, false);
} else {
const file = await fs.readBinaryFile(item.path);
size += file.byteLength;
}
}
if (isRoot === undefined || isRoot) return bytesToSize(size);
return size;
}
/**
* @description 获取缓存目录
* @since Beta v0.3.4