refactor(plugins): 重构插件自动加载逻辑
Some checks failed
CI/CD Pipeline / playwright (push) Failing after 7m17s
CI/CD Pipeline / build-and-deploy (push) Has been skipped

This commit is contained in:
严浩
2025-11-03 11:52:54 +08:00
parent 8a3b9e03fd
commit b669889bb0
2 changed files with 11 additions and 11 deletions

View File

@@ -4,13 +4,15 @@
type UserPlugin = (ctx: UserPluginContext) => void;
type AutoInstallModule = { [K: string]: unknown; install?: UserPlugin };
type UserPluginContext = { app: import('vue').App<Element> };
export function setupPlugins(
app: import('vue').App,
modules: AutoInstallModule | Record<string, unknown>,
) {
const autoInstallModules: AutoInstallModule = import.meta.glob('./!(index).ts', {
eager: true /* true 为同步false 为异步 */,
});
export function setupPlugins(app: import('vue').App) {
console.group('🔌 Plugins');
for (const path in modules) {
const module = modules[path] as AutoInstallModule;
for (const path in autoInstallModules) {
const module = autoInstallModules[path] as AutoInstallModule;
if (module.install) {
module.install({ app });
console.debug(`%c✔ ${path}`, 'color: #07a');