Fixed interface for Backend, allow redirect mainLinks
* Fixed the Backend interface to match the returned data structure * Allow empty parents in RouteConfig, use flatRoutes
This commit is contained in:
parent
c05fc5d877
commit
d4795a549f
|
@ -7,6 +7,7 @@ import {FG_Plugin} from 'src/plugins';
|
|||
import routes from 'src/router/routes';
|
||||
import { axios } from 'boot/axios';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { flatRoutes } from '@dreamonkey/vue-routes-flattener';
|
||||
|
||||
const config = {
|
||||
// Do not change required Modules !!
|
||||
|
@ -25,15 +26,15 @@ interface BackendPlugin {
|
|||
}
|
||||
|
||||
interface BackendPlugins {
|
||||
[key: string]: BackendPlugin
|
||||
[key: string]: BackendPlugin | null;
|
||||
}
|
||||
|
||||
interface Backend {
|
||||
plugins: [key: string];
|
||||
plugins: BackendPlugins[];
|
||||
version: string;
|
||||
}
|
||||
|
||||
export {Backend}
|
||||
export { Backend };
|
||||
|
||||
function combineRoutes(
|
||||
target: RouteConfig[],
|
||||
|
@ -200,9 +201,9 @@ function loadPlugin(
|
|||
});
|
||||
} else {
|
||||
console.exception(`Could not find required Plugin ${requiredModule}`);
|
||||
router.push({name: 'error'}).catch((e) => {
|
||||
console.warn(e)
|
||||
})
|
||||
router.push({ name: 'error' }).catch(e => {
|
||||
console.warn(e);
|
||||
});
|
||||
}
|
||||
});
|
||||
return loadedPlugins;
|
||||
|
@ -245,33 +246,44 @@ export default boot<Store<StateInterface>>(({Vue, router, store}) => {
|
|||
});
|
||||
|
||||
// check dependencies
|
||||
backendPromise.then((backend) => {
|
||||
console.log(backend)
|
||||
backendPromise
|
||||
.then(backend => {
|
||||
console.log(backend);
|
||||
if (backend) {
|
||||
plugins.forEach((plugin: FG_Plugin.Plugin) => {
|
||||
plugin.requiredModules.forEach((requiredModule: string) => {
|
||||
if (!(config.requiredModules.includes(requiredModule) || config.loadModules.includes(requiredModule))) {
|
||||
console.error(`Plugin ${plugin.name} need Plugin ${requiredModule}`)
|
||||
router.push({name: 'error'}).catch((e) => {
|
||||
console.warn(e)
|
||||
})
|
||||
if (
|
||||
!(
|
||||
config.requiredModules.includes(requiredModule) ||
|
||||
config.loadModules.includes(requiredModule)
|
||||
)
|
||||
) {
|
||||
console.error(
|
||||
`Plugin ${plugin.name} need Plugin ${requiredModule}`
|
||||
);
|
||||
router.push({ name: 'error' }).catch(e => {
|
||||
console.warn(e);
|
||||
});
|
||||
}
|
||||
})
|
||||
plugin.requiredBackendModules.forEach((requiredBackendModule: string) => {
|
||||
});
|
||||
plugin.requiredBackendModules.forEach(
|
||||
(requiredBackendModule: string) => {
|
||||
if (!(requiredBackendModule in backend.plugins)) {
|
||||
console.error(`Plugin ${plugin.name} need Plugin ${requiredBackendModule} in backend.`)
|
||||
console.error(
|
||||
`Plugin ${plugin.name} need Plugin ${requiredBackendModule} in backend.`
|
||||
);
|
||||
router.push({ name: 'error' }).catch(err => {
|
||||
console.warn(err)
|
||||
})
|
||||
console.warn(err);
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
// load plugins
|
||||
loadedPlugins = loadPlugin(
|
||||
|
@ -282,12 +294,19 @@ export default boot<Store<StateInterface>>(({Vue, router, store}) => {
|
|||
store,
|
||||
router
|
||||
);
|
||||
loadedPlugins = loadPlugin(loadedPlugins, config.loadModules, backendPromise, plugins, store, router);
|
||||
loadedPlugins = loadPlugin(
|
||||
loadedPlugins,
|
||||
config.loadModules,
|
||||
backendPromise,
|
||||
plugins,
|
||||
store,
|
||||
router
|
||||
);
|
||||
|
||||
loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);
|
||||
|
||||
// add new routes for plugins
|
||||
router.addRoutes(loadedPlugins.routes);
|
||||
// add new routes for plugins, flatten them to allow empty parent routes
|
||||
router.addRoutes(flatRoutes(loadedPlugins.routes));
|
||||
|
||||
// save plugins in VM-variable
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<template>
|
||||
<q-input
|
||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||
filled
|
||||
:readonly="readonly"
|
||||
:label="label"
|
||||
|
|
Loading…
Reference in New Issue