Regression / regression (push) Canceled after 0s
## 品牌标识(本次会话) 起因:品牌此前没有任何图形标识 —— 唯一 favicon 是内联 data-URI 里的字母「A」, 那是 v2.0.0「Aurora Admin → Kole UI」改名漏掉的一处(PC 顶栏也是「A」, 移动端站已是「K」;移动端文档站则完全没有 favicon)。 - 几何:24 网格三个互不接触的笔画(竖 + 两斜),圆头描边; 描边 2.25 → 16px 标签页尺寸下正好 1.5px = 规范原文「描边1.5px」 - 取色分两套(刻意):favicon 硬编码品牌蓝/白(渲染在浏览器标签栏,不继承 kole-dark); 顶栏标记走 currentColor(实测暗色下自动转 rgb(20,22,28)) - 新增 theme-color 双条(light #FFFFFF / dark #1C1F26,取 --kole-color-card-bg) - 修 site/app.js hero 标语 KOLE ADMIN → KOLE UI(改名变形残留) - 移动端 7 个模板补 favicon(此前计数 0) 验收:门禁 9 条全 OK(site-routing/site-routes/mobile-docs/mobile-site/isolation/ theme/nav/i18n/icons);PC 回归 1464/1464 · 移动端 807/807,各连跑 8 次一致; 两端 favicon 405 字节逐字节一致;PC 站控制台错误 1→0。 ## 并行会话成果(本次一并入库) - 图标系统:2576 图标(TDesign/Element Plus,MIT)+ 11 端注入 + 5 个构建门禁工具 + IconPreview 预览页 + ICON-SPEC.md 冻结规格 - 移动端平台:47 组件 × 6 端 + 文档站 53 页 + 隔离门禁 - PC 组件:103 个大后台组件 / 组件11 批次 - uni-app:PC 端试点 + 移动端端实现 + 真实编译验证 ## 工程 - .gitignore 补 .scratch/ 与 .zcode-preexisting-*.txt(会话中间产物,实测 9.1MB,不入库) - CHANGELOG 补品牌标识条目 - ROADMAP 登 S8-P4(品牌标识任务包 + og:image/apple-touch-icon 未做部分)
272 lines
8.7 KiB
Vue
272 lines
8.7 KiB
Vue
<template>
|
||
<view
|
||
class="kole-m-slider"
|
||
:class="sliderClass"
|
||
@touchstart="onTouchStart"
|
||
@touchmove="onTouchMove"
|
||
@touchend="onTouchEnd"
|
||
@touchcancel="onTouchEnd"
|
||
>
|
||
<view class="kole-m-slider__rail" ref="rail">
|
||
<view class="kole-m-slider__track">
|
||
<view class="kole-m-slider__filled" :style="filledStyle"></view>
|
||
<template v-if="marks">
|
||
<view
|
||
v-for="m in markPoints"
|
||
:key="'m' + m"
|
||
class="kole-m-slider__mark"
|
||
:style="{ left: m + '%' }"
|
||
></view>
|
||
</template>
|
||
<view
|
||
v-for="(v, i) in values"
|
||
:key="'t' + i"
|
||
class="kole-m-slider__thumb"
|
||
:style="{ left: pct(v) }"
|
||
:role="disabled ? '' : 'slider'"
|
||
:aria-valuenow="v"
|
||
:aria-valuemin="min"
|
||
:aria-valuemax="max"
|
||
:aria-disabled="disabled ? 'true' : 'false'"
|
||
></view>
|
||
</view>
|
||
</view>
|
||
<text v-if="showValue" class="kole-m-slider__value">{{ range ? values[0] + '~' + values[1] : values[0] }}</text>
|
||
<slot></slot>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
/* uni-app 端 · 滑动选择器(移动端)— 规格 §35
|
||
跨端差异(关键的一条):
|
||
① **手势只能用 touch 事件**(@touchstart / @touchmove / @touchend)——
|
||
小程序与 App 端没有 PointerEvent,也没有 pointerdown/pointermove;
|
||
② 坐标从 e.touches[0].clientX 取(uni 的事件对象与 DOM 事件不同,没有统一的 e.clientX 字段,
|
||
且 touchend 时 touches 为空数组,需回落到 e.changedTouches[0]);
|
||
③ 轨道位置用 ref 上的 uni.createSelectorQuery() 度量(小程序没有 getBoundingClientRect 的同步语义),
|
||
度量结果缓存在 layout 里,触摸期间不重复查询;
|
||
④ 尺寸用 rpx:88rpx = 375pt 下的 44px 触控最小边长,滑块 40rpx = 20px。 */
|
||
import { computed, ref } from 'vue';
|
||
|
||
const props = defineProps({
|
||
value: { type: Number, default: 0 },
|
||
valueMax: { type: Number, default: 100 },
|
||
min: { type: Number, default: 0 },
|
||
max: { type: Number, default: 100 },
|
||
step: { type: Number, default: 1 },
|
||
mode: { type: String, default: 'single' },
|
||
marks: { type: Boolean, default: false },
|
||
showValue: { type: Boolean, default: true },
|
||
disabled: { type: Boolean, default: false },
|
||
label: { type: String, default: '滑动选择' }
|
||
});
|
||
const emit = defineEmits(['change']);
|
||
|
||
const rail = ref(null);
|
||
const dragging = ref(false);
|
||
const active = ref(-1);
|
||
/* null = 跟随 value 属性;拖动后本地记账(与 Collapse 同一约定) */
|
||
const inner = ref(null);
|
||
/* 轨道度量缓存(左边界 + 宽度,单位 px);touchend 后清空,下次按下重新度量 */
|
||
const layout = ref(null);
|
||
const markPoints = [0, 25, 50, 75, 100];
|
||
|
||
const range = computed(() => props.mode === 'range');
|
||
const values = computed(() => inner.value || (range.value ? [props.value, props.valueMax] : [props.value]));
|
||
const sliderClass = computed(() => [
|
||
range.value ? 'kole-m-slider--range' : '',
|
||
props.marks ? 'kole-m-slider--marks' : '',
|
||
dragging.value ? 'is-dragging' : '',
|
||
props.disabled ? 'is-disabled' : ''
|
||
].filter(Boolean));
|
||
const filledStyle = computed(() => {
|
||
if (!range.value) return { right: 100 - ((values.value[0] - props.min) / (props.max - props.min)) * 100 + '%' };
|
||
return {
|
||
left: ((values.value[0] - props.min) / (props.max - props.min)) * 100 + '%',
|
||
right: 100 - ((values.value[1] - props.min) / (props.max - props.min)) * 100 + '%'
|
||
};
|
||
});
|
||
|
||
function pct(v) {
|
||
if (props.max === props.min) return '0%';
|
||
return ((v - props.min) / (props.max - props.min)) * 100 + '%';
|
||
}
|
||
function 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));
|
||
}
|
||
function nearest(v) {
|
||
if (!range.value) return 0;
|
||
return Math.abs(values.value[0] - v) <= Math.abs(values.value[1] - v) ? 0 : 1;
|
||
}
|
||
function commit(index, v) {
|
||
let next = clamp(v);
|
||
if (range.value) {
|
||
const other = values.value[1 - index];
|
||
next = index === 0 ? Math.min(next, other - props.step) : Math.max(next, other + props.step);
|
||
}
|
||
const out = range.value ? [values.value[0], values.value[1]] : [next];
|
||
out[index] = next;
|
||
inner.value = out;
|
||
emit('change', range.value ? out : out[0]);
|
||
}
|
||
|
||
/* 触摸坐标:uni 的事件对象用 touches / changedTouches,没有 DOM 的 clientX */
|
||
function clientXOf(e) {
|
||
var list = (e && e.touches && e.touches.length ? e.touches : null) || (e && e.changedTouches) || [];
|
||
return list.length ? list[0].clientX : null;
|
||
}
|
||
|
||
/* 轨道度量:小程序用 uni.createSelectorQuery 异步拿 left / width */
|
||
function measure() {
|
||
return new Promise(function (resolve) {
|
||
if (typeof uni === 'undefined' || !uni.createSelectorQuery) { resolve(layout.value); return; }
|
||
uni
|
||
.createSelectorQuery()
|
||
.select('.kole-m-slider__rail')
|
||
.boundingClientRect(function (rect) {
|
||
resolve(rect && rect.width ? { left: rect.left, width: rect.width } : null);
|
||
})
|
||
.exec();
|
||
});
|
||
}
|
||
|
||
function valueAt(clientX, box) {
|
||
if (clientX === null) return null;
|
||
if (!box || !box.width) return null;
|
||
return clamp(props.min + ((clientX - box.left) / box.width) * (props.max - props.min));
|
||
}
|
||
|
||
function onTouchStart(e) {
|
||
if (props.disabled) return;
|
||
const x = clientXOf(e);
|
||
if (x === null) return;
|
||
measure().then(function (box) {
|
||
if (!box) return;
|
||
layout.value = box;
|
||
const v = valueAt(x, box);
|
||
if (v === null) return;
|
||
active.value = nearest(v);
|
||
dragging.value = true;
|
||
commit(nearest(v), v);
|
||
});
|
||
}
|
||
|
||
function onTouchMove(e) {
|
||
if (props.disabled || active.value < 0) return;
|
||
const v = valueAt(clientXOf(e), layout.value);
|
||
if (v === null) return;
|
||
commit(active.value, v);
|
||
}
|
||
|
||
function onTouchEnd() {
|
||
if (active.value < 0) return;
|
||
active.value = -1;
|
||
dragging.value = false;
|
||
layout.value = null;
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.kole-m-slider {
|
||
--kole-m-slider-thumb: 40rpx; /* 滑块视觉直径(20px @375pt) */
|
||
--kole-m-slider-thumb-active: 48rpx; /* 拖动中的滑块直径(24px) */
|
||
--kole-m-slider-track: 8rpx; /* 轨道可视高度(4px) */
|
||
--kole-m-touch-target: 88rpx;
|
||
--kole-m-font-size-label: 28rpx;
|
||
--kole-m-gutter: 32rpx;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
align-items: center;
|
||
width: 100%;
|
||
padding-left: var(--kole-m-gutter);
|
||
padding-right: var(--kole-m-gutter);
|
||
background-color: var(--kole-color-card-bg);
|
||
color: var(--kole-color-text-body);
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
/* 轨道热区:可视 8rpx 的轨道垂直居中在这条 88rpx 高的带子里 */
|
||
.kole-m-slider__rail {
|
||
position: relative;
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
min-height: var(--kole-m-touch-target);
|
||
}
|
||
|
||
.kole-m-slider__track {
|
||
position: relative;
|
||
width: 100%;
|
||
height: var(--kole-m-slider-track);
|
||
border-radius: 4rpx;
|
||
background-color: var(--kole-color-border);
|
||
}
|
||
|
||
.kole-m-slider__filled {
|
||
position: absolute;
|
||
top: 0;
|
||
bottom: 0;
|
||
left: 0;
|
||
border-radius: 4rpx;
|
||
background-color: var(--kole-color-brand);
|
||
}
|
||
|
||
.kole-m-slider__thumb {
|
||
position: absolute;
|
||
top: 50%;
|
||
box-sizing: border-box;
|
||
width: var(--kole-m-slider-thumb);
|
||
height: var(--kole-m-slider-thumb);
|
||
margin-top: -20rpx;
|
||
margin-left: -20rpx;
|
||
border: 4rpx solid var(--kole-color-brand);
|
||
border-radius: 50%;
|
||
background-color: var(--kole-color-card-bg);
|
||
}
|
||
|
||
/* 状态 dragging:滑块放大 + 轨道加一层浅底(手指抓住的反馈) */
|
||
.kole-m-slider.is-dragging .kole-m-slider__thumb {
|
||
width: var(--kole-m-slider-thumb-active);
|
||
height: var(--kole-m-slider-thumb-active);
|
||
margin-top: -24rpx;
|
||
margin-left: -24rpx;
|
||
}
|
||
|
||
.kole-m-slider.is-dragging .kole-m-slider__rail { background-color: var(--kole-color-brand-bg); }
|
||
|
||
/* 变体 marks=with-marks:轨道上出现刻度点(默认不渲染 —— 刻度是信息不是装饰) */
|
||
.kole-m-slider__mark {
|
||
display: none;
|
||
position: absolute;
|
||
top: 50%;
|
||
width: 4rpx;
|
||
height: 16rpx;
|
||
margin-top: -8rpx;
|
||
margin-left: -2rpx;
|
||
border-radius: 2rpx;
|
||
background-color: var(--kole-color-text-placeholder);
|
||
}
|
||
|
||
.kole-m-slider--marks .kole-m-slider__mark { display: block; }
|
||
|
||
.kole-m-slider__value {
|
||
flex-shrink: 0;
|
||
min-width: 96rpx;
|
||
padding-left: 24rpx;
|
||
text-align: right;
|
||
color: var(--kole-color-text-secondary);
|
||
font-size: var(--kole-m-font-size-label);
|
||
}
|
||
|
||
/* 状态 disabled:整条置灰且不响应 */
|
||
.kole-m-slider.is-disabled .kole-m-slider__thumb {
|
||
border-color: var(--kole-color-text-disabled);
|
||
background-color: var(--kole-color-disabled-bg);
|
||
}
|
||
|
||
.kole-m-slider.is-disabled .kole-m-slider__filled { background-color: var(--kole-color-text-disabled); }
|
||
|
||
.kole-m-slider.is-disabled .kole-m-slider__value { color: var(--kole-color-text-disabled); }
|
||
</style>
|