mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
numbering tabs
This commit is contained in:
parent
cb67b57faf
commit
8396e726ec
@ -7,6 +7,14 @@ import { useOpenedTabs, useSetOpenedTabs } from './globalState';
|
||||
import tabs from '../tabs';
|
||||
import { setSelectedTabFunc } from './common';
|
||||
|
||||
function findFreeNumber(numbers) {
|
||||
if (numbers.length == 0) return 1;
|
||||
return _.max(numbers) + 1;
|
||||
// let res = 1;
|
||||
// while (numbers.includes(res)) res += 1;
|
||||
// return res;
|
||||
}
|
||||
|
||||
export default function useOpenNewTab() {
|
||||
const setOpenedTabs = useSetOpenedTabs();
|
||||
const openedTabs = useOpenedTabs();
|
||||
@ -48,7 +56,7 @@ export default function useOpenNewTab() {
|
||||
.filter(x => x.closedTime == null && x.title && x.title.startsWith(newTab.title))
|
||||
.map(x => parseInt(x.title.substring(newTab.title.length)));
|
||||
|
||||
newTab.title = `${newTab.title}${numbers.length > 0 ? _.max(numbers) + 1 : 1}`;
|
||||
newTab.title = `${newTab.title}${findFreeNumber(numbers)}`;
|
||||
}
|
||||
|
||||
const tabid = uuidv1();
|
||||
|
Loading…
Reference in New Issue
Block a user