feat: 初步实现基于iframe的插件的部分逻辑。

This commit is contained in:
539943419 committed 2024-09-12 03:31:20 +08:00
1 parent ff7d0d8d51
commit f2ff05f4e3
4 files changed
+120 -84

No files matched your search

+34 -1
View File
@@ -6,6 +6,21 @@ import type { stats, file, directory } from "@/types/type.ts";
const miaoFetchApi = useMiaoFetchApi();
export interface Tree {
name: string;
type: 'directory';
path: string;
stats: stats;
files?: {
name: string;
type: 'file';
size: number;
stats: stats;
url: string;
}[];
directories?: Tree[];
}
export class VirtualFile {
constructor(info: file, parent: VirtualDirectory) {
this.name = info.name;
@@ -26,7 +41,7 @@ export class VirtualFile {
}
get url() {
return `${config.api.get}${this.parent.path}${this.name}`
return `${config.api.get}${this.parent.path}${this.name}`;
}
}
@@ -96,6 +111,24 @@ class VirtualDirectory {
return this.parent.getParent(layer - 1);
}
get tree(): Tree {
return {
name: this.name,
type: this.type,
path: this.path,
stats: this.stats,
files:
this.files?.map(v => ({
name: v.name,
type: v.type,
size: v.size,
stats: v.stats,
url: v.url
})) ?? [],
directories: this.directories?.map(v => v.tree) ?? []
};
}
updateContent(content: (file | directory)[]) {
this.files = this.files ?? [];
this.directories = this.directories ?? [];