Merge branch 'dev' of https://gitea.51mars.com/Oak-Team/oak-frontend-base into dev
This commit is contained in:
commit
1be6ad76c1
|
|
@ -250,6 +250,9 @@ class UpdateLogManager<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
|
||||
abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feature {
|
||||
private zombie: boolean = false;
|
||||
/**
|
||||
* 当前有几个组件正在使用这个结点
|
||||
*/
|
||||
private count: number = 0;
|
||||
protected executing: boolean = false;
|
||||
protected dirty?: boolean;
|
||||
|
|
@ -2164,9 +2167,12 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
| VirtualNode<ED>
|
||||
| undefined);
|
||||
|
||||
// 找到了之前的node,需要检查是否需要重用
|
||||
if (node) {
|
||||
if (node.getCount()) {
|
||||
assert(!isPage || zombie, '暂时在路由上可能回归的页面必须设置为zombie');
|
||||
if (node.getCount()) { // 有组件正在使用
|
||||
// 页面组件已经被销毁,现在重新挂载,提示需要zombie
|
||||
assert(!isPage || zombie, '暂时在路由上可能回归的页面必须设置为zombie'); // 是页面并且不是zombie
|
||||
// 这次非virtualNode
|
||||
if (entity) {
|
||||
if (node instanceof ListNode) {
|
||||
if (isList && node.getEntity() === entity) {
|
||||
|
|
@ -2191,8 +2197,8 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
}
|
||||
}
|
||||
else {
|
||||
assert(node instanceof SingleNode);
|
||||
assert(!isList && node.getEntity() === entity);
|
||||
assert(node instanceof SingleNode, `节点[${path}]应为Virtual节点,但现在是[${entity.toString()}]请检查oakPath是否重复`);
|
||||
assert(!isList && node.getEntity() === entity, `节点${path}的entity为${node.getEntity().toString()},但现在为${entity.toString()},请检查oakPath是否重复`);
|
||||
if (!node.getProjection() && projection) {
|
||||
node.setProjection(projection);
|
||||
if (id) {
|
||||
|
|
@ -2206,8 +2212,10 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
}
|
||||
}
|
||||
}
|
||||
// 上次不是virtualNode,这次变成virtual了
|
||||
else {
|
||||
assert(false, '这种情况暂时不考虑,跑出来再处理,by Xc 20240717');
|
||||
assert(false, `创建Virtual节点时发现path[${fullPath}]已经存在有效的结点,请检查oakPath是否重复`);
|
||||
// assert(false, '这种情况暂时不考虑,跑出来再处理,by Xc 20240717');
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -2325,26 +2333,28 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
|
||||
destroyNode(path: string, isPage: boolean) {
|
||||
const node = this.findNode(path);
|
||||
if (node) {
|
||||
// 如果node不存在,说明父结点已经析构掉了,无视即可
|
||||
const cnt = node.decreaseCount();
|
||||
if (cnt === 0) {
|
||||
const zombie = node.isZombie();
|
||||
if (!zombie) {
|
||||
// 不是声明为zombie结点就析构
|
||||
const childPath = path.slice(path.lastIndexOf('.') + 1);
|
||||
const parent = node.getParent();
|
||||
if (parent) {
|
||||
parent.removeChild(childPath);
|
||||
} else if (!parent) {
|
||||
assert(this.root.hasOwnProperty(path));
|
||||
unset(this.root, path);
|
||||
}
|
||||
node.destroy();
|
||||
node.clearSubscribes();
|
||||
}
|
||||
}
|
||||
// 如果node不存在,说明父结点已经析构掉了,无视即可
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const cnt = node.decreaseCount();
|
||||
if (cnt !== 0) {
|
||||
return;
|
||||
}
|
||||
if (node.isZombie()) {
|
||||
return;
|
||||
}
|
||||
// 不是声明为zombie结点就析构
|
||||
const childPath = path.slice(path.lastIndexOf('.') + 1);
|
||||
const parent = node.getParent();
|
||||
if (parent) {
|
||||
parent.removeChild(childPath);
|
||||
} else if (!parent) {
|
||||
assert(this.root.hasOwnProperty(path));
|
||||
unset(this.root, path);
|
||||
}
|
||||
node.destroy();
|
||||
node.clearSubscribes();
|
||||
}
|
||||
|
||||
begin() {
|
||||
|
|
|
|||
|
|
@ -730,8 +730,6 @@ export function destroyNode<
|
|||
unset(this.state, ['oakFullpath', 'oakEntity']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function getFreshValue<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
T extends keyof ED
|
||||
|
|
|
|||
Loading…
Reference in New Issue