|
17 | 17 | <TabPanel value="0"> |
18 | 18 | <div class="config-section"> |
19 | 19 | <label>自动刷新间隔 ({{ configStore.autoRefreshInterval }} 分钟)</label> |
20 | | - <Slider |
21 | | - v-model="sliderValue" |
22 | | - :min="1" |
23 | | - :max="60" |
24 | | - :step="1" |
25 | | - @slideend="handleSliderEnd" |
26 | | - :disabled="isSaving" |
27 | | - /> |
| 20 | + <div class="slider-container"> |
| 21 | + <Slider |
| 22 | + v-model="sliderValue" |
| 23 | + :min="1" |
| 24 | + :max="60" |
| 25 | + :step="1" |
| 26 | + @slideend="handleSliderEnd" |
| 27 | + :disabled="isSaving" |
| 28 | + /> |
| 29 | + <!-- 刻度标记 --> |
| 30 | + <div class="slider-ticks"> |
| 31 | + <!-- 次刻度(每1分钟)--> |
| 32 | + <span |
| 33 | + v-for="tick in minorTicks" |
| 34 | + :key="'minor-' + tick" |
| 35 | + class="tick tick-minor" |
| 36 | + :style="{ left: getTickPosition(tick) }" |
| 37 | + ></span> |
| 38 | + <!-- 主刻度(每5分钟)--> |
| 39 | + <span |
| 40 | + v-for="tick in majorTicks" |
| 41 | + :key="'major-' + tick" |
| 42 | + class="tick tick-major" |
| 43 | + :style="{ left: getTickPosition(tick) }" |
| 44 | + ></span> |
| 45 | + </div> |
| 46 | + <!-- 主刻度标签 --> |
| 47 | + <div class="slider-labels"> |
| 48 | + <span |
| 49 | + v-for="tick in majorTicks" |
| 50 | + :key="'label-' + tick" |
| 51 | + class="tick-label" |
| 52 | + :style="{ left: getTickPosition(tick) }" |
| 53 | + >{{ tick }}</span> |
| 54 | + </div> |
| 55 | + </div> |
28 | 56 |
|
29 | 57 | <small class="help-text"> |
30 | 58 | 设置任务列表页面的自动刷新间隔,范围为 1-60 分钟 |
@@ -85,6 +113,22 @@ const sliderValue = computed({ |
85 | 113 | } |
86 | 114 | }) |
87 | 115 |
|
| 116 | +// 刻度配置 |
| 117 | +const MIN_VALUE = 1 |
| 118 | +const MAX_VALUE = 60 |
| 119 | +
|
| 120 | +// 主刻度:每5分钟(5, 10, 15, ..., 60) |
| 121 | +const majorTicks = Array.from({ length: 12 }, (_, i) => (i + 1) * 5) |
| 122 | +
|
| 123 | +// 次刻度:每1分钟(排除主刻度位置) |
| 124 | +const minorTicks = Array.from({ length: MAX_VALUE - MIN_VALUE + 1 }, (_, i) => i + MIN_VALUE) |
| 125 | + .filter(tick => tick % 5 !== 0) |
| 126 | +
|
| 127 | +// 计算刻度位置百分比 |
| 128 | +function getTickPosition(value: number): string { |
| 129 | + return `${((value - MIN_VALUE) / (MAX_VALUE - MIN_VALUE)) * 100}%` |
| 130 | +} |
| 131 | +
|
88 | 132 | async function handleSliderEnd() { |
89 | 133 | isSaving.value = true |
90 | 134 | try { |
@@ -127,6 +171,50 @@ async function handleSliderEnd() { |
127 | 171 | font-weight: 500; |
128 | 172 | } |
129 | 173 |
|
| 174 | +.slider-container { |
| 175 | + position: relative; |
| 176 | + padding: 0.5rem 0; |
| 177 | +} |
| 178 | +
|
| 179 | +.slider-ticks { |
| 180 | + position: relative; |
| 181 | + height: 8px; |
| 182 | + margin-top: 4px; |
| 183 | +} |
| 184 | +
|
| 185 | +.tick { |
| 186 | + position: absolute; |
| 187 | + width: 1px; |
| 188 | + transform: translateX(-50%); |
| 189 | + background-color: var(--p-surface-border); |
| 190 | +} |
| 191 | +
|
| 192 | +.tick-minor { |
| 193 | + height: 8px; |
| 194 | + width: 1px; |
| 195 | + background-color: var(--p-text-secondary-color); |
| 196 | + opacity: 0.7; |
| 197 | +} |
| 198 | +
|
| 199 | +.tick-major { |
| 200 | + height: 16px; |
| 201 | + width: 2px; |
| 202 | + background-color: var(--p-text-secondary-color); |
| 203 | +} |
| 204 | +
|
| 205 | +.slider-labels { |
| 206 | + position: relative; |
| 207 | + height: 20px; |
| 208 | + margin-top: 2px; |
| 209 | +} |
| 210 | +
|
| 211 | +.tick-label { |
| 212 | + position: absolute; |
| 213 | + transform: translateX(-50%); |
| 214 | + font-size: 0.75rem; |
| 215 | + color: var(--p-text-secondary-color); |
| 216 | +} |
| 217 | +
|
130 | 218 | .help-text { |
131 | 219 | display: block; |
132 | 220 | margin-top: 0.5rem; |
|
0 commit comments