mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
fix(desktop): restore table tabs on startup
This commit is contained in:
@@ -48,6 +48,7 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
|
||||
const PINNED_TREE_NODES_STORAGE_KEY = "dbx-pinned-tree-nodes";
|
||||
const ACTIVE_CONNECTION_STORAGE_KEY = "dbx-active-connection";
|
||||
type ImportSource = "dbx" | "navicat" | "dbeaver";
|
||||
|
||||
interface LoadTreeOptions {
|
||||
@@ -69,13 +70,12 @@ function redisDbLabel(db: number, loadedKeyCount?: number, totalKeyCount?: numbe
|
||||
export const useConnectionStore = defineStore("connection", () => {
|
||||
const connections = ref<ConnectionConfig[]>([]);
|
||||
const isDesktop = isTauriRuntime();
|
||||
const activeConnectionId = ref<string | null>(!isDesktop ? localStorage.getItem("dbx-active-connection") : null);
|
||||
const activeConnectionId = ref<string | null>(localStorage.getItem(ACTIVE_CONNECTION_STORAGE_KEY));
|
||||
const selectedTreeNodeId = ref<string | null>(null);
|
||||
|
||||
watch(activeConnectionId, (id) => {
|
||||
if (isDesktop) return;
|
||||
if (id) localStorage.setItem("dbx-active-connection", id);
|
||||
else localStorage.removeItem("dbx-active-connection");
|
||||
if (id) localStorage.setItem(ACTIVE_CONNECTION_STORAGE_KEY, id);
|
||||
else localStorage.removeItem(ACTIVE_CONNECTION_STORAGE_KEY);
|
||||
});
|
||||
const treeNodes = ref<TreeNode[]>([]);
|
||||
const pinnedTreeNodeIds = ref<Set<string>>(new Set());
|
||||
|
||||
@@ -26,7 +26,6 @@ import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/tableDataExport";
|
||||
import * as api from "@/lib/api";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { isTauriRuntime } from "@/lib/tauriRuntime";
|
||||
import type { SavedSqlFile } from "@/types/database";
|
||||
|
||||
const STORAGE_KEY = "dbx-open-tabs";
|
||||
@@ -41,9 +40,7 @@ function saveTabs(tabs: QueryTab[], activeTabId: string | null) {
|
||||
|
||||
function loadSavedTabs(): { tabs: QueryTab[]; activeTabId: string | null } {
|
||||
try {
|
||||
return restoreOpenTabsState(localStorage.getItem(STORAGE_KEY), localStorage.getItem(ACTIVE_TAB_KEY), {
|
||||
queryOnly: isTauriRuntime(),
|
||||
});
|
||||
return restoreOpenTabsState(localStorage.getItem(STORAGE_KEY), localStorage.getItem(ACTIVE_TAB_KEY));
|
||||
} catch {
|
||||
return { tabs: [], activeTabId: null };
|
||||
}
|
||||
@@ -117,8 +114,18 @@ export const useQueryStore = defineStore("query", () => {
|
||||
schema: t.schema,
|
||||
sql: t.sql,
|
||||
savedSqlId: t.savedSqlId,
|
||||
lastExecutedSql: t.lastExecutedSql,
|
||||
resultBaseSql: t.resultBaseSql,
|
||||
resultSortedSql: t.resultSortedSql,
|
||||
resultSortColumn: t.resultSortColumn,
|
||||
resultSortColumnIndex: t.resultSortColumnIndex,
|
||||
resultSortDirection: t.resultSortDirection,
|
||||
resultPageLimit: t.resultPageLimit,
|
||||
resultPageOffset: t.resultPageOffset,
|
||||
whereInput: t.whereInput,
|
||||
pinned: t.pinned,
|
||||
mode: t.mode,
|
||||
structureTableName: t.structureTableName,
|
||||
objectBrowser: t.objectBrowser,
|
||||
objectSource: t.objectSource,
|
||||
tableMeta: t.tableMeta,
|
||||
|
||||
Reference in New Issue
Block a user