mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-03 07:47:18 +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;
|
return result as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
isRootComponent() {
|
isRootComponent(includeBlock: boolean = true) {
|
||||||
return this.componentName === 'Page' || this.componentName === 'Block' || this.componentName === 'Component';
|
return this.componentName === 'Page' || this.componentName === 'Component' || (includeBlock && this.componentName === 'Block');
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get availableActions() {
|
@computed get availableActions() {
|
||||||
let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {};
|
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 || []);
|
actions = builtinComponentActions.concat(this.designer.getGlobalComponentActions() || [], actions || []);
|
||||||
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
|||||||
@ -105,8 +105,6 @@ export class DocumentModel {
|
|||||||
|
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
this._blank = true;
|
this._blank = true;
|
||||||
} else {
|
|
||||||
this.id = project.getSchema()?.id || this.id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rootNode = this.createNode<RootNode>(
|
this.rootNode = this.createNode<RootNode>(
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { designer } from './editor';
|
|
||||||
import { RootSchema } from '@ali/lowcode-types';
|
import { RootSchema } from '@ali/lowcode-types';
|
||||||
import { DocumentModel } from '@ali/lowcode-designer';
|
import { DocumentModel } from '@ali/lowcode-designer';
|
||||||
|
import { designer } from './editor';
|
||||||
import NodeCacheVisitor from './rootNodeVisitor';
|
import NodeCacheVisitor from './rootNodeVisitor';
|
||||||
|
import { getFormUuid } from './util';
|
||||||
|
|
||||||
const { project } = designer;
|
const { project } = designer;
|
||||||
|
|
||||||
@ -51,8 +52,7 @@ const pages = Object.assign(project, {
|
|||||||
project.load({
|
project.load({
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
componentsMap: [],
|
componentsMap: [],
|
||||||
componentsTree,
|
componentsTree
|
||||||
id: pages[0].id,
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified
|
// FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified
|
||||||
@ -86,7 +86,12 @@ const pages = Object.assign(project, {
|
|||||||
page.active();
|
page.active();
|
||||||
},
|
},
|
||||||
getCurrentPage() {
|
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() {
|
onPagesChange() {
|
||||||
// noop
|
// noop
|
||||||
@ -101,7 +106,7 @@ const pages = Object.assign(project, {
|
|||||||
|
|
||||||
Object.defineProperty(pages, 'currentPage', {
|
Object.defineProperty(pages, 'currentPage', {
|
||||||
get() {
|
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