You've already forked iFlow-Settings-Editor-GUI
修复 亚克力效果滑块进度条初始值不正确的bug
This commit is contained in:
@@ -51,18 +51,20 @@
|
|||||||
<div class="form-row" v-if="supportsAcrylic">
|
<div class="form-row" v-if="supportsAcrylic">
|
||||||
<div class="form-group form-group-full">
|
<div class="form-group form-group-full">
|
||||||
<label class="form-label">{{ $t('general.acrylicEffect') }}: {{ localSettings.acrylicIntensity }}%</label>
|
<label class="form-label">{{ $t('general.acrylicEffect') }}: {{ localSettings.acrylicIntensity }}%</label>
|
||||||
<div class="slider-container">
|
<div class="slider-wrapper" ref="sliderWrapper">
|
||||||
|
<div class="slider-track">
|
||||||
|
<div class="slider-fill" :style="{ width: localSettings.acrylicIntensity + '%' }"></div>
|
||||||
|
</div>
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
class="form-slider"
|
class="form-slider"
|
||||||
min="0"
|
min="0"
|
||||||
max="100"
|
max="100"
|
||||||
:value="localSettings.acrylicIntensity"
|
:value="localSettings.acrylicIntensity"
|
||||||
@input="updateSliderStyle"
|
@input="updateSliderValue"
|
||||||
ref="sliderRef"
|
|
||||||
/>
|
/>
|
||||||
<span class="slider-hint">{{ $t('general.acrylicMin') }} — {{ $t('general.acrylicMax') }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
<span class="slider-hint">{{ $t('general.acrylicMin') }} — {{ $t('general.acrylicMax') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -92,33 +94,12 @@ const supportsAcrylic = computed(() => {
|
|||||||
return typeof document !== 'undefined' && 'backdropFilter' in document.documentElement.style && props.settings.uiTheme !== 'Dark'
|
return typeof document !== 'undefined' && 'backdropFilter' in document.documentElement.style && props.settings.uiTheme !== 'Dark'
|
||||||
})
|
})
|
||||||
|
|
||||||
const sliderRef = ref(null)
|
const sliderWrapper = ref(null)
|
||||||
|
|
||||||
const updateSliderStyle = e => {
|
const updateSliderValue = e => {
|
||||||
const value = e.target.value
|
const value = Number(e.target.value)
|
||||||
const percent = ((value - 0) / (100 - 0)) * 100
|
emit('update:settings', { ...props.settings, acrylicIntensity: value })
|
||||||
e.target.style.backgroundSize = `${percent}% 100%`
|
|
||||||
emit('update:settings', { ...props.settings, acrylicIntensity: Number(value) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (sliderRef.value) {
|
|
||||||
const percent = ((props.settings.acrylicIntensity - 0) / (100 - 0)) * 100
|
|
||||||
sliderRef.value.style.backgroundSize = `${percent}% 100%`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.settings.uiTheme,
|
|
||||||
() => {
|
|
||||||
nextTick(() => {
|
|
||||||
if (sliderRef.value && supportsAcrylic.value) {
|
|
||||||
const percent = ((props.settings.acrylicIntensity - 0) / (100 - 0)) * 100
|
|
||||||
sliderRef.value.style.backgroundSize = `${percent}% 100%`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@@ -126,24 +107,40 @@ watch(
|
|||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-container {
|
.slider-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: center;
|
||||||
gap: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-slider {
|
.slider-track {
|
||||||
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 4px;
|
height: 4px;
|
||||||
background: var(--border);
|
background: var(--border);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: var(--accent);
|
||||||
|
border-radius: 2px;
|
||||||
|
transition: width 0.05s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-slider {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 4px;
|
||||||
|
background: transparent;
|
||||||
outline: none;
|
outline: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
background-image: linear-gradient(var(--accent), var(--accent));
|
z-index: 1;
|
||||||
background-size: var(--slider-progress, 50%) 100%;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-slider::-webkit-slider-thumb {
|
.form-slider::-webkit-slider-thumb {
|
||||||
@@ -181,5 +178,6 @@ watch(
|
|||||||
font-size: var(--font-size-xs);
|
font-size: var(--font-size-xs);
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user