- API 路由统一: 移除 /api/h5/,统一 /api/pms/ 入口 - 二进制改名: api-server -> pms-api(与服务名一致) - nginx: 合并 /api/ + /pms/api/ 为 /api/pms/ - 新增 docs/API.md 接口文档 - 后端: CabinetDetail 增加 rssi/pow_fail/address/soc 等字段 - Redis 管道批量读取仓体实时数据(SOC/电压/电流/功率) - DB: 所有 TIMESTAMP 列改为 DATETIME(修复类型不匹配) - 用户管理: 新增创建时间/修改时间列,状态改用 Switch - 角色管理/用户管理: 操作按钮改为图标 - PC 设备详情: 基本信息补全 RSSI/ICCID/电源/地址 - PC 卡片: 通道统计改用 Lucide 图标,颜色统一 - PC 二维码: canvas 渲染,含编号文字,支持右键下载 - H5: 按 uni-app 规范修正导航(navigateTo 替代 reLaunch) - H5: 详情页加返回导航条 - H5: 扫码支持摄像头(jsQR)+ ?id= 参数 - H5: 底部 tabBar 在所有页面常显 - H5: 首页统计改为 6 项(设备/通道/空闲/充电/充满/故障) - H5: 下拉刷新 / 上拉加载 - 产品首页: 添加业务联系 - 文档: 清理过时文件,补充缺失规范章节
4.2 KiB
4.2 KiB
title, impact, impactDescription, type, tags
| title | impact | impactDescription | type | tags | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| System Modifier Keys Must Be Held During keyup Events | MEDIUM | Modifier keys (ctrl, alt, shift, meta) behave differently with keyup - they must be held when the key is released | gotcha |
|
System Modifier Keys Must Be Held During keyup Events
Impact: MEDIUM - When using system modifier keys (.ctrl, .alt, .shift, .meta) with keyup events, the modifier must still be pressed when the other key is released. Releasing the modifier key first will not trigger the event, causing keyboard shortcuts to appear broken.
Task Checklist
- Understand that
@keyup.ctrlrequires Ctrl to be held while releasing another key - Consider using
keydowninstead ofkeyupfor modifier key combinations - Use
.exactwhen you need precise modifier key control - Test keyboard shortcuts with proper key release order
Incorrect:
<!-- WRONG: Expecting this to fire when Ctrl is released -->
<template>
<input @keyup.ctrl="onCtrlRelease" />
<!-- This does NOT fire when you just release Ctrl! -->
<!-- It fires when you release ANY key while holding Ctrl -->
</template>
<!-- WRONG: Misunderstanding keyup.ctrl behavior -->
<template>
<div @keyup.ctrl="handleShortcut">
<!-- User presses Ctrl+S, releases Ctrl first, then S -->
<!-- Event does NOT fire because Ctrl wasn't held during S release -->
</div>
</template>
Correct:
<!-- CORRECT: User must hold Ctrl while releasing another key -->
<template>
<input @keyup.ctrl.s="saveDocument" />
<!-- User presses Ctrl+S, then releases S while holding Ctrl -->
<!-- Event fires correctly -->
</template>
<script setup>
function saveDocument(event) {
event.preventDefault()
// Save logic here
}
</script>
<!-- CORRECT: Use keydown for more intuitive modifier behavior -->
<template>
<div @keydown.ctrl.s="saveDocument">
<!-- keydown fires immediately when both keys are pressed -->
<!-- More intuitive for keyboard shortcuts -->
</div>
</template>
<!-- CORRECT: Use .exact for precise modifier control -->
<template>
<!-- Only fires when ONLY Ctrl is pressed (no Shift, Alt, etc.) -->
<button @click.ctrl.exact="onCtrlClick">Ctrl+Click Only</button>
<!-- Fires with no system modifiers at all -->
<button @click.exact="onPlainClick">Plain Click Only</button>
</template>
How System Modifiers Work with keyup
// Timeline of Ctrl+S keydown:
// 1. User presses Ctrl (keydown fires)
// 2. User presses S while holding Ctrl (keydown fires)
// Timeline of Ctrl+S keyup:
// 3. User releases S while holding Ctrl (keyup.ctrl.s fires!)
// 4. User releases Ctrl (keyup fires, but not keyup.ctrl.s)
// Common mistake:
// 3. User releases Ctrl first (nothing fires for our handler)
// 4. User releases S (keyup.s fires, but not keyup.ctrl.s)
System Modifier Keys
<!-- Available system modifiers -->
<input @keyup.ctrl="..." /> <!-- Ctrl key -->
<input @keyup.alt="..." /> <!-- Alt key (Option on Mac) -->
<input @keyup.shift="..." /> <!-- Shift key -->
<input @keyup.meta="..." /> <!-- Cmd on Mac, Windows key on PC -->
The .exact Modifier
<!-- Different .exact behaviors -->
<!-- Fires even if Shift/Alt are also pressed -->
<button @click.ctrl="onClick">Ctrl + any other modifiers</button>
<!-- Fires ONLY when Ctrl alone is pressed -->
<button @click.ctrl.exact="onClick">Ctrl only, no other modifiers</button>
<!-- Fires ONLY when no system modifiers are pressed -->
<button @click.exact="onClick">No modifiers allowed</button>
Best Practice: Prefer keydown for Shortcuts
<template>
<div
tabindex="0"
@keydown.ctrl.s.prevent="save"
@keydown.ctrl.z.prevent="undo"
@keydown.ctrl.shift.z.prevent="redo"
>
<!-- keydown is more reliable for keyboard shortcuts -->
<!-- Add .prevent to stop browser default (e.g., save dialog) -->
</div>
</template>