flaschengeist-frontend/src/boot/plugins.ts

45 lines
1.7 KiB
TypeScript
Raw Normal View History

import { boot } from 'quasar/wrappers';
import { RouteConfig } from 'vue-router';
import { Module } from 'vuex';
import {} from 'webpack';
interface PluginRouteConfig extends RouteConfig {
example?: unknown;
}
interface EssentialLink {
title: string;
link: string;
icon?: string;
}
interface Plugin {
router: PluginRouteConfig[];
store?: Module<any, any>;
mainLink: EssentialLink;
}
export { PluginRouteConfig, Plugin };
// "async" is optional;
// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
export default boot(({ Vue, router, store }) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
const plugins: any = require.context('src/plugins', true, /.+\/plugin.ts$/);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
let mop = [];
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
plugins.keys().forEach((fileName: any) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
router.addRoutes(plugins(fileName).default.router);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
mop.push(plugins(fileName).default.mainLink);
});
Vue.prototype.$flaschengeist_plugins = mop;
console.log(plugins);
});