mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-12 02:46:08 +00:00
fix: modify layout props
This commit is contained in:
parent
10a618e39f
commit
9baba75ca1
@ -15,8 +15,6 @@ export class BemTools extends Component<{ host: BuiltinSimulatorHost }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// yiyi
|
|
||||||
// live 模式选中,画布会不会有相关交互
|
|
||||||
const { host } = this.props;
|
const { host } = this.props;
|
||||||
const { designMode } = host;
|
const { designMode } = host;
|
||||||
const { scrollX, scrollY, scale } = host.viewport;
|
const { scrollX, scrollY, scale } = host.viewport;
|
||||||
|
|||||||
@ -278,7 +278,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupEvents() {
|
setupEvents() {
|
||||||
debugger;
|
|
||||||
// TODO: Thinkof move events control to simulator renderer
|
// TODO: Thinkof move events control to simulator renderer
|
||||||
// just listen special callback
|
// just listen special callback
|
||||||
// because iframe maybe reload
|
// because iframe maybe reload
|
||||||
@ -333,6 +332,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
if (isMulti && !isRootNode(node) && selection.has(id)) {
|
if (isMulti && !isRootNode(node) && selection.has(id)) {
|
||||||
selection.remove(id);
|
selection.remove(id);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: 加个开关控制(yiyi)
|
||||||
|
// 如果选中的为 Page 节点,则默认选中第一个子节点
|
||||||
if (node.isPage() && node.getChildren()?.notEmpty()) {
|
if (node.isPage() && node.getChildren()?.notEmpty()) {
|
||||||
const firstChildId = node
|
const firstChildId = node
|
||||||
.getChildren()
|
.getChildren()
|
||||||
|
|||||||
@ -166,9 +166,17 @@ export class Designer {
|
|||||||
selectionDispose();
|
selectionDispose();
|
||||||
selectionDispose = undefined;
|
selectionDispose = undefined;
|
||||||
}
|
}
|
||||||
this.postEvent('selection.change', this.currentSelection);
|
// TODO: 加开关控制(yiyi)
|
||||||
if (this.currentSelection) {
|
// 避免选中 Page 组件,默认选中第一个子节点
|
||||||
const currentSelection = this.currentSelection;
|
const currentSelection = this.currentSelection;
|
||||||
|
if (currentSelection && currentSelection.selected.length === 0) {
|
||||||
|
const rootNodeChildrens = this.currentDocument.getRoot().getChildren().children;
|
||||||
|
if (rootNodeChildrens.length > 0) {
|
||||||
|
currentSelection.select(rootNodeChildrens[0].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.postEvent('selection.change', currentSelection);
|
||||||
|
if (currentSelection) {
|
||||||
selectionDispose = currentSelection.onSelectionChange(() => {
|
selectionDispose = currentSelection.onSelectionChange(() => {
|
||||||
this.postEvent('selection.change', currentSelection);
|
this.postEvent('selection.change', currentSelection);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,6 +58,22 @@ const pages = Object.assign(project, {
|
|||||||
props: {
|
props: {
|
||||||
logo: '',
|
logo: '',
|
||||||
name: '测试网站',
|
name: '测试网站',
|
||||||
|
tabBars: {
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
name: "页面1",
|
||||||
|
pagePath: "home1",
|
||||||
|
icon: "https://pre-go.alibaba-inc.com/filehandle?fileName…8e9-ff58-4e7a-bd24-9e5c32244e14.png&type=download",
|
||||||
|
activeIcon: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
activeIcon: "",
|
||||||
|
name: "页面2",
|
||||||
|
icon: "",
|
||||||
|
pagePath: "home2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -218,7 +218,7 @@ export function useRouter(routerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (_initialized) throw new Error('Error: useRouter can only be called once.');
|
if (_initialized) return;
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
const history = _routerConfig.history;
|
const history = _routerConfig.history;
|
||||||
const routes = _routerConfig.routes;
|
const routes = _routerConfig.routes;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export default class SimulatorRendererView extends Component<{ rendererContainer
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { rendererContainer } = this.props;
|
const { rendererContainer } = this.props;
|
||||||
this.unlisten = rendererContainer.onDocumentChange(() => {
|
this.unlisten = rendererContainer.onLayoutChange(() => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -104,6 +104,13 @@ function getDeviceView(view: any, device: string, mode: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }> {
|
class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }> {
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
this.props.rendererContainer.onReRender(() => {
|
||||||
|
this.forceUpdate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { rendererContainer, children } = this.props;
|
const { rendererContainer, children } = this.props;
|
||||||
const layout = rendererContainer.layout;
|
const layout = rendererContainer.layout;
|
||||||
@ -114,7 +121,14 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
|
|||||||
return <Component props={props}>{children}</Component>;
|
return <Component props={props}>{children}</Component>;
|
||||||
}
|
}
|
||||||
if (componentName) {
|
if (componentName) {
|
||||||
return createElement(rendererContainer.getComponent(componentName), {}, [children]);
|
return createElement(
|
||||||
|
rendererContainer.getComponent(componentName),
|
||||||
|
{
|
||||||
|
...props,
|
||||||
|
rendererContainer,
|
||||||
|
},
|
||||||
|
[children],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -237,6 +237,9 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.dispose = host.connect(this, () => {
|
this.dispose = host.connect(this, () => {
|
||||||
// sync layout config
|
// sync layout config
|
||||||
|
debugger;
|
||||||
|
this._layout = host.project.get('config').layout;
|
||||||
|
|
||||||
// todo: split with others, not all should recompute
|
// todo: split with others, not all should recompute
|
||||||
if (this._libraryMap !== host.libraryMap || this._componentsMap !== host.designer.componentsMap) {
|
if (this._libraryMap !== host.libraryMap || this._componentsMap !== host.designer.componentsMap) {
|
||||||
this._libraryMap = host.libraryMap || {};
|
this._libraryMap = host.libraryMap || {};
|
||||||
@ -249,6 +252,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
|
|
||||||
// sync device
|
// sync device
|
||||||
this._device = host.device;
|
this._device = host.device;
|
||||||
|
|
||||||
|
this.emitter.emit('layoutChange');
|
||||||
});
|
});
|
||||||
const documentInstanceMap = new Map<string, DocumentInstance>();
|
const documentInstanceMap = new Map<string, DocumentInstance>();
|
||||||
let initialEntry = '/';
|
let initialEntry = '/';
|
||||||
@ -261,7 +266,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
}
|
}
|
||||||
return inst;
|
return inst;
|
||||||
});
|
});
|
||||||
this.emitter.emit('documentChange');
|
this.emitter.emit('layoutChange');
|
||||||
const path = host.project.currentDocument ? documentInstanceMap.get(host.project.currentDocument.id)!.path : '/';
|
const path = host.project.currentDocument ? documentInstanceMap.get(host.project.currentDocument.id)!.path : '/';
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
initialEntry = path;
|
initialEntry = path;
|
||||||
@ -308,9 +313,13 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@obx private _layout: any = null;
|
||||||
@computed get layout(): any {
|
@computed get layout(): any {
|
||||||
// TODO: parse layout Component
|
// TODO: parse layout Component
|
||||||
return null;
|
return this._layout;
|
||||||
|
}
|
||||||
|
set layout(value: any) {
|
||||||
|
this._layout = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _libraryMap: { [key: string]: string } = {};
|
private _libraryMap: { [key: string]: string } = {};
|
||||||
@ -439,10 +448,17 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
cursor.release();
|
cursor.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
onDocumentChange(cb: () => void) {
|
onLayoutChange(cb: () => void) {
|
||||||
this.emitter.on('documentChange', cb);
|
this.emitter.on('layoutChange', cb);
|
||||||
return () => {
|
return () => {
|
||||||
this.emitter.removeListener('documentChange', cb);
|
this.emitter.removeListener('layoutChange', cb);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
onReRender(fn: () => void) {
|
||||||
|
this.emitter.on('rerender', fn);
|
||||||
|
return () => {
|
||||||
|
this.emitter.removeListener('renderer', fn);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -141,6 +141,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.dispose = host.connect(this, () => {
|
this.dispose = host.connect(this, () => {
|
||||||
// sync layout config
|
// sync layout config
|
||||||
|
this._layout = host.project.get('config').layout;
|
||||||
|
|
||||||
// todo: split with others, not all should recompute
|
// todo: split with others, not all should recompute
|
||||||
if (this._libraryMap !== host.libraryMap || this._componentsMap !== host.designer.componentsMap) {
|
if (this._libraryMap !== host.libraryMap || this._componentsMap !== host.designer.componentsMap) {
|
||||||
this._libraryMap = host.libraryMap || {};
|
this._libraryMap = host.libraryMap || {};
|
||||||
@ -213,9 +215,13 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@obx private _layout: any = null;
|
||||||
@computed get layout(): any {
|
@computed get layout(): any {
|
||||||
// TODO: parse layout Component
|
// TODO: parse layout Component
|
||||||
return null;
|
return this._layout;
|
||||||
|
}
|
||||||
|
set layout(value: any) {
|
||||||
|
this._layout = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _libraryMap: { [key: string]: string } = {};
|
private _libraryMap: { [key: string]: string } = {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user