feat: 重构部分组件,使miaoDirectoryItem更加通用

This commit is contained in:
539943419 committed 2024-09-01 14:45:29 +08:00
1 parent 938dde4c1c
commit 9aec221ea3
6 files changed
+127 -113

No files matched your search

+4 -4
View File
@@ -13,14 +13,14 @@ export class VirtualFile {
this.stats = info.stats;
this.parent = parent;
this.type = "file";
this.uid = generateId();
this.id = generateId();
}
name: string;
type: "file";
size: number;
stats: stats;
parent: VirtualDirectory;
uid: number;
id: number;
get path() {
return `${this.parent.path}${this.name}`;
}
@@ -36,7 +36,7 @@ class VirtualDirectory {
this.type = "directory";
this.stats = info.stats;
this.parent = parent ?? undefined;
this.uid = generateId();
this.id = generateId();
}
// 文件夹名
name: string;
@@ -51,7 +51,7 @@ class VirtualDirectory {
// 父文件夹
parent?: VirtualDirectory;
uid: number;
id: number;
/**
* 获取相对于根目录的路径的层数
+4 -4
View File
@@ -18,7 +18,7 @@ export default class VirtualPage {
this.currentDirectories = initObjects?.directories ?? [];
this.currentFiles = initObjects?.files ?? [];
this.visible = true;
this.uid = generateId();
this.id = generateId();
this.refreshKey = Math.random();
this.color = getRandomWebSafeColor();
}
@@ -31,7 +31,7 @@ export default class VirtualPage {
// 当前正在使用的文件
currentFiles: VirtualFile[];
// 区分每一个页面的唯一id
uid: number;
id: number;
// 当refreshKey改变时需要刷新页面,目前还没接入刷新
refreshKey: number;
// 为了区分,每个虚拟页面都会分配一个color,这个color会体现在tab上
@@ -79,7 +79,7 @@ export class VirtualPages {
*/
getIndex(id: number) {
for (let i in this._views) {
if (this._views[i].uid === id) {
if (this._views[i].id === id) {
return parseInt(i);
}
}
@@ -91,7 +91,7 @@ export class VirtualPages {
*/
getView(id: number) {
for (let v of this._views) {
if (v.uid === id) {
if (v.id === id) {
return v;
}
}