|
|
@ -7,7 +7,6 @@ import { FG_Plugin } from 'src/plugins';
|
|
|
|
import routes from 'src/router/routes';
|
|
|
|
import routes from 'src/router/routes';
|
|
|
|
import { axios } from 'boot/axios';
|
|
|
|
import { axios } from 'boot/axios';
|
|
|
|
import { AxiosResponse } from 'axios';
|
|
|
|
import { AxiosResponse } from 'axios';
|
|
|
|
import { flatRoutes } from '@dreamonkey/vue-routes-flattener';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
const config = {
|
|
|
|
// Do not change required Modules !!
|
|
|
|
// Do not change required Modules !!
|
|
|
@ -44,21 +43,16 @@ function combineRoutes(
|
|
|
|
target.forEach(target => {
|
|
|
|
target.forEach(target => {
|
|
|
|
if (target.path === mainPath) {
|
|
|
|
if (target.path === mainPath) {
|
|
|
|
source.forEach((sourceMainConfig: FG_Plugin.PluginRouteConfig) => {
|
|
|
|
source.forEach((sourceMainConfig: FG_Plugin.PluginRouteConfig) => {
|
|
|
|
const targetMainConfig = target.children?.find(
|
|
|
|
const targetMainConfig = target.children?.find((targetMainConfig: RouteConfig) => {
|
|
|
|
(targetMainConfig: RouteConfig) => {
|
|
|
|
return sourceMainConfig.path === targetMainConfig.path;
|
|
|
|
return sourceMainConfig.path === targetMainConfig.path;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (targetMainConfig) {
|
|
|
|
if (targetMainConfig) {
|
|
|
|
const sourceChildren: RouteConfig[] = [];
|
|
|
|
const sourceChildren: RouteConfig[] = [];
|
|
|
|
sourceMainConfig.children?.forEach(child => {
|
|
|
|
sourceMainConfig.children?.forEach(child => {
|
|
|
|
sourceChildren.push(<RouteConfig>child);
|
|
|
|
sourceChildren.push(<RouteConfig>child);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (targetMainConfig.children) {
|
|
|
|
if (targetMainConfig.children) {
|
|
|
|
targetMainConfig.children = Object.assign(
|
|
|
|
targetMainConfig.children = Object.assign(targetMainConfig.children, sourceChildren);
|
|
|
|
targetMainConfig.children,
|
|
|
|
|
|
|
|
sourceChildren
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
targetMainConfig.children = sourceChildren;
|
|
|
|
targetMainConfig.children = sourceChildren;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -66,6 +60,12 @@ function combineRoutes(
|
|
|
|
if (target.children === undefined) {
|
|
|
|
if (target.children === undefined) {
|
|
|
|
target.children = [];
|
|
|
|
target.children = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
sourceMainConfig.children &&
|
|
|
|
|
|
|
|
sourceMainConfig.children.length > 0 &&
|
|
|
|
|
|
|
|
!sourceMainConfig.component
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
sourceMainConfig.component = () => import('src/components/navigation/EmptyParent.vue');
|
|
|
|
target.children.push(<RouteConfig>sourceMainConfig);
|
|
|
|
target.children.push(<RouteConfig>sourceMainConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -79,26 +79,22 @@ function combineMainLinks(
|
|
|
|
target: FG_Plugin.PluginMainLink[],
|
|
|
|
target: FG_Plugin.PluginMainLink[],
|
|
|
|
source: FG_Plugin.PluginRouteConfig
|
|
|
|
source: FG_Plugin.PluginRouteConfig
|
|
|
|
): FG_Plugin.PluginMainLink[] {
|
|
|
|
): FG_Plugin.PluginMainLink[] {
|
|
|
|
const targetPluginMainLink:
|
|
|
|
const targetPluginMainLink: FG_Plugin.PluginMainLink | undefined = target.find(
|
|
|
|
| FG_Plugin.PluginMainLink
|
|
|
|
|
|
|
|
| undefined = target.find(
|
|
|
|
|
|
|
|
(targetPluginMainLink: FG_Plugin.PluginMainLink) => {
|
|
|
|
(targetPluginMainLink: FG_Plugin.PluginMainLink) => {
|
|
|
|
console.log(targetPluginMainLink.title, source.title);
|
|
|
|
console.log(targetPluginMainLink.title, source.title);
|
|
|
|
return targetPluginMainLink.title == source.title;
|
|
|
|
return targetPluginMainLink.title == source.title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (targetPluginMainLink) {
|
|
|
|
if (targetPluginMainLink) {
|
|
|
|
source.children?.forEach(
|
|
|
|
source.children?.forEach((sourcePluginChildLink: FG_Plugin.PluginRouteConfig) => {
|
|
|
|
(sourcePluginChildLink: FG_Plugin.PluginRouteConfig) => {
|
|
|
|
targetPluginMainLink.children.push(<FG_Plugin.PluginChildLink>{
|
|
|
|
targetPluginMainLink.children.push(<FG_Plugin.PluginChildLink>{
|
|
|
|
title: sourcePluginChildLink.title,
|
|
|
|
title: sourcePluginChildLink.title,
|
|
|
|
icon: sourcePluginChildLink.icon,
|
|
|
|
icon: sourcePluginChildLink.icon,
|
|
|
|
link: sourcePluginChildLink.name,
|
|
|
|
link: sourcePluginChildLink.name,
|
|
|
|
name: sourcePluginChildLink.name,
|
|
|
|
name: sourcePluginChildLink.name,
|
|
|
|
permissions: sourcePluginChildLink.meta?.permissions
|
|
|
|
permissions: sourcePluginChildLink.meta?.permissions
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const mainLink: FG_Plugin.PluginMainLink = <FG_Plugin.PluginMainLink>{
|
|
|
|
const mainLink: FG_Plugin.PluginMainLink = <FG_Plugin.PluginMainLink>{
|
|
|
|
title: source.title,
|
|
|
|
title: source.title,
|
|
|
@ -158,36 +154,18 @@ function loadPlugin(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (plugin) {
|
|
|
|
if (plugin) {
|
|
|
|
if (plugin.mainRoutes) {
|
|
|
|
if (plugin.mainRoutes) {
|
|
|
|
loadedPlugins.routes = combineRoutes(
|
|
|
|
loadedPlugins.routes = combineRoutes(loadedPlugins.routes, plugin.mainRoutes, '/main');
|
|
|
|
loadedPlugins.routes,
|
|
|
|
|
|
|
|
plugin.mainRoutes,
|
|
|
|
|
|
|
|
'/main'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
plugin.mainRoutes.forEach(route => {
|
|
|
|
plugin.mainRoutes.forEach(route => {
|
|
|
|
loadedPlugins.mainLinks = combineMainLinks(
|
|
|
|
loadedPlugins.mainLinks = combineMainLinks(loadedPlugins.mainLinks, route);
|
|
|
|
loadedPlugins.mainLinks,
|
|
|
|
|
|
|
|
route
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
loadedPlugins.shortcuts = loadShortCuts(
|
|
|
|
loadedPlugins.shortcuts = loadShortCuts(loadedPlugins.shortcuts, plugin.mainRoutes);
|
|
|
|
loadedPlugins.shortcuts,
|
|
|
|
|
|
|
|
plugin.mainRoutes
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (plugin.outRoutes) {
|
|
|
|
if (plugin.outRoutes) {
|
|
|
|
loadedPlugins.routes = combineRoutes(
|
|
|
|
loadedPlugins.routes = combineRoutes(loadedPlugins.routes, plugin.outRoutes);
|
|
|
|
loadedPlugins.routes,
|
|
|
|
loadedPlugins.shortcutsOut = loadShortCuts(loadedPlugins.shortcutsOut, plugin.outRoutes);
|
|
|
|
plugin.outRoutes
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
loadedPlugins.shortcutsOut = loadShortCuts(
|
|
|
|
|
|
|
|
loadedPlugins.shortcutsOut,
|
|
|
|
|
|
|
|
plugin.outRoutes
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (plugin.widgets.length > 0) {
|
|
|
|
if (plugin.widgets.length > 0) {
|
|
|
|
plugin.widgets.forEach(
|
|
|
|
plugin.widgets.forEach(widget => (widget.name = plugin.name + '_' + widget.name));
|
|
|
|
widget => (widget.name = plugin.name + '_' + widget.name)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets);
|
|
|
|
Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (plugin.store) {
|
|
|
|
if (plugin.store) {
|
|
|
@ -258,26 +236,22 @@ export default boot<Store<StateInterface>>(({ Vue, router, store }) => {
|
|
|
|
config.loadModules.includes(requiredModule)
|
|
|
|
config.loadModules.includes(requiredModule)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
console.error(
|
|
|
|
console.error(`Plugin ${plugin.name} need Plugin ${requiredModule}`);
|
|
|
|
`Plugin ${plugin.name} need Plugin ${requiredModule}`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
router.push({ name: 'error' }).catch(e => {
|
|
|
|
router.push({ name: 'error' }).catch(e => {
|
|
|
|
console.warn(e);
|
|
|
|
console.warn(e);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
plugin.requiredBackendModules.forEach(
|
|
|
|
plugin.requiredBackendModules.forEach((requiredBackendModule: string) => {
|
|
|
|
(requiredBackendModule: string) => {
|
|
|
|
if (!(requiredBackendModule in backend.plugins)) {
|
|
|
|
if (!(requiredBackendModule in backend.plugins)) {
|
|
|
|
console.error(
|
|
|
|
console.error(
|
|
|
|
`Plugin ${plugin.name} need Plugin ${requiredBackendModule} in backend.`
|
|
|
|
`Plugin ${plugin.name} need Plugin ${requiredBackendModule} in backend.`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
router.push({ name: 'error' }).catch(err => {
|
|
|
|
router.push({ name: 'error' }).catch(err => {
|
|
|
|
console.warn(err);
|
|
|
|
console.warn(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -306,7 +280,7 @@ export default boot<Store<StateInterface>>(({ Vue, router, store }) => {
|
|
|
|
loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);
|
|
|
|
loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);
|
|
|
|
|
|
|
|
|
|
|
|
// add new routes for plugins, flatten them to allow empty parent routes
|
|
|
|
// add new routes for plugins, flatten them to allow empty parent routes
|
|
|
|
router.addRoutes(flatRoutes(loadedPlugins.routes));
|
|
|
|
router.addRoutes(loadedPlugins.routes);
|
|
|
|
|
|
|
|
|
|
|
|
// save plugins in VM-variable
|
|
|
|
// save plugins in VM-variable
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
|
|