Skip to content

Commit 1b21944

Browse files
add HistoryActiveTabs.prototype.remove
1 parent 627b805 commit 1b21944

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/utils/api/activedTabsHistory.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
const HistoryActiveTabs = function () {
22
this.tabsId = [];
33
};
4-
HistoryActiveTabs.prototype.getTab = function () {
4+
HistoryActiveTabs.prototype.popLastTabID = function () {
55
return this.tabsId.pop();
66
};
77
HistoryActiveTabs.prototype.reset = function () {
88
this.tabsId = [];
99
};
1010
HistoryActiveTabs.prototype.add = function (id) {
11-
const tabsId = this.tabsId;
12-
tabsId[tabsId.length - 1] === id || tabsId.push(id);
11+
this.tabsId.push(id);
12+
};
13+
HistoryActiveTabs.prototype.remove = function (id) {
14+
const tabIDs = this.tabsId;
15+
while (tabIDs.indexOf(id) >= 0) {
16+
tabIDs.splice(tabIDs.indexOf(id), 1);
17+
}
18+
return this;
1319
};
1420
export default HistoryActiveTabs;

0 commit comments

Comments
 (0)