ComponentOption中增加了stale配置项

This commit is contained in:
Xu Chang 2024-12-10 19:01:59 +08:00
parent 41254e9304
commit 57ebc434ba
9 changed files with 33 additions and 12 deletions

View File

@ -482,7 +482,7 @@ const oakBehavior = Behavior({
this.oakOption.lifetimes?.ready && this.oakOption.lifetimes?.ready &&
this.oakOption.lifetimes?.ready.call(this); this.oakOption.lifetimes?.ready.call(this);
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && if (oakFullpath && !this.oakOption.stale &&
!this.features.runningTree.checkIsModiNode(oakFullpath) && !this.features.runningTree.checkIsModiNode(oakFullpath) &&
!this.features.runningTree.isListDescandent(oakFullpath)) { !this.features.runningTree.isListDescandent(oakFullpath)) {
this.refresh(); this.refresh();
@ -787,7 +787,9 @@ export function createComponent(option, features) {
return; return;
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
try { try {
await this.refresh(); await this.refresh();
} }

View File

@ -643,7 +643,9 @@ export function createComponent(option, features) {
} }
try { try {
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
await this.refresh(); await this.refresh();
} }
else { else {
@ -701,7 +703,9 @@ export function createComponent(option, features) {
lifetimes?.show && lifetimes.show.call(this); lifetimes?.show && lifetimes.show.call(this);
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
this.refresh(); this.refresh();
} }
else { else {

1
es/types/Page.d.ts vendored
View File

@ -41,6 +41,7 @@ interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEn
* *
*/ */
isList?: IsList; isList?: IsList;
stale?: boolean;
zombie?: true; zombie?: true;
getTotal?: { getTotal?: {
max: number; max: number;

View File

@ -485,7 +485,7 @@ const oakBehavior = Behavior({
this.oakOption.lifetimes?.ready && this.oakOption.lifetimes?.ready &&
this.oakOption.lifetimes?.ready.call(this); this.oakOption.lifetimes?.ready.call(this);
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && if (oakFullpath && !this.oakOption.stale &&
!this.features.runningTree.checkIsModiNode(oakFullpath) && !this.features.runningTree.checkIsModiNode(oakFullpath) &&
!this.features.runningTree.isListDescandent(oakFullpath)) { !this.features.runningTree.isListDescandent(oakFullpath)) {
this.refresh(); this.refresh();
@ -790,7 +790,9 @@ function createComponent(option, features) {
return; return;
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
try { try {
await this.refresh(); await this.refresh();
} }

View File

@ -648,7 +648,9 @@ function createComponent(option, features) {
} }
try { try {
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
await this.refresh(); await this.refresh();
} }
else { else {
@ -706,7 +708,9 @@ function createComponent(option, features) {
lifetimes?.show && lifetimes.show.call(this); lifetimes?.show && lifetimes.show.call(this);
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
this.refresh(); this.refresh();
} }
else { else {

1
lib/types/Page.d.ts vendored
View File

@ -41,6 +41,7 @@ interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEn
* *
*/ */
isList?: IsList; isList?: IsList;
stale?: boolean;
zombie?: true; zombie?: true;
getTotal?: { getTotal?: {
max: number; max: number;

View File

@ -704,7 +704,7 @@ const oakBehavior = Behavior<
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if ( if (
oakFullpath && oakFullpath && !this.oakOption.stale &&
!this.features.runningTree.checkIsModiNode( !this.features.runningTree.checkIsModiNode(
oakFullpath oakFullpath
) && ) &&
@ -1115,7 +1115,9 @@ export function createComponent<
return; return;
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
try { try {
await this.refresh(); await this.refresh();
} }

View File

@ -974,7 +974,9 @@ export function createComponent<
try { try {
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
await this.refresh(); await this.refresh();
} }
else { else {
@ -1042,7 +1044,9 @@ export function createComponent<
lifetimes?.show && lifetimes.show.call(this); lifetimes?.show && lifetimes.show.call(this);
} }
const { oakFullpath } = this.state; const { oakFullpath } = this.state;
if (oakFullpath && !features.runningTree.checkIsModiNode(oakFullpath) && !features.runningTree.isListDescandent(oakFullpath)) { if (oakFullpath && !option.stale &&
!features.runningTree.checkIsModiNode(oakFullpath) &&
!features.runningTree.isListDescandent(oakFullpath)) {
this.refresh(); this.refresh();
} }
else { else {

View File

@ -141,6 +141,7 @@ interface ComponentOption<
* *
*/ */
isList?: IsList; isList?: IsList;
stale?: boolean;
zombie?: true; zombie?: true;
getTotal?: { getTotal?: {
max: number; max: number;