fix: 暂时使用 live 模式作为条件判断是否限制选中 Page 组件

This commit is contained in:
wanying.jwy 2020-09-14 10:42:18 +08:00
parent d4f8467abd
commit 0bab0307f7
2 changed files with 4 additions and 5 deletions

View File

@ -332,9 +332,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
if (isMulti && !isRootNode(node) && selection.has(id)) {
selection.remove(id);
} else {
// TODO: 加个开关控制yiyi
// 如果选中的为 Page 节点,则默认选中第一个子节点
if (node.isPage() && node.getChildren()?.notEmpty()) {
// TODO: 避免选中 Page 组件,默认选中第一个子节点;新增规则 或 判断 Live 模式
if (node.isPage() && node.getChildren()?.notEmpty() && this.designMode === 'live') {
const firstChildId = node
.getChildren()
?.get(0)

View File

@ -178,8 +178,8 @@ export class Designer {
selectionDispose = undefined;
}
const currentSelection = this.currentSelection;
// TODO: yiyi 加开关控制,避免选中 Page 组件,默认选中第一个子节点
if (currentSelection && currentSelection.selected.length === 0) {
// TODO: 避免选中 Page 组件,默认选中第一个子节点;新增规则 或 判断 Live 模式
if (currentSelection && currentSelection.selected.length === 0 && this.simulatorProps?.designMode === 'live') {
const rootNodeChildrens = this.currentDocument.getRoot().getChildren().children;
if (rootNodeChildrens.length > 0) {
currentSelection.select(rootNodeChildrens[0].id);