mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 12:47:25 +00:00
28 lines
773 B
TypeScript
28 lines
773 B
TypeScript
import { writable } from 'svelte/store';
|
|
|
|
interface TabDefinition {
|
|
title: string;
|
|
closedTime?: number;
|
|
icon: string;
|
|
props: any;
|
|
selected: boolean;
|
|
busy: boolean;
|
|
tabid: string;
|
|
}
|
|
|
|
export function writableWithStorage<T>(defaultValue: T, storageName) {
|
|
const init = localStorage.getItem(storageName);
|
|
const res = writable<T>(init ? JSON.parse(init) : defaultValue);
|
|
res.subscribe(value => {
|
|
localStorage.setItem(storageName, JSON.stringify(value));
|
|
});
|
|
return res;
|
|
}
|
|
|
|
export const selectedWidget = writable('database');
|
|
export const openedConnections = writable([]);
|
|
export const currentDatabase = writable(null);
|
|
export const openedTabs = writableWithStorage<TabDefinition[]>([], 'openedTabs');
|
|
|
|
// export const leftPanelWidth = writable(300);
|