feat(P4): precompute移植+app.js sources双向回填+回归1003/1003+验收体积/文件/data.json
Deploy to GitHub Pages / deploy (push) Failing after 16s
Regression / regression (push) Failing after 15m2s

This commit is contained in:
aurora-admin
2026-09-12 14:18:41 +08:00
parent 16f365a045
commit c65a69c34e
401 changed files with 22932 additions and 140 deletions
+176
View File
@@ -0,0 +1,176 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aurora Admin · Slider (H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css">
<link rel="stylesheet" href="./Slider.css">
<style>
.demo { padding: 24px; background: var(--au-color-page-bg); font-family: var(--font-family); }
h1 { font-size: 20px; margin: 0 0 4px; color: var(--au-color-text-title); }
.sub { color: var(--au-color-text-secondary); margin: 0 0 24px; font-size: 12px; }
.demo-block { background: var(--au-color-card-bg); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; }
.demo-block > .hint { color: var(--au-color-text-secondary); font-size: 12px; margin: 0 0 12px; }
.slider-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.slider-row .lab { width: 72px; font-size: 13px; color: var(--au-color-text-body); }
</style>
</head>
<body>
<div class="demo">
<h1>Aurora Admin · Slider 组件(纯 H5)</h1>
<p class="sub">对齐 SliderInput 规范:单/双滑块、刻度、输入框联动</p>
<div class="demo-block">
<p class="hint">单滑块 + 数值联动</p>
<div class="slider-row">
<span class="lab">音量</span>
<div class="aa-slider" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-slider data-min="0" data-max="100" data-value="30" data-input></div>
</div>
</div>
<div class="demo-block">
<p class="hint">带刻度</p>
<div class="aa-slider" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-slider data-min="0" data-max="100" data-step="10" data-value="50" data-ticks></div>
</div>
<div class="demo-block">
<p class="hint">双滑块范围</p>
<div class="aa-slider" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-slider data-range data-min="0" data-max="100" data-value="20,60"></div>
</div>
<div class="demo-block">
<p class="hint">禁用</p>
<div class="aa-slider is-disabled" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-slider data-min="0" data-max="100" data-value="40"></div>
</div>
</div>
<script>
function initSlider(root) {
const min = +root.dataset.min || 0, max = +root.dataset.max || 100, step = +root.dataset.step || 1;
const range = root.hasAttribute('data-range');
const showTicks = root.hasAttribute('data-ticks');
const showInput = root.hasAttribute('data-input');
let value = range
? root.dataset.value.split(',').map(Number)
: (+root.dataset.value || 0);
const track = document.createElement('div');
track.className = 'aa-slider-track';
track.innerHTML = '<div class="aa-slider-rail" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100"></div><div class="aa-slider-fill" aria-valuemin="0" aria-valuemax="100"></div><div class="aa-slider-ticks" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100"></div>';
if (range) {
track.insertAdjacentHTML('beforeend', '<div class="aa-slider-handle" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-i="0"></div><div class="aa-slider-handle" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-i="1"></div>');
} else {
track.insertAdjacentHTML('beforeend', '<div class="aa-slider-handle" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" data-i="0"></div>');
}
root.appendChild(track);
const valueWrap = document.createElement('div');
valueWrap.className = 'aa-slider-value';
if (showInput) {
if (range) {
valueWrap.innerHTML = '<input type="number"><span>—</span><input type="number">';
} else {
valueWrap.innerHTML = '<input type="number">';
}
root.appendChild(valueWrap);
valueWrap.querySelectorAll('input').forEach(inp => {
inp.addEventListener('change', () => {
if (range) {
const a = +valueWrap.querySelectorAll('input')[0].value;
const b = +valueWrap.querySelectorAll('input')[1].value;
value = [Math.min(a, b), Math.max(a, b)];
} else {
value = +inp.value;
}
paint();
});
});
}
const rail = track.querySelector('.aa-slider-rail');
const fill = track.querySelector('.aa-slider-fill');
const ticks = track.querySelector('.aa-slider-ticks');
const handles = [...track.querySelectorAll('.aa-slider-handle')];
if (showTicks) {
const n = Math.floor((max - min) / step);
for (let i = 0; i <= n; i++) {
const v = min + i * step;
const t = document.createElement('div');
t.className = 'aa-slider-tick';
t.style.left = ((v - min) / (max - min) * 100) + '%';
ticks.appendChild(t);
}
}
function clamp(v) { v = Math.round((v - min) / step) * step + min; return Math.max(min, Math.min(max, v)); }
function pct(v) { return (v - min) / (max - min) * 100; }
function fromClientX(x) {
const rect = track.getBoundingClientRect();
return clamp(min + (x - rect.left) / rect.width * (max - min));
}
function paint() {
if (range) {
const [lo, hi] = value;
fill.style.left = pct(lo) + '%';
fill.style.width = (pct(hi) - pct(lo)) + '%';
handles[0].style.left = pct(lo) + '%';
handles[1].style.left = pct(hi) + '%';
if (showInput) {
valueWrap.querySelectorAll('input')[0].value = lo;
valueWrap.querySelectorAll('input')[1].value = hi;
}
} else {
fill.style.left = '0%';
fill.style.width = pct(value) + '%';
handles[0].style.left = pct(value) + '%';
if (showInput) valueWrap.querySelector('input').value = value;
}
}
function startDrag(i, e) {
e.preventDefault();
const move = (ev) => {
const x = (ev.touches ? ev.touches[0].clientX : ev.clientX);
const nv = fromClientX(x);
if (range) {
value[i] = nv;
value.sort((a, b) => a - b); // 保持顺序
} else {
value = nv;
}
paint();
};
const up = () => {
document.removeEventListener('pointermove', move);
document.removeEventListener('pointerup', up);
};
document.addEventListener('pointermove', move);
document.addEventListener('pointerup', up);
}
handles.forEach((h, i) => {
h.addEventListener('pointerdown', (e) => startDrag(i, e));
});
// 点击轨道定位最近的手柄
track.addEventListener('pointerdown', (e) => {
if (e.target.classList.contains('aa-slider-handle')) return;
const nv = fromClientX(e.clientX);
if (range) {
const i = Math.abs(nv - value[0]) <= Math.abs(nv - value[1]) ? 0 : 1;
value[i] = nv; value.sort((a, b) => a - b);
} else {
value = nv;
}
paint();
});
paint();
}
document.querySelectorAll('[data-slider]').forEach(initSlider);
</script>
</body>
</html>
+145
View File
@@ -0,0 +1,145 @@
import React, { useRef, useState, useEffect } from 'react';
import './Slider.css';
/**
* Aurora Admin Slider(React)
* 对齐 组件7.txt SliderInput 规范:单/双滑块、刻度、输入框联动
*
* props:
* - value / defaultValue : number | [lo, hi]
* - min / max / step
* - range : 双滑块
* - showTicks : 刻度
* - showInput : 数值输入框联动
* - disabled
* - onChange(value)
*/
export default function Slider({
value,
defaultValue = 0,
min = 0,
max = 100,
step = 1,
range = false,
showTicks = false,
showInput = false,
disabled = false,
onChange
}) {
const trackRef = useRef(null);
const [dragIndex, setDragIndex] = useState(-1);
const current = value !== undefined ? value : defaultValue;
const pct = (v) => ((v - min) / (max - min)) * 100;
const clamp = (v) => {
const snapped = Math.round((v - min) / step) * step + min;
return Math.max(min, Math.min(max, snapped));
};
const valueFromClientX = (x) => {
const rect = trackRef.current.getBoundingClientRect();
return clamp(min + (x - rect.left) / rect.width * (max - min));
};
const setVal = (next) => {
if (value === undefined) onChange && onChange(next);
else onChange && onChange(next);
};
const onMove = (e) => {
if (dragIndex < 0) return;
const nv = valueFromClientX(e.clientX);
if (range) {
const arr = [...current]; arr[dragIndex] = nv; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(nv);
}
};
const onUp = () => {
setDragIndex(-1);
window.removeEventListener('pointermove', onMove);
window.removeEventListener('pointerup', onUp);
};
const onHandleDown = (i, e) => {
if (disabled) return;
e.preventDefault();
setDragIndex(i);
window.addEventListener('pointermove', onMove);
window.addEventListener('pointerup', onUp);
};
const onTrackDown = (e) => {
if (disabled || e.target.classList.contains('aa-slider-handle')) return;
const nv = valueFromClientX(e.clientX);
if (range) {
const i = Math.abs(nv - current[0]) <= Math.abs(nv - current[1]) ? 0 : 1;
const arr = [...current]; arr[i] = nv; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(nv);
}
};
const onInput = (i, e) => {
const v = +e.target.value;
if (range) {
const arr = [...current]; arr[i] = v; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(v);
}
};
useEffect(() => () => onUp(), []); // eslint-disable-line
const handlePercents = range ? [pct(current[0]), pct(current[1])] : [pct(current)];
const fillStyle = range
? { left: pct(current[0]) + '%', width: (pct(current[1]) - pct(current[0])) + '%' }
: { left: '0%', width: pct(current) + '%' };
const tickPercents = Array.from(
{ length: Math.floor((max - min) / step) + 1 },
(_, i) => pct(min + i * step)
);
return (
<div className={`aa-slider${disabled ? ' is-disabled' : ''}`}>
<div className="aa-slider-track" ref={trackRef} onPointerDown={onTrackDown}>
<div className="aa-slider-rail"></div>
<div className="aa-slider-fill" style={fillStyle}></div>
{showTicks && (
<div className="aa-slider-ticks">
{tickPercents.map((t, i) => (
<div key={i} className="aa-slider-tick" style={{ left: t + '%' }}></div>
))}
</div>
)}
{handlePercents.map((h, i) => (
<div
key={i}
className="aa-slider-handle"
style={{ left: h + '%' }}
onPointerDown={(e) => onHandleDown(i, e)}
></div>
))}
</div>
{showInput && (
<div className="aa-slider-value">
{range ? (
<>
<input type="number" value={current[0]} onChange={(e) => onInput(0, e)} />
<span>—</span>
<input type="number" value={current[1]} onChange={(e) => onInput(1, e)} />
</>
) : (
<input type="number" value={current} onChange={(e) => onInput(null, e)} />
)}
</div>
)}
</div>
);
}
/*
用法示例:
import Slider from './Slider';
<Slider min={0} max={100} defaultValue={30} showInput onChange={setV} />
<Slider range min={0} max={100} defaultValue={[20, 60]} onChange={setRange} />
*/
+132
View File
@@ -0,0 +1,132 @@
<template>
<div class="aa-slider" :class="{ 'is-disabled': disabled }">
<div class="aa-slider-track" ref="track" @pointerdown="onTrackDown">
<div class="aa-slider-rail"></div>
<div class="aa-slider-fill" :style="fillStyle"></div>
<div class="aa-slider-ticks" v-if="showTicks">
<div v-for="(t, i) in tickPercents" :key="i" class="aa-slider-tick" :style="{ left: t + '%' }"></div>
</div>
<div
v-for="(h, i) in handlePercents" :key="i"
class="aa-slider-handle" :style="{ left: h + '%' }"
@pointerdown.stop="onHandleDown(i, $event)"
></div>
</div>
<div class="aa-slider-value" v-if="showInput">
<template v-if="range">
<input type="number" :value="value[0]" @change="onInput(0, $event)" />
<span>—</span>
<input type="number" :value="value[1]" @change="onInput(1, $event)" />
</template>
<input v-else type="number" :value="value" @change="onInput(null, $event)" />
</div>
</div>
</template>
<script>
export default {
name: 'AaSlider',
props: {
value: { type: [Number, Array], default: 0 }, // number | [lo, hi]
min: { type: Number, default: 0 },
max: { type: Number, default: 100 },
step: { type: Number, default: 1 },
range: { type: Boolean, default: false },
showTicks: { type: Boolean, default: false },
showInput: { type: Boolean, default: false },
disabled: { type: Boolean, default: false }
},
data() { return { dragIndex: -1 }; },
computed: {
pct() { return (v) => ((v - this.min) / (this.max - this.min)) * 100; },
clamp() {
return (v) => {
const snapped = Math.round((v - this.min) / this.step) * this.step + this.min;
return Math.max(this.min, Math.min(this.max, snapped));
};
},
handlePercents() {
if (this.range) return [this.pct(this.value[0]), this.pct(this.value[1])];
return [this.pct(this.value)];
},
fillStyle() {
if (this.range) {
const lo = this.pct(this.value[0]), hi = this.pct(this.value[1]);
return { left: lo + '%', width: (hi - lo) + '%' };
}
return { left: '0%', width: this.pct(this.value) + '%' };
},
tickPercents() {
const n = Math.floor((this.max - this.min) / this.step);
return Array.from({ length: n + 1 }, (_, i) => this.pct(this.min + i * this.step));
}
},
methods: {
setVal(next) { this.$emit('input', next); this.$emit('change', next); },
valueFromClientX(x) {
const rect = this.$refs.track.getBoundingClientRect();
return this.clamp(this.min + (x - rect.left) / rect.width * (this.max - this.min));
},
onHandleDown(i, e) {
if (this.disabled) return;
e.preventDefault();
this.dragIndex = i;
window.addEventListener('pointermove', this.onMove);
window.addEventListener('pointerup', this.onUp);
},
onTrackDown(e) {
if (this.disabled || e.target.classList.contains('aa-slider-handle')) return;
const nv = this.valueFromClientX(e.clientX);
if (this.range) {
const i = Math.abs(nv - this.value[0]) <= Math.abs(nv - this.value[1]) ? 0 : 1;
const arr = [...this.value]; arr[i] = nv; arr.sort((a, b) => a - b);
this.setVal(arr);
} else {
this.setVal(nv);
}
},
onMove(e) {
if (this.dragIndex < 0) return;
const nv = this.valueFromClientX(e.clientX);
if (this.range) {
const arr = [...this.value]; arr[this.dragIndex] = nv; arr.sort((a, b) => a - b);
this.setVal(arr);
} else {
this.setVal(nv);
}
},
onUp() {
this.dragIndex = -1;
window.removeEventListener('pointermove', this.onMove);
window.removeEventListener('pointerup', this.onUp);
},
onInput(i, e) {
const v = +e.target.value;
if (this.range) {
const arr = [...this.value]; arr[i] = v; arr.sort((a, b) => a - b);
this.setVal(arr);
} else {
this.setVal(v);
}
}
},
beforeDestroy() { this.onUp(); }
};
</script>
<!-- 样式对齐 组件7.txt SliderInput 规范 -->
<style>
.aa-slider { position: relative; display: flex; align-items: center; font-family: var(--font-family, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif); }
.aa-slider.is-disabled { opacity: .5; pointer-events: none; }
.aa-slider-track { position: relative; flex: 1; height: 40px; }
.aa-slider-rail { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 4px; background: #E8ECF1; border-radius: 2px; }
.aa-slider-fill { position: absolute; top: 50%; transform: translateY(-50%); height: 4px; background: #2F54EB; border-radius: 2px; }
.aa-slider-handle { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: #fff;
border: 2px solid #2F54EB; transform: translate(-50%, -50%); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: box-shadow .15s; }
.aa-slider-handle:hover, .aa-slider-handle:focus { box-shadow: 0 0 0 4px rgba(47,84,235,0.2); outline: none; }
.aa-slider-ticks { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 0; pointer-events: none; }
.aa-slider-tick { position: absolute; top: 0; width: 2px; height: 8px; background: #E8ECF1; transform: translate(-50%, -50%); }
.aa-slider-value { margin-left: 12px; font-size: 14px; color: #262626; display: inline-flex; align-items: center; gap: 6px; }
.aa-slider-value input { width: 56px; height: 28px; text-align: center; border: 1px solid #E8ECF1; border-radius: 4px; font-size: 13px; outline: none; color: #262626; }
.aa-slider-value input:focus { border-color: #2F54EB; box-shadow: 0 0 0 2px rgba(47,84,235,0.2); }
</style>
+136
View File
@@ -0,0 +1,136 @@
<template>
<div class="aa-slider" :class="{ 'is-disabled': disabled }">
<div class="aa-slider-track" ref="track" @pointerdown="onTrackDown">
<div class="aa-slider-rail"></div>
<div class="aa-slider-fill" :style="fillStyle"></div>
<div class="aa-slider-ticks" v-if="showTicks">
<div v-for="(t, i) in tickPercents" :key="i" class="aa-slider-tick" :style="{ left: t + '%' }"></div>
</div>
<div
v-for="(h, i) in handlePercents" :key="i"
class="aa-slider-handle" :style="{ left: h + '%' }"
@pointerdown.stop="onHandleDown(i, $event)"
></div>
</div>
<div class="aa-slider-value" v-if="showInput">
<template v-if="range">
<input type="number" :value="modelValue[0]" @change="onInput(0, $event)" />
<span>—</span>
<input type="number" :value="modelValue[1]" @change="onInput(1, $event)" />
</template>
<input v-else type="number" :value="modelValue" @change="onInput(null, $event)" />
</div>
</div>
</template>
<script setup>
import { ref, computed, onBeforeUnmount } from 'vue';
const props = defineProps({
modelValue: { type: [Number, Array], default: 0 }, // number | [lo, hi]
min: { type: Number, default: 0 },
max: { type: Number, default: 100 },
step: { type: Number, default: 1 },
range: { type: Boolean, default: false },
showTicks: { type: Boolean, default: false },
showInput: { type: Boolean, default: false },
disabled: { type: Boolean, default: false }
});
const emit = defineEmits(['update:modelValue', 'change']);
const track = ref(null);
const dragIndex = ref(-1);
const pct = (v) => ((v - props.min) / (props.max - props.min)) * 100;
const clamp = (v) => {
const snapped = Math.round((v - props.min) / props.step) * props.step + props.min;
return Math.max(props.min, Math.min(props.max, snapped));
};
const handlePercents = computed(() => {
if (props.range) return [pct(props.modelValue[0]), pct(props.modelValue[1])];
return [pct(props.modelValue)];
});
const fillStyle = computed(() => {
if (props.range) {
const lo = pct(props.modelValue[0]), hi = pct(props.modelValue[1]);
return { left: lo + '%', width: (hi - lo) + '%' };
}
return { left: '0%', width: pct(props.modelValue) + '%' };
});
const tickPercents = computed(() => {
const n = Math.floor((props.max - props.min) / props.step);
return Array.from({ length: n + 1 }, (_, i) => pct(props.min + i * props.step));
});
function setVal(next) {
emit('update:modelValue', next);
emit('change', next);
}
function valueFromClientX(x) {
const rect = track.value.getBoundingClientRect();
return clamp(props.min + (x - rect.left) / rect.width * (props.max - props.min));
}
function onHandleDown(i, e) {
if (props.disabled) return;
e.preventDefault();
dragIndex.value = i;
window.addEventListener('pointermove', onMove);
window.addEventListener('pointerup', onUp);
}
function onTrackDown(e) {
if (props.disabled || e.target.classList.contains('aa-slider-handle')) return;
const nv = valueFromClientX(e.clientX);
if (props.range) {
const i = Math.abs(nv - props.modelValue[0]) <= Math.abs(nv - props.modelValue[1]) ? 0 : 1;
const arr = [...props.modelValue]; arr[i] = nv; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(nv);
}
}
function onMove(e) {
if (dragIndex.value < 0) return;
const nv = valueFromClientX(e.clientX);
if (props.range) {
const arr = [...props.modelValue]; arr[dragIndex.value] = nv; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(nv);
}
}
function onUp() {
dragIndex.value = -1;
window.removeEventListener('pointermove', onMove);
window.removeEventListener('pointerup', onUp);
}
function onInput(i, e) {
const v = +e.target.value;
if (props.range) {
const arr = [...props.modelValue]; arr[i] = v; arr.sort((a, b) => a - b);
setVal(arr);
} else {
setVal(v);
}
}
onBeforeUnmount(onUp);
</script>
<!-- 样式对齐 组件7.txt SliderInput 规范 -->
<style scoped>
.aa-slider { position: relative; display: flex; align-items: center; font-family: var(--font-family, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif); }
.aa-slider.is-disabled { opacity: .5; pointer-events: none; }
.aa-slider-track { position: relative; flex: 1; height: 40px; }
.aa-slider-rail { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 4px; background: #E8ECF1; border-radius: 2px; }
.aa-slider-fill { position: absolute; top: 50%; transform: translateY(-50%); height: 4px; background: #2F54EB; border-radius: 2px; }
.aa-slider-handle { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: #fff;
border: 2px solid #2F54EB; transform: translate(-50%, -50%); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: box-shadow .15s; }
.aa-slider-handle:hover, .aa-slider-handle:focus { box-shadow: 0 0 0 4px rgba(47,84,235,0.2); outline: none; }
.aa-slider-ticks { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 0; pointer-events: none; }
.aa-slider-tick { position: absolute; top: 0; width: 2px; height: 8px; background: #E8ECF1; transform: translate(-50%, -50%); }
.aa-slider-value { margin-left: 12px; font-size: 14px; color: #262626; display: inline-flex; align-items: center; gap: 6px; }
.aa-slider-value input { width: 56px; height: 28px; text-align: center; border: 1px solid #E8ECF1; border-radius: 4px; font-size: 13px; outline: none; color: #262626; }
.aa-slider-value input:focus { border-color: #2F54EB; box-shadow: 0 0 0 2px rgba(47,84,235,0.2); }
</style>