mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 21:20:28 +00:00
fix: 区块组件无法删除
fix: 修改 currentPage 逻辑
This commit is contained in:
parent
775725d3f7
commit
d936d2bdde
@ -208,13 +208,13 @@ export class ComponentMeta {
|
||||
return result as any;
|
||||
}
|
||||
|
||||
isRootComponent() {
|
||||
return this.componentName === 'Page' || this.componentName === 'Block' || this.componentName === 'Component';
|
||||
isRootComponent(includeBlock: boolean = true) {
|
||||
return this.componentName === 'Page' || this.componentName === 'Component' || (includeBlock && this.componentName === 'Block');
|
||||
}
|
||||
|
||||
@computed get availableActions() {
|
||||
let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {};
|
||||
const disabled = ensureAList(disableBehaviors) || (this.isRootComponent() ? ['copy', 'remove'] : null);
|
||||
const disabled = ensureAList(disableBehaviors) || (this.isRootComponent(false) ? ['copy', 'remove'] : null);
|
||||
actions = builtinComponentActions.concat(this.designer.getGlobalComponentActions() || [], actions || []);
|
||||
|
||||
if (disabled) {
|
||||
|
||||
@ -105,8 +105,6 @@ export class DocumentModel {
|
||||
|
||||
if (!schema) {
|
||||
this._blank = true;
|
||||
} else {
|
||||
this.id = project.getSchema()?.id || this.id;
|
||||
}
|
||||
|
||||
this.rootNode = this.createNode<RootNode>(
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { designer } from './editor';
|
||||
import { RootSchema } from '@ali/lowcode-types';
|
||||
import { DocumentModel } from '@ali/lowcode-designer';
|
||||
import { designer } from './editor';
|
||||
import NodeCacheVisitor from './rootNodeVisitor';
|
||||
import { getFormUuid } from './util';
|
||||
|
||||
const { project } = designer;
|
||||
|
||||
@ -51,8 +52,7 @@ const pages = Object.assign(project, {
|
||||
project.load({
|
||||
version: '1.0.0',
|
||||
componentsMap: [],
|
||||
componentsTree,
|
||||
id: pages[0].id,
|
||||
componentsTree
|
||||
}, true);
|
||||
|
||||
// FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified
|
||||
@ -86,7 +86,12 @@ const pages = Object.assign(project, {
|
||||
page.active();
|
||||
},
|
||||
getCurrentPage() {
|
||||
return project.currentDocument;
|
||||
if (!project.currentDocument) {
|
||||
return null;
|
||||
}
|
||||
const currentPage = { ...project.currentDocument, id: getFormUuid() };
|
||||
Object.setPrototypeOf(currentPage, Object.getPrototypeOf(project.currentDocument || {}));
|
||||
return currentPage;
|
||||
},
|
||||
onPagesChange() {
|
||||
// noop
|
||||
@ -101,7 +106,7 @@ const pages = Object.assign(project, {
|
||||
|
||||
Object.defineProperty(pages, 'currentPage', {
|
||||
get() {
|
||||
return project.currentDocument;
|
||||
return pages.getCurrentPage();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
18
packages/editor-preset-vision/src/util/index.ts
Normal file
18
packages/editor-preset-vision/src/util/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
function getUrlParameter(sParam: string) {
|
||||
var sPageURL = window.location.search.substring(1),
|
||||
sURLVariables = sPageURL.split('&'),
|
||||
sParameterName,
|
||||
i;
|
||||
|
||||
for (i = 0; i < sURLVariables.length; i++) {
|
||||
sParameterName = sURLVariables[i].split('=');
|
||||
|
||||
if (sParameterName[0] === sParam) {
|
||||
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export function getFormUuid() {
|
||||
return getUrlParameter('formUuid');
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user