feat: 使App.vue和VirtualDirectory解耦

This commit is contained in:
539943419 committed 2024-12-24 14:19:08 +08:00
1 parent 6d550505a0
commit 4aba71d451
8 files changed
+162 -66

No files matched your search

+11 -17
View File
@@ -6,25 +6,19 @@ const initPlugin = async (globalAlertTip: alertTipType) => {
initPluginCenter(globalAlertTip);
const modulesFiles = import.meta.glob("@/plugins/**/export*.ts", { eager: true });
const pluginCenter = usePluginCenter();
const promiseArray = [];
for (let pluginConfig of Object.values(modulesFiles)) {
promiseArray.push(
new Promise(async resolve => {
const _config = pluginConfig as {
default: registerComponentOption | Plugin;
type: PluginExportType;
key?: string;
};
const { type, key } = _config;
if (type === PluginExportType.component) {
resolve(pluginCenter.registerComponent(_config.default as registerComponentOption));
} else if (type === PluginExportType.default) {
resolve(pluginCenter.register(key as string, _config.default as Plugin));
}
})
);
const _config = pluginConfig as {
default: registerComponentOption | Plugin;
type: PluginExportType;
key?: string;
};
const { type, key } = _config;
if (type === PluginExportType.component) {
pluginCenter.registerComponent(_config.default as registerComponentOption);
} else if (type === PluginExportType.default) {
pluginCenter.register(key as string, _config.default as Plugin);
}
}
await Promise.all(promiseArray);
};
export default initPlugin;
+17
View File
@@ -0,0 +1,17 @@
import VirtualDirectory from "@/class/VirtualDirectory";
import { reactive } from "vue";
const root = reactive(
new VirtualDirectory({
name: '根目录',
stats: {
atimeMs: 0,
birthtimeMs: 0,
ctimeMs: 0,
mtimeMs: 0
}
})
)
export default function useRootVDirectory() {
return root;
}