mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-08-12 14:52:00 +08:00
* feat(plugin-layout): 支持运行时配置menus * refactor(plugin-model): 去掉provide * refactor(plugin-layout): 优化runtimeConfig,重新实现运行时menus配置方式,修复多页时setup执行两次的bug * feat(plugin-layout): 菜单支持配置默认展开等 * refactor: 优化
30 lines
615 B
Smarty
30 lines
615 B
Smarty
|
|
{{{userImports}}}
|
|
{{{extraImports}}}
|
|
|
|
export const models = {
|
|
{{#extraModels}}
|
|
{{{extraModels}}},
|
|
{{/extraModels}}
|
|
{{#userModels}}
|
|
{{{userModels}}},
|
|
{{/userModels}}
|
|
};
|
|
|
|
|
|
const cache = new Map();
|
|
|
|
export const useModel = (name) => {
|
|
const modelFunc = models[name];
|
|
if (modelFunc === undefined) {
|
|
throw new Error('[plugin-model]: useModel, name is undefined.');
|
|
}
|
|
if (typeof modelFunc !== 'function') {
|
|
throw new Error('[plugin-model]: useModel is not a function.');
|
|
}
|
|
if (!cache.has(name)) {
|
|
cache.set(name, modelFunc());
|
|
}
|
|
return cache.get(name);
|
|
};
|