From b2d54a046f247802b10c19f9a514ebc1c3b18c1f Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 4 Feb 2021 02:42:49 +0100 Subject: [PATCH] [Vue3] Fixed usage of plugins --- src/boot/plugins.ts | 10 +++++++--- src/layouts/MainLayout.vue | 10 +++++----- src/layouts/OutLayout.vue | 6 +++--- src/pages/Dashboard.vue | 4 ++-- src/pages/about/About.vue | 10 ++++++---- src/plugins.d.ts | 2 +- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/boot/plugins.ts b/src/boot/plugins.ts index a6ea6ec..3943b49 100644 --- a/src/boot/plugins.ts +++ b/src/boot/plugins.ts @@ -156,13 +156,13 @@ function loadShortCuts( // loade plugins function loadPlugin( - loadedPlugins: FG_Plugin.LoadedPlugins, + loadedPlugins: FG_Plugin.Flaschengeist, modules: string[], backendpromise: Promise, plugins: FG_Plugin.Plugin[], store: Store, router: Router -): FG_Plugin.LoadedPlugins { +): FG_Plugin.Flaschengeist { modules.forEach((requiredModule) => { const plugin = plugins.find((plugin) => { return plugin.name == requiredModule; @@ -223,7 +223,7 @@ export default boot(({ router, store, app }) => { const backendPromise = getBackend(); - let loadedPlugins: FG_Plugin.LoadedPlugins = { + let loadedPlugins: FG_Plugin.Flaschengeist = { routes, plugins: [], mainLinks: [], @@ -298,6 +298,10 @@ export default boot(({ router, store, app }) => { loadedPlugins.routes.forEach((route) => router.addRoute(route)); // save plugins in VM-variable +<<<<<<< HEAD console.log(store); app.provide('flaschengeistPlugins', loadedPlugins); +======= + app.provide('flaschengeist', loadedPlugins); +>>>>>>> 3a1cb84... [Vue3] Fixed usage of plugins }); diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 0cee983..0eda61e 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -24,7 +24,7 @@
('flaschengeistPlugins'); + const flaschengeist = inject('flaschengeist'); const leftDrawer = ref(false); const leftDrawerOpen = ref( @@ -155,7 +155,7 @@ export default defineComponent({ } const pluginChildLinks = computed(() => { - const link: FG_Plugin.PluginMainLink | undefined = plugins?.mainLinks.find( + const link: FG_Plugin.PluginMainLink | undefined = flaschengeist?.mainLinks.find( (plugin: FG_Plugin.PluginMainLink) => { if (route.matched.length > 1) { return plugin.name == route.matched[1].name; @@ -185,7 +185,7 @@ export default defineComponent({ pluginChildLinks, shortcuts, logout, - plugins, + flaschengeist, }; }, }); diff --git a/src/layouts/OutLayout.vue b/src/layouts/OutLayout.vue index bb78908..f5c0712 100644 --- a/src/layouts/OutLayout.vue +++ b/src/layouts/OutLayout.vue @@ -10,7 +10,7 @@
('flaschengeistPlugins'); - return { plugins }; + const shortcuts = inject('flaschengeist')?.shortcutsOut || []; + return { shortcuts }; }, }); diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index 06543a3..6c0858d 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -18,10 +18,10 @@ export default defineComponent({ name: 'Dashboard', setup() { const widgets = markRaw>([]); - const flaschengeistPlugins = inject('flaschengeistPlugins'); + const flaschengeist = inject('flaschengeist'); onMounted(() => { - flaschengeistPlugins?.widgets.forEach((widget) => { + flaschengeist?.widgets.forEach((widget) => { if (hasPermissions(widget.permissions)) widgets.push(widget.widget); }); }); diff --git a/src/pages/about/About.vue b/src/pages/about/About.vue index 991d76c..c1e1770 100644 --- a/src/pages/about/About.vue +++ b/src/pages/about/About.vue @@ -26,7 +26,7 @@
Geladene Plugins:
diff --git a/src/plugins.d.ts b/src/plugins.d.ts index cd92e91..3c20b91 100644 --- a/src/plugins.d.ts +++ b/src/plugins.d.ts @@ -54,7 +54,7 @@ declare namespace FG_Plugin { version: string; } - interface LoadedPlugins { + interface Flaschengeist { plugins: LoadedPlugin[]; routes: RouteRecordRaw[]; mainLinks: PluginMainLink[];