mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
open tabs on startup fix
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { openFavorite } from '../appobj/FavoriteFileAppObject.svelte';
|
||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import { openedTabs } from '../stores';
|
||||
|
||||
import { useFavorites } from './metadataLoaders';
|
||||
@@ -20,10 +22,28 @@
|
||||
|
||||
opened = true;
|
||||
|
||||
if ($openedTabs.find(x => !x.closedTime)) return;
|
||||
const { hash } = document.location;
|
||||
const openFavoriteName = hash && hash.startsWith('#favorite=') ? hash.substring('#favorite='.length) : null;
|
||||
const openTabdata = hash && hash.startsWith('#tabdata=') ? hash.substring('#tabdata='.length) : null;
|
||||
|
||||
for (const favorite of list.filter(x => x.openOnStartup)) {
|
||||
openFavorite(favorite);
|
||||
if (openFavoriteName) {
|
||||
const open = list.find(x => x.urlPath == openFavoriteName);
|
||||
if (open) {
|
||||
openFavorite(open);
|
||||
window.history.replaceState(null, null, ' ');
|
||||
}
|
||||
} else if (openTabdata) {
|
||||
try {
|
||||
const json = JSON.parse(decodeURIComponent(openTabdata));
|
||||
openFavorite(json);
|
||||
window.history.replaceState(null, null, ' ');
|
||||
} catch (err) {
|
||||
showModal(ErrorMessageModal, { message: err.message });
|
||||
}
|
||||
} else if (!$openedTabs.find(x => x.closedTime == null)) {
|
||||
for (const favorite of list.filter(x => x.openOnStartup)) {
|
||||
openFavorite(favorite);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user