mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 02:16:02 +00:00
save perspective to file
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { createPerspectiveConfig } from 'dbgate-datalib';
|
||||
import { writable } from 'svelte/store';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
function doLoadPerspectiveConfigFunc(tabid) {
|
||||
try {
|
||||
const existing = localStorage.getItem(`tabdata_perspective_${tabid}`);
|
||||
if (existing) {
|
||||
return {
|
||||
...createPerspectiveConfig(),
|
||||
...JSON.parse(existing),
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Error loading perspective config:', err.message);
|
||||
}
|
||||
return createPerspectiveConfig();
|
||||
}
|
||||
|
||||
export default function usePerspectiveConfig(tabid) {
|
||||
const config = writable(doLoadPerspectiveConfigFunc(tabid));
|
||||
const unsubscribe = config.subscribe(value =>
|
||||
localStorage.setItem(`tabdata_perspective_${tabid}`, JSON.stringify(value))
|
||||
);
|
||||
onDestroy(unsubscribe);
|
||||
return config;
|
||||
}
|
||||
Reference in New Issue
Block a user