This commit is contained in:
Pan Qiancheng 2024-12-07 16:43:14 +08:00
commit 1be6ad76c1
2 changed files with 34 additions and 26 deletions

View File

@ -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() {

View File

@ -730,8 +730,6 @@ export function destroyNode<
unset(this.state, ['oakFullpath', 'oakEntity']);
}
export function getFreshValue<
ED extends EntityDict & BaseEntityDict,
T extends keyof ED