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 未做部分)
360 lines
11 KiB
Vue
360 lines
11 KiB
Vue
<template>
|
||
<view>
|
||
<slot></slot>
|
||
<view
|
||
v-if="mode === 'popup'"
|
||
class="kole-m-cascader__mask"
|
||
:class="{ 'is-open': open }"
|
||
aria-hidden="true"
|
||
@tap="onMaskTap"
|
||
@touchmove.stop.prevent
|
||
></view>
|
||
<view
|
||
class="kole-m-cascader"
|
||
:class="panelClass"
|
||
:role="mode === 'popup' ? 'dialog' : 'group'"
|
||
:aria-modal="mode === 'popup' ? 'true' : 'false'"
|
||
:aria-label="mode === 'popup' ? (title || '选择地区') : label"
|
||
:aria-hidden="mode === 'popup' && !open ? 'true' : 'false'"
|
||
:data-level="String(depth)"
|
||
>
|
||
<view v-if="mode === 'popup'" class="kole-m-cascader__header">
|
||
<view class="kole-m-cascader__btn" role="button" @tap="onCancelTap"><text>取消</text></view>
|
||
<text class="kole-m-cascader__title">{{ title || '选择地区' }}</text>
|
||
<view class="kole-m-cascader__btn kole-m-cascader__btn--confirm" role="button" @tap="onConfirmTap">
|
||
<text>确定</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view v-if="showPath" class="kole-m-cascader__path">
|
||
<template v-for="(item, i) in items" :key="item.value + '-' + i">
|
||
<view
|
||
class="kole-m-cascader__path-item"
|
||
:class="{ 'is-current': i === items.length - 1 }"
|
||
:role="i === items.length - 1 ? '' : 'button'"
|
||
:aria-current="i === items.length - 1 ? 'true' : 'false'"
|
||
@tap="back(i)"
|
||
>
|
||
<text>{{ item.label }}</text>
|
||
</view>
|
||
<text v-if="i !== items.length - 1" class="kole-m-cascader__sep">›</text>
|
||
</template>
|
||
</view>
|
||
|
||
<scroll-view v-if="list.length" class="kole-m-cascader__panel" scroll-y :role="'listbox'" :aria-label="listLabel">
|
||
<view
|
||
v-for="(node, i) in list"
|
||
:key="node.value + '-' + i"
|
||
class="kole-m-cascader__option"
|
||
:class="isSelected(node) ? 'is-selected' : (isOff(node) ? 'is-disabled' : '')"
|
||
:role="'option'"
|
||
:aria-selected="isSelected(node) ? 'true' : 'false'"
|
||
:aria-disabled="isOff(node) ? 'true' : 'false'"
|
||
@tap="pick(node)"
|
||
>
|
||
<text class="kole-m-cascader__label">{{ node.label }}</text>
|
||
<text v-if="isLeaf(node)" class="kole-m-cascader__check">✓</text>
|
||
<text v-else class="kole-m-cascader__arrow">›</text>
|
||
</view>
|
||
</scroll-view>
|
||
<text v-else class="kole-m-cascader__empty">该级暂无可选项</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
/* uni-app 端 · 级联选择器(移动端)— 规格 §44
|
||
跨端差异:用 view / text;选项区用 scroll-view(scroll-y)代替 ul / li,滚动由小程序/App 原生接管,
|
||
role / aria-* 仍按规格 §44.6 保留(用 :role / :aria-* 绑定,H5 产物里生效)。
|
||
点击一律 @tap;浮层遮罩用 @touchmove.stop.prevent 阻止背景滚动穿透。
|
||
级数不写死:路径条按已选深度渲染,面板**只渲染当前一层** —— 375px 宽下并排多列会把每列压到
|
||
100px 以内,无法阅读(规格 §44.2)。
|
||
尺寸用 rpx(88rpx = 375pt 下的 44px 触控最小边长)。 */
|
||
import { computed, ref } from 'vue';
|
||
|
||
const props = defineProps({
|
||
mode: { type: String, default: 'panel' },
|
||
round: { type: Boolean, default: false },
|
||
showPath: { type: Boolean, default: true },
|
||
open: { type: Boolean, default: false },
|
||
closeOnMask: { type: Boolean, default: true },
|
||
value: { type: Array, default: () => [] },
|
||
options: { type: Array, default: () => [] },
|
||
disabled: { type: Boolean, default: false },
|
||
title: { type: String, default: '' },
|
||
label: { type: String, default: '级联选项' }
|
||
});
|
||
const emit = defineEmits(['change', 'confirm', 'close']);
|
||
|
||
const LAYER_LABELS = ['省份', '城市', '区县'];
|
||
|
||
/* 选项可以是字符串,也可以是 { label, value, disabled, children } 结点(规格 §44.7) */
|
||
function nodeOf(option, i) {
|
||
if (option === null || option === undefined) {
|
||
return { label: '', value: String(i), disabled: false, children: [] };
|
||
}
|
||
if (typeof option === 'object') {
|
||
return {
|
||
label: String(option.label === undefined ? '' : option.label),
|
||
value: String(option.value === undefined ? i : option.value),
|
||
disabled: !!option.disabled,
|
||
children: Array.isArray(option.children) ? option.children.map(nodeOf) : []
|
||
};
|
||
}
|
||
return { label: String(option), value: String(option), disabled: false, children: [] };
|
||
}
|
||
|
||
const tree = computed(() => (Array.isArray(props.options) ? props.options : []).map(nodeOf));
|
||
|
||
/* 沿 path 走到第 depth 级的选项数组(depth=0 是根) */
|
||
function levelList(path, depth) {
|
||
let list = tree.value;
|
||
for (let i = 0; i < depth; i++) {
|
||
const hit = list.find((n) => n.value === String(path[i]));
|
||
if (!hit || !hit.children.length) return [];
|
||
list = hit.children;
|
||
}
|
||
return list;
|
||
}
|
||
|
||
/* 当前展示层级:末项是叶子时停在它所在层(可改选同级),否则展示下一级 */
|
||
function displayDepth(path) {
|
||
let depth = path.length;
|
||
if (depth > 0) {
|
||
const parent = levelList(path, depth - 1);
|
||
const last = parent.find((n) => n.value === String(path[depth - 1]));
|
||
if (last && !last.children.length) depth -= 1;
|
||
}
|
||
return depth;
|
||
}
|
||
|
||
/* null = 跟随 value 属性;点选后本地记账,确认前不改宿主的值 */
|
||
const draft = ref(null);
|
||
const picked = computed(() => draft.value || (Array.isArray(props.value) ? props.value.map(String) : []));
|
||
const depth = computed(() => displayDepth(picked.value));
|
||
const list = computed(() => levelList(picked.value, depth.value));
|
||
const pickedValue = computed(() => picked.value[depth.value]);
|
||
const items = computed(() => {
|
||
const out = [];
|
||
let lv = tree.value;
|
||
for (let i = 0; i < picked.value.length; i++) {
|
||
const hit = lv.find((n) => n.value === String(picked.value[i]));
|
||
if (!hit) break;
|
||
out.push(hit);
|
||
lv = hit.children;
|
||
}
|
||
return out;
|
||
});
|
||
const listLabel = computed(
|
||
() => props.label + ' · ' + (LAYER_LABELS[depth.value] || '第 ' + (depth.value + 1) + ' 级')
|
||
);
|
||
|
||
const panelClass = computed(() => [
|
||
'kole-m-cascader--' + (props.mode === 'popup' ? 'popup' : 'panel'),
|
||
props.showPath ? '' : 'kole-m-cascader--no-path',
|
||
props.round ? 'kole-m-cascader--round' : '',
|
||
props.open ? 'is-open' : ''
|
||
].filter(Boolean));
|
||
|
||
function isSelected(node) {
|
||
return String(node.value) === String(pickedValue.value === undefined ? '' : pickedValue.value);
|
||
}
|
||
|
||
function isOff(node) {
|
||
return props.disabled || node.disabled;
|
||
}
|
||
|
||
function isLeaf(node) {
|
||
return !node.children.length;
|
||
}
|
||
|
||
function emitPath(next) {
|
||
draft.value = next;
|
||
emit('change', next);
|
||
}
|
||
|
||
/* 点选项:截断更深的层级,写入本级选中值(规格 §44.5) */
|
||
function pick(node) {
|
||
if (isOff(node)) return;
|
||
const next = picked.value.slice(0, depth.value);
|
||
next[depth.value] = node.value;
|
||
emitPath(next);
|
||
}
|
||
|
||
/* 点路径条上的上级:退回该级,重新展示它的下一级 */
|
||
function back(d) {
|
||
if (props.disabled) return;
|
||
if (d === items.value.length - 1) return; /* 末位是「你在这里」的锚点,不响应 */
|
||
emitPath(picked.value.slice(0, d + 1));
|
||
}
|
||
|
||
function onMaskTap() {
|
||
if (!props.closeOnMask) return;
|
||
emit('close');
|
||
}
|
||
|
||
function onCancelTap() {
|
||
emit('close');
|
||
}
|
||
|
||
function onConfirmTap() {
|
||
if (props.disabled) return;
|
||
emit('confirm', picked.value);
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.kole-m-cascader {
|
||
--kole-m-cascader-row-height: 88rpx;
|
||
--kole-m-cascader-panel-height: 480rpx;
|
||
--kole-m-touch-target: 88rpx;
|
||
--kole-m-font-size-body: 32rpx;
|
||
--kole-m-font-size-label: 28rpx;
|
||
--kole-m-font-size-caption: 22rpx;
|
||
--kole-m-gutter: 32rpx;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 100%;
|
||
background-color: var(--kole-color-card-bg);
|
||
color: var(--kole-color-text-body);
|
||
font-size: var(--kole-m-font-size-body);
|
||
}
|
||
|
||
.kole-m-cascader__mask {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 2000;
|
||
background-color: var(--kole-color-mask);
|
||
opacity: 0;
|
||
}
|
||
|
||
.kole-m-cascader__mask.is-open { opacity: 1; }
|
||
|
||
/* 变体 mode=panel:内嵌在页面里,跟随文档流 */
|
||
.kole-m-cascader--panel {
|
||
border: 1rpx solid var(--kole-color-border);
|
||
border-radius: 8rpx;
|
||
}
|
||
|
||
/* 变体 mode=popup:底部浮层(默认收起,靠 is-open 滑入) */
|
||
.kole-m-cascader--popup {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 2001;
|
||
padding-bottom: constant(safe-area-inset-bottom);
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
}
|
||
|
||
/* 变体 showPath=false:不显示路径条 */
|
||
.kole-m-cascader--no-path .kole-m-cascader__path { display: none; }
|
||
|
||
/* 变体 round=true:浮层靠内容一侧切圆角 */
|
||
.kole-m-cascader--round {
|
||
border-top-left-radius: 16rpx;
|
||
border-top-right-radius: 16rpx;
|
||
}
|
||
|
||
.kole-m-cascader__header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 16rpx var(--kole-m-gutter);
|
||
border-bottom: 1rpx solid var(--kole-color-border);
|
||
}
|
||
|
||
.kole-m-cascader__title {
|
||
color: var(--kole-color-text-title);
|
||
font-size: var(--kole-m-font-size-body);
|
||
}
|
||
|
||
.kole-m-cascader__btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
min-height: var(--kole-m-touch-target);
|
||
padding: 0 16rpx;
|
||
color: var(--kole-color-brand);
|
||
font-size: var(--kole-m-font-size-label);
|
||
}
|
||
|
||
.kole-m-cascader__btn--confirm { font-weight: 500; }
|
||
|
||
/* 路径条:显示已选层级,点某一级回退到该级 */
|
||
.kole-m-cascader__path {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
padding: 8rpx var(--kole-m-gutter);
|
||
border-bottom: 1rpx solid var(--kole-color-border);
|
||
background-color: var(--kole-color-page-bg);
|
||
font-size: var(--kole-m-font-size-label);
|
||
color: var(--kole-color-text-secondary);
|
||
}
|
||
|
||
.kole-m-cascader__path-item {
|
||
display: flex;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
min-height: var(--kole-m-touch-target);
|
||
padding: 0 16rpx;
|
||
color: var(--kole-color-brand);
|
||
font-size: var(--kole-m-font-size-label);
|
||
}
|
||
|
||
/* 当前层级(不可点,是「你在这里」的锚点) */
|
||
.kole-m-cascader__path-item.is-current { color: var(--kole-color-text-body); }
|
||
|
||
.kole-m-cascader__sep {
|
||
color: var(--kole-color-text-placeholder);
|
||
font-size: var(--kole-m-font-size-caption);
|
||
}
|
||
|
||
.kole-m-cascader__panel {
|
||
max-height: var(--kole-m-cascader-panel-height);
|
||
}
|
||
|
||
.kole-m-cascader__option {
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
min-height: var(--kole-m-cascader-row-height);
|
||
padding: 16rpx var(--kole-m-gutter);
|
||
color: var(--kole-color-text-body);
|
||
font-size: var(--kole-m-font-size-body);
|
||
}
|
||
|
||
.kole-m-cascader__option:active { background-color: var(--kole-color-table-header-bg); }
|
||
|
||
/* 状态 selected:当前路径上的项(与 aria-selected 同步) */
|
||
.kole-m-cascader__option.is-selected {
|
||
color: var(--kole-color-brand);
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 状态 disabled:置灰且不响应 */
|
||
.kole-m-cascader__option.is-disabled { color: var(--kole-color-text-disabled); }
|
||
|
||
.kole-m-cascader__label { flex: 1; }
|
||
|
||
/* 展开指示:有下级用 ›,叶子用 ✓(形状差异,不只靠颜色) */
|
||
.kole-m-cascader__arrow { color: var(--kole-color-text-placeholder); }
|
||
|
||
.kole-m-cascader__check { color: var(--kole-color-brand); }
|
||
|
||
/* 状态 empty:当前级没有可选项 */
|
||
.kole-m-cascader__empty {
|
||
padding: 80rpx var(--kole-m-gutter);
|
||
color: var(--kole-color-text-secondary);
|
||
font-size: var(--kole-m-font-size-label);
|
||
text-align: center;
|
||
}
|
||
</style>
|