feat: 支持 disableDefaultSettingPanel 禁止默认的设置面板

This commit is contained in:
lihao.ylh 2021-06-28 17:13:46 +08:00
parent 29eeaa07d1
commit cc465469b2
2 changed files with 78 additions and 65 deletions

View File

@ -1,5 +1,68 @@
import lodashGet from 'lodash.get'; import lodashGet from 'lodash.get';
export interface EngineOptions {
/**
* condition condition
*/
enableCondition?: boolean;
/**
* live 'design'
*/
designMode?: 'design' | 'live';
/**
* 'default'
*/
device?: 'default' | 'mobile' | string;
/**
* 'zh_CN'
*/
locale?: string;
/**
* 'react'
*/
renderEnv?: 'react' | 'rax' | string;
/**
* device
*/
deviceMapper?: {
transform: (originalDevice: string) => string;
};
/**
* false
*/
enableReactiveContainer?: boolean;
/**
* false
*/
disableAutoRender?: boolean;
/**
* 线false
*/
disableDetecting?: boolean;
/**
* selectorsundefined
*/
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[]) => string[];
/**
* false
*/
disableDefaultSettingPanel: boolean,
/**
* false
*/
disableDefaultSetters: boolean,
/**
* Vision-polyfill settings
*/
visionSettings?: {
// 是否禁用降级 reducer默认值false
disableCompatibleReducer?: boolean;
// 是否开启在 render 阶段开启 filter reducer默认值false
enableFilterReducerInRenderStage?: boolean;
};
[key: string]: any;
}
export class EngineConfig { export class EngineConfig {
private config: { [key: string]: any } = {}; private config: { [key: string]: any } = {};

View File

@ -1,6 +1,6 @@
import { createElement } from 'react'; import { createElement } from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import { globalContext, Editor, engineConfig } from '@ali/lowcode-editor-core'; import { globalContext, Editor, engineConfig, EngineOptions } from '@ali/lowcode-editor-core';
import * as editorCabin from '@ali/lowcode-editor-core'; import * as editorCabin from '@ali/lowcode-editor-core';
import { import {
Designer, Designer,
@ -108,6 +108,7 @@ plugins.register((ctx: ILowCodePluginContext) => {
return { return {
name: '___setter_registry___', name: '___setter_registry___',
init() { init() {
if (engineConfig.get('disableDefaultSetters')) return;
const builtinSetters = require('@ali/lowcode-engine-ext')?.setters; const builtinSetters = require('@ali/lowcode-engine-ext')?.setters;
if (builtinSetters) { if (builtinSetters) {
ctx.setters.registerSetter(builtinSetters); ctx.setters.registerSetter(builtinSetters);
@ -127,15 +128,17 @@ plugins.register((ctx: ILowCodePluginContext) => {
type: 'Widget', type: 'Widget',
content: DesignerPlugin, content: DesignerPlugin,
}); });
skeleton.add({ if (!engineConfig.get('disableDefaultSettingPanel')) {
area: 'rightArea', skeleton.add({
name: 'settingsPane', area: 'rightArea',
type: 'Panel', name: 'settingsPane',
content: SettingsPrimaryPane, type: 'Panel',
props: { content: SettingsPrimaryPane,
ignoreRoot: true, props: {
}, ignoreRoot: true,
}); },
});
}
skeleton.add({ skeleton.add({
area: 'leftArea', area: 'leftArea',
name: 'outlinePane', name: 'outlinePane',
@ -160,60 +163,6 @@ plugins.register((ctx: ILowCodePluginContext) => {
}; };
}); });
interface EngineOptions {
/**
* condition condition
*/
enableCondition?: boolean;
/**
* live 'design'
*/
designMode?: 'design' | 'live';
/**
* 'default'
*/
device?: 'default' | 'mobile' | string;
/**
* 'zh_CN'
*/
locale?: string;
/**
* 'react'
*/
renderEnv?: 'react' | 'rax' | string;
/**
* device
*/
deviceMapper?: {
transform: (originalDevice: string) => string;
};
/**
* false
*/
enableReactiveContainer?: boolean;
/**
* false
*/
disableAutoRender?: boolean;
/**
* 线false
*/
disableDetecting?: boolean;
/**
* selectors(selectors) => selectors
*/
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[]) => string[];
/**
* Vision-polyfill settings
*/
visionSettings?: {
// 是否禁用降级 reducer默认值false
disableCompatibleReducer?: boolean;
// 是否开启在 render 阶段开启 filter reducer默认值false
enableFilterReducerInRenderStage?: boolean;
};
[key: string]: any;
}
export async function init(container?: Element, options?: EngineOptions) { export async function init(container?: Element, options?: EngineOptions) {
let engineOptions = null; let engineOptions = null;
let engineContainer = null; let engineContainer = null;
@ -231,8 +180,9 @@ export async function init(container?: Element, options?: EngineOptions) {
} }
engineContainer.id = 'engine'; engineContainer.id = 'engine';
await plugins.init();
engineConfig.setConfig(engineOptions as any); engineConfig.setConfig(engineOptions as any);
await plugins.init();
render( render(
createElement(Workbench, { createElement(Workbench, {
skeleton, skeleton,