Skip to content

Commit 56d696d

Browse files
committed
更新 ExpressionEditor.vue 组件,修改 el-scrollbar 属性为 always;更新 layout.scss 文件,调整 flex 布局,固定高度并优化搜索框和变量列表的样式。
1 parent b92b0d7 commit 56d696d

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

src/components/ExpressionEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<el-input v-model="variableSearchText" placeholder="搜索变量" clearable :prefix-icon="Search" />
9797
</div>
9898
<div class="variables" ref="variablesRef">
99-
<el-scrollbar>
99+
<el-scrollbar always>
100100
<button v-for="variable in filteredVariables" :key="variable.code" @click="addVariable(variable)"
101101
:title="variable.name">
102102
{{ variable.name }}

src/components/styles/layout.scss

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
padding-right: v.$spacing-xl; // 增加右侧内边距
3030
border-right: 1px solid var(--el-border-color-light); // 添加分隔线
3131
flex: 1;
32+
display: flex;
33+
flex-direction: column;
3234

3335
.variables {
3436
:deep(.el-scrollbar) {
@@ -50,7 +52,7 @@
5052
display: flex;
5153
flex-direction: column;
5254
gap: v.$spacing-xs;
53-
max-height: 320px;
55+
height: 320px; // 固定高度
5456
margin: 0 auto;
5557
overflow: hidden;
5658
transition: all 0.3s ease;
@@ -66,7 +68,9 @@
6668
}
6769

6870
.variables-search {
71+
flex-shrink: 0; // 防止搜索框被压缩
6972
padding: 0 12px;
73+
margin-bottom: v.$spacing-xs;
7074

7175
:deep(.el-input) {
7276
.el-input__wrapper {
@@ -79,20 +83,50 @@
7983

8084
.variables {
8185
flex: 1;
86+
min-height: 0; // 允许元素在flex布局中收缩
87+
position: relative;
8288
overflow: hidden;
89+
max-height: calc(100% - 50px); // 减去搜索框的高度和间距
8390
padding-right: v.$spacing-md; // 减小右侧padding,因为scrollbar已经占据了一定空间
91+
display: flex; // 添加 flex 布局
92+
flex-direction: column; // 垂直方向布局
8493

8594
:deep(.el-scrollbar) {
86-
height: 100%;
87-
max-height: 400px;
95+
height: 100%; // 确保高度占满容器
96+
min-height: 0; // 允许内容区域收缩
97+
98+
.el-scrollbar__wrap {
99+
overflow-x: hidden;
100+
}
88101

89-
@media (max-width: 768px) {
90-
max-height: 300px;
102+
.el-scrollbar__view {
103+
padding: v.$spacing-md;
104+
display: flex;
105+
flex-direction: column;
106+
gap: v.$spacing-xs;
91107
}
92108
}
93109

94-
:deep(.el-scrollbar__wrap) {
95-
padding: v.$spacing-md v.$spacing-md v.$spacing-md v.$spacing-md; // 增加滚动区域的内边距
110+
button {
111+
flex-shrink: 0;
112+
width: 100%;
113+
text-align: left;
114+
padding: 8px 12px;
115+
border: 1px solid var(--el-border-color-lighter);
116+
border-radius: 4px;
117+
background: var(--el-bg-color);
118+
color: var(--el-text-color-regular);
119+
transition: all 0.3s;
120+
cursor: pointer;
121+
white-space: nowrap;
122+
overflow: hidden;
123+
text-overflow: ellipsis;
124+
125+
&:hover {
126+
border-color: var(--el-color-primary);
127+
color: var(--el-color-primary);
128+
background: var(--el-color-primary-light-9);
129+
}
96130
}
97131
}
98132

0 commit comments

Comments
 (0)