mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 03:53:57 +00:00
rememeber datagrid manager width
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
import { getBoolSettingsValue } from '../settings/settingsTools';
|
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||||
import { getLocalStorage } from '../utility/storageCache';
|
import { getLocalStorage, getLocalStorage, getLocalStorage, setLocalStorage } from '../utility/storageCache';
|
||||||
|
|
||||||
export let config;
|
export let config;
|
||||||
export let setConfig;
|
export let setConfig;
|
||||||
@@ -144,9 +144,23 @@
|
|||||||
{ command: 'dataGrid.switchToJson', tag: 'switch', hideDisabled: true },
|
{ command: 'dataGrid.switchToJson', tag: 'switch', hideDisabled: true },
|
||||||
{ command: 'dataGrid.toggleLeftPanel', tag: 'switch' }
|
{ command: 'dataGrid.toggleLeftPanel', tag: 'switch' }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$: if (managerSize) setLocalStorage('dataGridManagerWidth', managerSize);
|
||||||
|
|
||||||
|
function getInitialManagerSize() {
|
||||||
|
const width = getLocalStorage('dataGridManagerWidth');
|
||||||
|
if (_.isNumber(width) && width > 30 && width < 500) {
|
||||||
|
return `${width}px`;
|
||||||
|
}
|
||||||
|
return '300px';
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<HorizontalSplitter initialValue="300px" bind:size={managerSize} hideFirst={$collapsedLeftColumnStore}>
|
<HorizontalSplitter
|
||||||
|
initialValue={getInitialManagerSize()}
|
||||||
|
bind:size={managerSize}
|
||||||
|
hideFirst={$collapsedLeftColumnStore}
|
||||||
|
>
|
||||||
<div class="left" slot="1">
|
<div class="left" slot="1">
|
||||||
<WidgetColumnBar>
|
<WidgetColumnBar>
|
||||||
<WidgetColumnBarItem
|
<WidgetColumnBarItem
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ export function getLocalStorage(key, defaultValue = undefined) {
|
|||||||
if (key in cache) return cache[key];
|
if (key in cache) return cache[key];
|
||||||
const item = localStorage.getItem(key);
|
const item = localStorage.getItem(key);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
try {
|
||||||
const res = JSON.parse(item);
|
const res = JSON.parse(item);
|
||||||
cache[key] = res;
|
cache[key] = res;
|
||||||
return res;
|
return res;
|
||||||
|
} catch (e) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user