From 9bccddc9d7af650ca0bd26a48ed64f72d63fc6d7 Mon Sep 17 00:00:00 2001 From: Dailer Date: Tue, 8 Mar 2022 21:15:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A0JRIA=20tab=E5=9C=A8single:true?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E6=94=AF=E6=8C=81keepAlive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/tab.js | 11 +++++++++-- typescript/base/combination/tab.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 664b0c09a..06a9a06fd 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -15,7 +15,8 @@ BI.Tab = BI.inherit(BI.Widget, { tab: false, cardCreator: function (v) { return BI.createWidget(); - } + }, + keepAlives: [] }); }, @@ -60,7 +61,7 @@ BI.Tab = BI.inherit(BI.Widget, { var self = this, o = this.options; if (o.single === true) { BI.each(this.cardMap, function (name, card) { - if (name !== (currCardName + "")) { + if (name !== (currCardName + "") && self._keepAlive(name) !== true) { self.layout.deleteCardByName(name); delete self.cardMap[name]; } @@ -76,6 +77,12 @@ BI.Tab = BI.inherit(BI.Widget, { } }, + _keepAlive: function (v) { + var o = this.options; + var keepAlives = BI.isFunction(o.keepAlives) ? o.keepAlives() : o.keepAlives; + return BI.contains(keepAlives, v); + }, + created: function () { var o = this.options; if (o.showIndex !== false) { diff --git a/typescript/base/combination/tab.ts b/typescript/base/combination/tab.ts index 611c3e9c0..fa4cc8b25 100644 --- a/typescript/base/combination/tab.ts +++ b/typescript/base/combination/tab.ts @@ -15,6 +15,7 @@ export declare class Tab extends Widget { dynamic: boolean; }; tab?: Obj; + keepAlives?: string[] | ((cardName: string) => boolean) } setSelect(v: string | number, action?: Action, callback?: Function): void; From 8b0aff255c9c0fb546f7bf511fd5df931359ad92 Mon Sep 17 00:00:00 2001 From: Dailer Date: Tue, 8 Mar 2022 22:15:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0JRIA=20tab=E5=9C=A8single:true?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E6=94=AF=E6=8C=81keepAlive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/router.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/router/router.js b/src/router/router.js index 93a661d84..4ee289f88 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -3179,7 +3179,8 @@ ref: function (_ref) { self.tab = _ref; }, - single: false, // 是不是单页面 + single: o.single, // 是不是单页面 + keepAlives: o.keepAlives, logic: { dynamic: false }, From bc81cb3714ec77681bb49fdef53fd9ad83724006 Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 9 Mar 2022 09:19:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JRIA=20tab=E5=9C=A8single:true?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E6=94=AF=E6=8C=81keepAlive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/tab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 33321322d..30259e71a 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -85,8 +85,8 @@ BI.Tab = BI.inherit(BI.Widget, { _keepAlive: function (v) { var o = this.options; - var keepAlives = BI.isFunction(o.keepAlives) ? o.keepAlives() : o.keepAlives; - return BI.contains(keepAlives, v); + return BI.isFunction(o.keepAlives) ? o.keepAlives(v) : BI.contains(o.keepAlives, v); + }, created: function () {