mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-10 01:48:18 +00:00
Merge branch feat/renderer-1.0.45 into release/1.0.45
Title: 渲染模块3个需求 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/5273568
This commit is contained in:
commit
ecfbe24e50
@ -231,7 +231,7 @@ class Renderer extends Component<{
|
|||||||
return createElement(
|
return createElement(
|
||||||
getDeviceView(Component, device, designMode),
|
getDeviceView(Component, device, designMode),
|
||||||
viewProps,
|
viewProps,
|
||||||
leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : null,
|
leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : children,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export default function addonRendererFactory() {
|
|||||||
const schema = props.__schema || {};
|
const schema = props.__schema || {};
|
||||||
this.state = this.__parseData(schema.state || {});
|
this.state = this.__parseData(schema.state || {});
|
||||||
if (isEmpty(props.config) || !props.config.addonKey) {
|
if (isEmpty(props.config) || !props.config.addonKey) {
|
||||||
console.warn('luna addon has wrong config');
|
console.warn('lce addon has wrong config');
|
||||||
this.state.__hasError = true;
|
this.state.__hasError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -268,9 +268,32 @@ export default function baseRenererFactory() {
|
|||||||
this.setLocale = (loc: string) => this.appHelper?.utils?.i18n?.setLocale && this.appHelper?.utils?.i18n?.setLocale(loc);
|
this.setLocale = (loc: string) => this.appHelper?.utils?.i18n?.setLocale && this.appHelper?.utils?.i18n?.setLocale(loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
__writeCss = () => {
|
||||||
|
const css = getValue(this.props.__schema, 'css', '');
|
||||||
|
let style = this.styleElement;
|
||||||
|
if (!this.styleElement) {
|
||||||
|
style = document.createElement('style');
|
||||||
|
style.type = 'text/css';
|
||||||
|
style.setAttribute('from', 'style-sheet');
|
||||||
|
if (style.firstChild) {
|
||||||
|
style.removeChild(style.firstChild);
|
||||||
|
}
|
||||||
|
const head = document.head || document.getElementsByTagName('head')[0];
|
||||||
|
head.appendChild(style);
|
||||||
|
this.styleElement = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (style.innerHTML === css) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
style.innerHTML = css;
|
||||||
|
};
|
||||||
|
|
||||||
__render = () => {
|
__render = () => {
|
||||||
const schema = this.props.__schema;
|
const schema = this.props.__schema;
|
||||||
this.__setLifeCycleMethods('render');
|
this.__setLifeCycleMethods('render');
|
||||||
|
this.__writeCss();
|
||||||
|
|
||||||
const { engine } = this.context;
|
const { engine } = this.context;
|
||||||
if (engine) {
|
if (engine) {
|
||||||
@ -441,7 +464,7 @@ export default function baseRenererFactory() {
|
|||||||
Comp = compWrapper(Comp);
|
Comp = compWrapper(Comp);
|
||||||
}
|
}
|
||||||
otherProps.ref = (ref: any) => {
|
otherProps.ref = (ref: any) => {
|
||||||
this.$(props.fieldId, ref); // 收集ref
|
this.$(props.fieldId || props.ref, ref); // 收集ref
|
||||||
const refProps = props.ref;
|
const refProps = props.ref;
|
||||||
if (refProps && typeof refProps === 'string') {
|
if (refProps && typeof refProps === 'string') {
|
||||||
this[refProps] = ref;
|
this[refProps] = ref;
|
||||||
@ -668,7 +691,7 @@ export default function baseRenererFactory() {
|
|||||||
|
|
||||||
$(filedId: string, instance?: any) {
|
$(filedId: string, instance?: any) {
|
||||||
this.__instanceMap = this.__instanceMap || {};
|
this.__instanceMap = this.__instanceMap || {};
|
||||||
if (!filedId) {
|
if (!filedId || typeof filedId !== 'string') {
|
||||||
return this.__instanceMap;
|
return this.__instanceMap;
|
||||||
}
|
}
|
||||||
if (instance) {
|
if (instance) {
|
||||||
|
|||||||
@ -90,7 +90,7 @@ export function inSameDomain() {
|
|||||||
export function getFileCssName(fileName: string) {
|
export function getFileCssName(fileName: string) {
|
||||||
if (!fileName) return;
|
if (!fileName) return;
|
||||||
const name = fileName.replace(/([A-Z])/g, '-$1').toLowerCase();
|
const name = fileName.replace(/([A-Z])/g, '-$1').toLowerCase();
|
||||||
return (`luna-${name}`)
|
return (`lce-${name}`)
|
||||||
.split('-')
|
.split('-')
|
||||||
.filter((p) => !!p)
|
.filter((p) => !!p)
|
||||||
.join('-');
|
.join('-');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user