2020-10-12 21:49:05 +00:00
|
|
|
import { boot } from 'quasar/wrappers';
|
|
|
|
import { RouteConfig } from 'vue-router';
|
|
|
|
import { Module } from 'vuex';
|
|
|
|
|
|
|
|
interface PluginRouteConfig extends RouteConfig {
|
|
|
|
example?: unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface EssentialLink {
|
|
|
|
title: string;
|
|
|
|
link: string;
|
|
|
|
icon?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Plugin {
|
|
|
|
router: PluginRouteConfig[];
|
2020-10-13 09:27:27 +00:00
|
|
|
store?: Module<never, never>;
|
|
|
|
mainLink: PluginMainLink;
|
2020-10-12 21:49:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 09:27:27 +00:00
|
|
|
interface PluginMainLink extends PluginChildLink {
|
|
|
|
children: PluginChildLink[] | [];
|
|
|
|
}
|
|
|
|
|
|
|
|
interface PluginChildLink {
|
|
|
|
name: string;
|
|
|
|
title: string;
|
|
|
|
link: string;
|
|
|
|
icon: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export { PluginRouteConfig, Plugin, PluginChildLink, PluginMainLink };
|
2020-10-12 21:49:05 +00:00
|
|
|
|
|
|
|
// "async" is optional;
|
|
|
|
// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file
|
2020-10-13 09:27:27 +00:00
|
|
|
export default boot(({ Vue, router }) => {
|
|
|
|
const plugins = require.context('src/plugins', true, /.+\/plugin.ts$/);
|
|
|
|
const pluginMainLinks: PluginMainLink[] = [];
|
|
|
|
plugins.keys().forEach((fileName: string) => {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
2020-10-12 21:49:05 +00:00
|
|
|
router.addRoutes(plugins(fileName).default.router);
|
2020-10-13 09:27:27 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
|
|
pluginMainLinks.push(plugins(fileName).default.mainLink);
|
2020-10-12 21:49:05 +00:00
|
|
|
});
|
2020-10-13 09:27:27 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
|
|
Vue.prototype.$flaschengeist_plugins = pluginMainLinks;
|
2020-10-12 21:49:05 +00:00
|
|
|
console.log(plugins);
|
|
|
|
});
|