!516 feat(core): 在设计器模式下增加依赖库选项配置支持

Merge pull request !516 from StudiousTiger/fix-bug-support_plugin_ext_params_with_designer-mode
This commit is contained in:
踩着两条虫
2025-12-28 04:27:54 +00:00
committed by Gitee
2 changed files with 10 additions and 5 deletions

View File

@@ -88,6 +88,10 @@ export interface EngineOptions {
* 项目物料,优先于 project 的 dependencies
*/
materials?: Record<string, () => Promise<any>>;
/**
* 依赖库选项配置
*/
libraryOptions?: Record<string, any>;
/**
* 内置物料路径 BasePath
*/
@@ -195,6 +199,7 @@ export class Engine extends Base {
dependencies,
materials,
materialPath = './',
libraryOptions = {},
pageRouteName,
adapter,
install,
@@ -216,6 +221,7 @@ export class Engine extends Base {
dependencies,
materials,
materialPath,
libraryOptions,
adapter,
pageRouteName,
install

View File

@@ -63,6 +63,7 @@ export class Renderer {
const plugins = Object.entries(library);
Object.assign(app.config.globalProperties, globals);
app.config.globalProperties.$apis = apis;
const libraryOptions = this.provider?.options?.libraryOptions || {};
plugins.forEach(([name, plugin]) => {
if (!plugin) {
console.warn(`plugin: ${name} is undefined`);
@@ -80,11 +81,9 @@ export class Renderer {
typeof plugin === 'function' ||
typeof plugin.install === 'function'
) {
let options: Record<string, any> = {};
const locale = locales[name];
if (locale) {
options.locale = locale;
}
const locale = locales[name] || {};
const extraOptions = libraryOptions[name] || {};
const options = { ...locale, ...extraOptions };
try {
app?.use(plugin, options);
} catch (e) {