[Vue3] Fixed usage of plugins
This commit is contained in:
parent
9967296698
commit
b2d54a046f
|
@ -156,13 +156,13 @@ function loadShortCuts(
|
|||
|
||||
// loade plugins
|
||||
function loadPlugin(
|
||||
loadedPlugins: FG_Plugin.LoadedPlugins,
|
||||
loadedPlugins: FG_Plugin.Flaschengeist,
|
||||
modules: string[],
|
||||
backendpromise: Promise<Backend | null>,
|
||||
plugins: FG_Plugin.Plugin[],
|
||||
store: Store<UserSessionState>,
|
||||
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<UserSessionState>(({ 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<UserSessionState>(({ 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
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<!-- Hier kommen die Shortlinks hin -->
|
||||
<div>
|
||||
<short-cut-link
|
||||
v-for="(shortcut, index) in plugins.shortcuts"
|
||||
v-for="(shortcut, index) in flaschengeist.shortcuts"
|
||||
:key="'shortcut' + index"
|
||||
:link="shortcut.link"
|
||||
:icon="shortcut.icon"
|
||||
|
@ -46,7 +46,7 @@
|
|||
<!-- Plugins -->
|
||||
<q-list>
|
||||
<essential-link
|
||||
v-for="(link, index) in plugins.mainLinks"
|
||||
v-for="(link, index) in flaschengeist.mainLinks"
|
||||
:key="'plugin' + index"
|
||||
:title="link.title"
|
||||
:link="link.link"
|
||||
|
@ -137,7 +137,7 @@ export default defineComponent({
|
|||
setup() {
|
||||
const route = useRoute();
|
||||
const store = useStore();
|
||||
const plugins = inject<FG_Plugin.LoadedPlugins>('flaschengeistPlugins');
|
||||
const flaschengeist = inject<FG_Plugin.Flaschengeist>('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,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</q-toolbar-title>
|
||||
<div>
|
||||
<short-cut-link
|
||||
v-for="(shortcut, index) in plugins.shortcutsOut"
|
||||
v-for="(shortcut, index) in shortcuts"
|
||||
:key="'shortcut' + index"
|
||||
:link="shortcut.link"
|
||||
:icon="shortcut.icon"
|
||||
|
@ -50,8 +50,8 @@ export default defineComponent({
|
|||
name: 'OutLayout',
|
||||
components: { ShortCutLink },
|
||||
setup() {
|
||||
const plugins = inject<FG_Plugin.LoadedPlugins>('flaschengeistPlugins');
|
||||
return { plugins };
|
||||
const shortcuts = inject<FG_Plugin.Flaschengeist>('flaschengeist')?.shortcutsOut || [];
|
||||
return { shortcuts };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -18,10 +18,10 @@ export default defineComponent({
|
|||
name: 'Dashboard',
|
||||
setup() {
|
||||
const widgets = markRaw<Array<Component>>([]);
|
||||
const flaschengeistPlugins = inject<FG_Plugin.LoadedPlugins>('flaschengeistPlugins');
|
||||
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
|
||||
|
||||
onMounted(() => {
|
||||
flaschengeistPlugins?.widgets.forEach((widget) => {
|
||||
flaschengeist?.widgets.forEach((widget) => {
|
||||
if (hasPermissions(widget.permissions)) widgets.push(widget.widget);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<div v-if="$route.name == 'about'" class="col-12 text-h6 q-pa-sm">Geladene Plugins:</div>
|
||||
<div v-if="$route.name == 'about'" class="col-12 q-pa-sm">
|
||||
<q-chip
|
||||
v-for="(plugin, index) in $flaschengeistPlugins.plugins"
|
||||
v-for="(plugin, index) in plugins"
|
||||
:key="'plugin' + index"
|
||||
square
|
||||
:color="$q.dark.isActive ? 'accent' : ''"
|
||||
|
@ -59,8 +59,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { defineComponent, inject } from 'vue';
|
||||
import Developer from 'components/about/Developer.vue';
|
||||
import { FG_Plugin } from 'src/plugins';
|
||||
|
||||
const developers = [
|
||||
{
|
||||
|
@ -94,10 +95,11 @@ const developers = [
|
|||
},
|
||||
];
|
||||
export default defineComponent({
|
||||
// name: 'PageName'
|
||||
name: 'About',
|
||||
components: { Developer },
|
||||
setup() {
|
||||
return { developers };
|
||||
const plugins = inject<FG_Plugin.Flaschengeist>('flaschengeist')?.plugins || [];
|
||||
return { developers, plugins };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -54,7 +54,7 @@ declare namespace FG_Plugin {
|
|||
version: string;
|
||||
}
|
||||
|
||||
interface LoadedPlugins {
|
||||
interface Flaschengeist {
|
||||
plugins: LoadedPlugin[];
|
||||
routes: RouteRecordRaw[];
|
||||
mainLinks: PluginMainLink[];
|
||||
|
|
Loading…
Reference in New Issue