@@ -18,6 +18,7 @@ import {
1818 getTabByRoute ,
1919 getTabIdByRoute ,
2020 isTabInTabs ,
21+ reorderFixedTabs ,
2122 updateTabByI18nKey ,
2223 updateTabsByI18nKey
2324} from './shared' ;
@@ -248,6 +249,48 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
248249 await clearTabs ( excludes ) ;
249250 }
250251
252+ /**
253+ * Fix tab
254+ *
255+ * @param tabId
256+ */
257+ function fixTab ( tabId : string ) {
258+ const tabIndex = tabs . value . findIndex ( t => t . id === tabId ) ;
259+ if ( tabIndex === - 1 ) return ;
260+
261+ const tab = tabs . value [ tabIndex ] ;
262+ const fixedCount = getFixedTabIds ( tabs . value ) . length ;
263+ tab . fixedIndex = fixedCount ;
264+
265+ if ( tabIndex !== fixedCount ) {
266+ tabs . value . splice ( tabIndex , 1 ) ;
267+ tabs . value . splice ( fixedCount , 0 , tab ) ;
268+ }
269+
270+ reorderFixedTabs ( tabs . value ) ;
271+ }
272+
273+ /**
274+ * Unfix tab
275+ *
276+ * @param tabId
277+ */
278+ function unfixTab ( tabId : string ) {
279+ const tabIndex = tabs . value . findIndex ( t => t . id === tabId ) ;
280+ if ( tabIndex === - 1 ) return ;
281+
282+ const tab = tabs . value [ tabIndex ] ;
283+ tab . fixedIndex = undefined ;
284+
285+ const fixedCount = getFixedTabIds ( tabs . value ) . length ;
286+ if ( tabIndex !== fixedCount ) {
287+ tabs . value . splice ( tabIndex , 1 ) ;
288+ tabs . value . splice ( fixedCount , 0 , tab ) ;
289+ }
290+
291+ reorderFixedTabs ( tabs . value ) ;
292+ }
293+
251294 /**
252295 * Set new label of tab
253296 *
@@ -328,6 +371,8 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
328371 clearTabs,
329372 clearLeftTabs,
330373 clearRightTabs,
374+ fixTab,
375+ unfixTab,
331376 switchRouteByTab,
332377 setTabLabel,
333378 resetTabLabel,
0 commit comments