mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 23:26:00 +00:00
SYNC: fixed Cannot open up large JSON file #1215
This commit is contained in:
committed by
Diflow
parent
3571d49987
commit
0dd36260e9
@@ -29,8 +29,11 @@
|
|||||||
const elementData = getContext('json-tree-element-data');
|
const elementData = getContext('json-tree-element-data');
|
||||||
const slicedKeyCount = getContext('json-tree-sliced-key-count');
|
const slicedKeyCount = getContext('json-tree-sliced-key-count');
|
||||||
const keyLabel = labelOverride ?? key;
|
const keyLabel = labelOverride ?? key;
|
||||||
|
const PAGE_SIZE = 100;
|
||||||
|
let visibleKeyCount = PAGE_SIZE;
|
||||||
|
|
||||||
$: slicedKeys = expanded ? keys : previewKeys.slice(0, slicedKeyCount || 5);
|
// $: slicedKeys = expanded ? keys : previewKeys.slice(0, Math.max(slicedKeyCount || 5, visibleKeyCount));
|
||||||
|
$: slicedKeys = expanded ? keys?.slice(0, visibleKeyCount) : previewKeys.slice(0, slicedKeyCount || 5);
|
||||||
|
|
||||||
$: if (!isParentExpanded) {
|
$: if (!isParentExpanded) {
|
||||||
expanded = false;
|
expanded = false;
|
||||||
@@ -52,6 +55,12 @@
|
|||||||
$: if (domElement && elementData && elementValue) {
|
$: if (domElement && elementData && elementValue) {
|
||||||
elementData.set(domElement, elementValue);
|
elementData.set(domElement, elementValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showNextKeys() {
|
||||||
|
visibleKeyCount += PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$: visibleShowNextKeys = expanded && slicedKeys.length < keys.length;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class:indent={isParentExpanded} class:jsonValueHolder={!!elementValue} bind:this={domElement}>
|
<li class:indent={isParentExpanded} class:jsonValueHolder={!!elementValue} bind:this={domElement}>
|
||||||
@@ -84,13 +93,21 @@
|
|||||||
<span class="comma">,</span>
|
<span class="comma">,</span>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{#if slicedKeys.length < previewKeys.length}
|
{#if !visibleShowNextKeys && slicedKeys.length < previewKeys.length}
|
||||||
<span>…</span>
|
<span>…</span>
|
||||||
{/if}
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
{:else}
|
{:else}
|
||||||
<span>…</span>
|
<span>…</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if visibleShowNextKeys}
|
||||||
|
<span class="load-more">
|
||||||
|
<!-- svelte-ignore a11y-invalid-attribute -->
|
||||||
|
<a href="#" on:click|preventDefault={showNextKeys}>(Next 100)</a>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<span>{bracketClose}</span>
|
<span>{bracketClose}</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@@ -115,4 +132,18 @@
|
|||||||
/* display: contents; */
|
/* display: contents; */
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.load-more {
|
||||||
|
margin-left: 2em;
|
||||||
|
font-style: italic;
|
||||||
|
color: var(--theme-font-link);
|
||||||
|
}
|
||||||
|
.load-more a {
|
||||||
|
color: var(--theme-font-link);
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.load-more a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user