Files
vue-ts-example-2025/src/plugins/index.ts
严浩 b4fcde324d
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 4m9s
CI/CD Pipeline / build-and-deploy (push) Successful in 4m38s
feat(auth): 添加用户认证模块与登录页面
2025-11-03 13:46:47 +08:00

30 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* https://github.com/antfu-collective/vitesse/blob/47618e72dfba76c77b9b85b94784d739e35c492b/src/modules/README.md
*/
type UserPlugin = (ctx: UserPluginContext) => void;
type AutoInstallModule = { [K: string]: unknown; install?: UserPlugin };
type UserPluginContext = { app: import('vue').App<Element> };
const autoInstallModules: AutoInstallModule = import.meta.glob(
['./*.ts', '!./**/*.types.ts', '!./index.ts'],
{
eager: true /* true 为同步false 为异步 */,
},
);
export function setupPlugins(app: import('vue').App) {
console.group(`🔌 Installing ${Object.keys(autoInstallModules).length} plugins`);
for (const path in autoInstallModules) {
const module = autoInstallModules[path] as AutoInstallModule;
if (module.install) {
module.install({ app });
console.debug(`%c✔ ${path}`, 'color: #07a');
} else {
if (typeof module.setupPlugins === 'function') continue;
console.warn(`%c✘ ${path} has no install function`, 'color: #f50');
}
}
console.groupEnd();
return app;
}