Skip to content

Commit

Permalink
refactor: snapshot xScrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 8, 2024
1 parent 1d568d8 commit 894051d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import ErrorDlg from './components/ErrorDlg.vue';
--gkd-width: max(1200px, 100vw);
--gkd-height: max(700px, 100vh);
}
#app {
min-width: 1200px;
min-height: 700px;
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
width: var(--gkd-width);
height: var(--gkd-height);
&.mobile {
--gkd-width: 100vw;
min-width: auto;
}
}
.gkd_code,
Expand Down
6 changes: 6 additions & 0 deletions src/utils/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const getLabelSuffix = (node: RawNode) => {
return node.attr.text || node.attr.desc || node.attr.vid || node.attr.id;
};
const labelKey = Symbol(`labelKey`);
const labelLimit = 20;
export const getNodeLabel = (node: RawNode): string => {
if (Reflect.has(node, labelKey)) {
return Reflect.get(node, labelKey);
Expand All @@ -157,6 +158,11 @@ export const getNodeLabel = (node: RawNode): string => {
}
const text = getLabelSuffix(node);
if (text) {
// if (text.length > labelLimit) {
// label = `${label} : ${text.slice(0, labelLimit)}...`;
// } else {
// label = `${label} : ${text}`;
// }
label = `${label} : ${text}`;
}
Reflect.set(node, labelKey, label);
Expand Down
2 changes: 1 addition & 1 deletion src/views/snapshot/ScreenshotCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const imgBounding = useElementBounding(imgRef);
top: imgBounding.top.value + 'px',
}"
pointer-events-none
absolute
fixed
overflow-hidden
z-2
bg-white
Expand Down
29 changes: 17 additions & 12 deletions src/views/snapshot/WindowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const treeNodeProps = (info: {
color: info.option.id == focusNode.value?.id ? `#00F` : undefined,
fontWeight: qf ? `bold` : undefined,
},
class: 'whitespace-nowrap overflow-hidden text-ellipsis',
};
};
Expand Down Expand Up @@ -106,7 +107,7 @@ const onDelete = async () => {
</script>

<template>
<div flex flex-col>
<div flex flex-col overflow-hidden>
<div flex items-center px-8px>
<GapList flex flex-wrap items-center gap-8px gkd_code>
<template #gap>
Expand Down Expand Up @@ -212,16 +213,20 @@ const onDelete = async () => {
/>
</div>
<div h-1px mt-4px bg="#efeff5"></div>
<NTree
ref="treeRef"
virtualScroll
showLine
keyField="id"
v-model:expandedKeys="expandedKeys"
:data="[rootNode as any]"
:filter="(treeFilter as any)"
:nodeProps="(treeNodeProps as any)"
:renderLabel="(renderLabel as any)"
/>

<NScrollbar xScrollable>
<NTree
class="mb-24px mr-24px"
ref="treeRef"
virtualScroll
showLine
keyField="id"
v-model:expandedKeys="expandedKeys"
:data="[rootNode as any]"
:filter="(treeFilter as any)"
:nodeProps="(treeNodeProps as any)"
:renderLabel="(renderLabel as any)"
/>
</NScrollbar>
</div>
</template>

0 comments on commit 894051d

Please sign in to comment.