Compare commits

..

No commits in common. "2240dbba7a290cb8f4a7c776b9d6fd133301c421" and "a34b194211bdb735d8ddb2b19042280c541c3b24" have entirely different histories.

24 changed files with 1709 additions and 2670 deletions

3
.gitattributes vendored
View File

@ -1,3 +0,0 @@
# Android/设备端脚本必须以 LF 落地:
# CRLF 会让 shebang 变成 "#!/system/bin/sh\r",adb push 到平板后执行即报 "not found"。
*.sh text eol=lf

299
README.md
View File

@ -1,243 +1,5 @@
# WMS 工作台(wms_worker_station) # WMS 工作台(wms_worker_station)
## UI 排版规范(全站强约束)
> 一句话:**布局用 rem(1rem = 100px),间距用 5px 网格;控件高度 36px,行高两档,字号 10 档,圆角 3 档,控件内嵌图标取控件高度的 55~60%。**
> 新增页面/组件照此写;改动旧页面时按本节重新排一遍。
> 页面级结构与自查见 **第 14 节**;真机平台注意见 **第 13 节**。
### 1. 尺寸基数:1rem = 100px
- 唯一实现 `src/render-common/rem-base.js`:`html.fontSize = 100 × min(1, 视口宽 / 1280)`
- **宽度 ≥1280 一律 1rem = 100px**(1280 / 1920 / 2560 / 4K 都一样,也不看窗口高度);
- 窄于 1280 等比缩小,下限 50px(640 宽)。
- 口径:**CSS 里的 rem 值 = 设计稿像素 ÷ 100**(写 `0.5rem` 就是 50px)。
- 真机 APP-PLUS 由 `App.vue` 的 `html { font-size: 7.8125vw !important }` 承担;`7.8125vw = 100/1280`,**必须精确,不要取整**。
- **小数位最多 2 位**(2 位 = 1px 精度,误差 ≤0.5px),`0.20` 写成 `0.2`。
- **媒体查询里不要用 rem 写断点**:媒体查询中的 `rem` 按**初始 16px** 解析,与本项目 1rem = 100px 不是一套(例如写 `20.48rem` 实际是 327px,永远不会触发)。
本项目**不需要窄屏断点**:宽度 <1280 时整站按比例缩放(下限 0.5 倍 = 640px 宽);桌面窗口由 `electron/main.js` 的 `minWidth: 1024` / `minHeight: 640` 兜底。
如需新增断点,写**真实 px** 并注明理由。
### 2. 控件高度 / 行高
| 类型 | rem | ≥1280 时 | 用途 |
|---|---|---|---|
| 控件 | `0.36rem` | 36px | **按钮、输入框、下拉、tab、步进按钮全部统一这一档** |
| 表格/列表行 | `0.5rem` 左右 | 50px | 表格行、列表行(订单表格实为 `0.52`/`0.56rem`,以内容为准) |
| 顶栏 | `0.7rem` | 70px | 顶栏高度,内行由 `0.5rem` 的 logo 决定 |
- **控件不要再写 `0.5rem` 高度**(2026-09-25 已全站从 0.5rem 降到 0.36rem);`80px`/`120px` 是移动端口径,PC 上更不要用。
- 图标、图片、头像、缩略图等**非控件**不套这几档,按内容尺寸走。
- **控件内部的图标/徽标/字形**另有比例要求(可见标记 ≈ 控件高度的 55~60%),见第 12 节。
- 按钮**不要写死宽度**:给高度 + 左右 `padding`,宽度跟内容走。
- 给 `button` 设高度时**必须同时设 `line-height`**(uni-app 默认 `line-height: 2.55555556`,不设会文字偏移/被裁)。
- 多行粘贴框(订单页 `.batch-review-input`)例外,按内容给高度。
### 3. 字号:只有 10 档
| token | rem | ≥1280 | 用途 |
|---|---|---|---|
| `--wms-font-xs` | 0.15 | 15px | 标签、角标、辅助提示 |
| `--wms-font-sm` | 0.17 | 17px | 说明文字 |
| `--wms-font-base` | 0.18 | 18px | 正文、表格 |
| `--wms-font-md` | 0.2 | 20px | 正文强调 |
| `--wms-font-lg` | 0.21 | 21px | 卡片标题 |
| `--wms-font-xl` | 0.22 | 22px | 导航菜单、大标题 |
| `--wms-font-title` | 0.25 | 25px | 页面/弹窗标题 |
| `--wms-font-2xl` | 0.3 | 30px | 大号数值(称重输入、数量) |
| `--wms-font-3xl` | 0.35 | 35px | 合计、重点数字 |
| `--wms-font-4xl` | 0.45 | 45px | 强调大字(打包拦截提示等) |
- 全站字号已统一 ×0.85(只降文字、不降布局尺寸);**要调字号只改字号值,别动 rem 基数**。
- 浮层里的 `px` 字号(退件页摄像头浮窗 11/12/13px、`scan-diag-panel.vue`)是有意为之,不参与本刻度。
### 4. 间距:5px 网格
- `padding` / `margin` / `gap` 取 **`0.05rem` 的倍数**(5 / 10 / 15 / 20 / 25 / 30 …px)。
- 紧凑标签、角标的**内部微内边距**可取 **`0.02rem` 的倍数**(2 / 4px),不要再出现第三种写法。
- 行高与控件高度不受本网格限制(走第 2 节的 36 / 50 / 70)。
### 5. 圆角:3 档 + 圆
| 档位 | rem | 用途 |
|---|---|---|
| 角标 | `0.03rem` | 小标签、角标 |
| 控件/小卡片 | `0.07rem` | 按钮、输入框、标签、小色块;列表/信息类小卡片(退件 `.rp-card`、订单左栏卡片) |
| 大容器 | `0.13rem` | 页面级面板/弹窗(`.pack-card`、`.popup-card`、`.update-dialog`、`.container`) |
| 圆形 | `50%` | 头像、圆形图标按钮 |
### 6. 边框:1px
- 常规边框统一 `0.01rem`(≥1280 正好 1px)。
- 例外只有两种:图标描边/装饰虚线 `0.02rem`(2px)、左侧强调条/对齐条 `0.05rem`(5px)。
### 7. 颜色:用 token,不写死高频色值
- 颜色/圆角/字号都集中在 `src/styles/base.css` 的 `:root`,页面里写 `var(--wms-*)`:
`--wms-primary`、`--wms-primary-alt`、`--wms-success`、`--wms-warning`、`--wms-danger`、
`--wms-text` / `-strong` / `-secondary` / `-tertiary` / `-muted` / `-placeholder` / `-disabled`、
`--wms-page-bg`、`--wms-card-bg`、`--wms-bg-subtle`、`--wms-bg-tint`、`--wms-border` / `-alt` / `-light` / `-strong`、`--wms-white`。
- **页面底色全站统一 `--wms-page-bg = #e8eaed`,各页不要自己写底色**(登录页、打包页原先各写 `#f2f2f2` / `#e8eaed`,已统一)。
它比 `#f8f8f8` 深一档:与白卡片对比 **1.21 : 1**(`#f8f8f8` 只有 1.06 : 1),这样白色卡片才「立」得起来。
页面级框架背景在 `pages.json` 的 `globalStyle.backgroundColor`,与 token 保持同值。
- 纯白分两种写法:**底色**用 `var(--wms-card-bg)`,**文字/描边**用 `var(--wms-white)`。
- 一次性特殊色(渐变、遮罩、阴影里的 `rgba()`、品牌图标色)可以直接写。
### 8. 布局:% / flex 负责伸展,rem 负责封顶
- **大屏表现**:宽度 ≥1280 后所有 rem 尺寸封顶,只做布局变化——多余空间给主区(`flex: 1; min-width: 0`),**不要给窄侧栏**。
- 窄侧栏统一 `flex: 0 0 3.8rem`(380px),三页(订单左栏 / 打包右栏 / 退件左栏)保持一致。
- **主体到页边的留白全站统一**:`--wms-page-pad` = `0.25rem`(25px),由基准 `.page-main` 的
`padding: 0.05rem var(--wms-page-pad) var(--wms-page-pad)` 提供;顶栏 `margin-bottom: 0.2rem` + 上 0.05 = 25px,**四边视觉留白一致**。
- 页面内层容器**不要再加内间距**,否则和基准叠加(订单 `.container` 已置 0;打包页没有 `.page-main`,`.mode-main` 直接取同一个 token)。
- 顶栏(`top-nav`)与打包页顶栏(`.mode-topbar`)的水平内边距也用 `var(--wms-page-pad)`,保证 logo/内容左右对齐。
- **主体内左右分栏间距统一 `--wms-panel-gap` = `0.15rem`(15px)**:
订单 `.panel-left { margin-right }`、退件 `.rp-left { margin-right }`、打包 `.pack-right { margin-left }`(三页统一用 `margin`,保持一致)。
> 更正(2026-09-26):此前记的“真机 WebView 不支持 flex `gap`,写了会贴在一起”**不成立** —— 用户实测 `gap` 在真机生效(原因见第 13 节)。
> 所以页面里现存的 `gap` **保留即可**,不必再逐处换成 `margin`;新代码用 `gap` 或 `margin` 都行,只是同一处不要两种混用。
- 页面骨架统一用 `.page` / `.page-main`,每页只写差异项。
- **侧栏内容用「灰底 + 白卡片」**:侧栏自己不要铺底色(订单左栏、退件左栏都是透明灰底,与右栏一致);里面的每一块(搜索、列表、底部信息栏)做成独立白卡片,卡片间距 `0.15rem`、卡片内边距 `0.15rem`。
- 滚动方式各页自定:整块滚用 `overflow-y: auto`(订单、称重);面板各自滚用 `overflow: hidden` + 子面板 `auto`(退件)。
### 9. 样式放哪:全局在 base.css,个性化在页面
- 6 个页面都要用的 → `src/styles/base.css`(`App.vue` 的 `<style>` 顶部 `@import` 引入;编译后顺序在所有页面 CSS 之前,页面同权重规则天然覆盖基准)。
- 单页面用、或与基准不同的 → 写在页面 `<style>` 里,只写差异项。
- **不要**把页面骨架类改造成公共类去复用:`.page` / `.page-main` 是跨页共用类名(首页用 `keep-alive` 内嵌其它页),加公共类会把别页的 `padding` / `overflow` 套到自己身上。
- 页面 `<style>` 没有 `lang="scss"`,`uni.scss` 的 scss 变量在页面里不可用 → 基准统一用 **CSS 变量**。
### 10. 提交前自检
```bash
npm run lint:layout # 代码级自检:字号/圆角/间距网格/rem 小数位/颜色 token
```
- [ ] 控件高度是 `0.36rem`(表格/列表行 ≈ `0.5rem`),顶栏 `0.7rem`;按钮没写死宽度,设了高度就设 `line-height`
- [ ] 间距是 `0.05rem` 的倍数(微内边距是 `0.02rem` 的倍数)
- [ ] 字号在 10 档内、圆角在 3 档内、边框 `0.01rem`(例外:图标描边 0.02、强调条 0.05)
- [ ] 颜色用 `var(--wms-*)`,没有写死 `#333` / `#2f7dff` / `#909399` 这类高频色
- [ ] 控件内嵌图标/字形 ≤ `0.22rem`,且点击热区与可见标记分开写(第 12 节)
- [ ] 没新增 flex `gap`;`position: sticky` 带了 `-webkit-` 前缀;没在媒体查询里写 rem(第 13 节)
- [ ] rem 值最多 2 位小数;没有动 `7.8125vw`
- [ ] `npm run build:h5` 通过
> 代码级自检只能盖住可量化的部分(字号/间距/小数位);**尺寸比例、图标大小、真机表现这类“看得见”的问题必须先在 dev 里量尺寸或截图确认**(见第 14 节自查)。
### 11. 本地画图:二维码/条形码一律视图层现画,不走远程出图
- **原因**:远程出图(`.../grcode/build?text=`、`api.qrserver.com` 兜底)在断网、内网隔离、服务不可用时二维码直接出不来,
且真机每次都要联网取图。扫码登录二维码、工作台绑定码已全部改为本地绘制。
- **二维码**:`src/render-common/qr-render.js`(依赖 `qrcode-generator`,devDependency:纯 ES5、零运行时依赖、约 15KB)。
用法固定为「属性传内容 + 视图层画」:
```vue
<view class="scan-image" :data-qr-text="scanQrText"></view>
```
```js
// 页面 renderjs 模块
import { paintQrIn, watchQrIn } from '../../render-common/qr-render.js'
mounted () {
// 视图层副作用(画二维码/条形码、console 转发、视口自愈)直接写在最外层:
// 它们 H5 与真机都要跑,不要包进任何 #ifdef 里
this.paintQrCodes() // 内部:paintQrIn + 80/600/1500ms 兜底 + watchQrIn
// #ifndef APP-PLUS
// 只有 H5/Electron 需要的东西(如 rem 初始化)包在 #ifndef 里,
// ⚠️ 不要用 `#ifdef APP-PLUS + return`(会让 esbuild 报 semicolon-after-return,
// 而且以后补的视图层代码会变成真机永不执行)
// #endif
}
```
- **约定**:`data-qr-text` 存**二维码内容**(不是图片地址);画完打 `data-qr-drawn` 记录已画内容,内容不变不重画
(绑定码轮询每 1.5s 一次,不做这层判断会一直重绘);容器用 `childList` + `attributeFilter` 监听,`v-if` 首次插入也会画。
- **绘制细节**:静区 4 模块(少了真机扫不出)、白底、`shape-rendering: crispEdges`(缩放不抗锯齿)、同色连续模块横向合并成一个 `rect`(节点数约减半)。
- **容器要求**:固定正方形(登录页 `0.36rem` 级控件之外的 `1.47rem` 图),**不要加 `border-radius` / `overflow: hidden` 剪裁**,否则会把码切掉导致扫不出。
- **条形码**同理:退件页 `JsBarcode` → SVG(`data-bc-code`,见该页 renderjs)。
- **验证方式**(改完照着做一遍):① 反推 SVG 矩阵与库矩阵逐格比对(0 差异);② 用独立解码器(如 `jsqr`)回环解码等于原文;③ 真机实扫。
### 12. 控件内嵌元素:图标 / 徽标 / 字形
- **可见标记取控件高度的 55~60%**:36px 控件里放 `0.2rem`~`0.22rem`(20~22px),上下各留 7~8px 白边。
- 输入框清除圆标:`0.22rem` 圆 + `0.01rem` 描边 + `0.15rem` 字形 + `line-height: 0.2rem`(配 `box-sizing: border-box`)
- 密码可见图标 `0.2rem`;下拉箭头 `0.2rem`;搜索框清除字形 `0.18rem`(36px 灰圆本身保留)
- **点击热区与可见标记必须分开写**:热区保持控件尺寸 `0.36rem`(透明、**不加边框**),可见圆标/图标放子元素上。
- 坑:`content-box` 下给 `0.36rem` 的盒子再加 `0.01rem` 边框,实际占位 38px,会比 36px 输入框高出 2px 溢出上下边(登录页清除圆标原来就是这样)。
- 圆形一律 `border-radius: 50%`;描边用 `0.01rem`(`0.02rem` 是装饰虚线档)。
- 图标统一用内联 `<svg>`(`viewBox` + `width/height: 100%`),尺寸由外层盒子控制,不要在 `svg` 上写死 px。
- 反例(2026-09-25 已全改):圆标和输入框同高、眼睛图标 `0.3rem` 顶满输入框、下拉箭头 `0.3rem`、搜索清除字形 `0.25rem`。
- 非控件图形(商品图 59px、头像 42.6px、缩略图 36px、表格行 50px+)按内容尺寸走,不套本节的 55~60%。
### 13. 真机平台注意(WebView 由 Chrome 应用提供)
> **更正(2026-09-26)**:此前记录的“真机 WebView = Chromium 52、不支持 flex `gap`”**已被实测推翻** —— 用户确认 `gap` 在真机生效。
> 原因:真机的 WebView 提供者是 **Chrome 应用**(`adb shell settings get global webview_provider` = `com.android.chrome`),
> 不是随固件的系统 `com.android.webview`;版本跟设备上装的 Chrome 走,**不能用“Android 7.1.2 ⇒ Chromium 52”推断能力边界**。
> 复核版本:`adb shell dumpsys webviewupdate`(顺手 `adb shell dumpsys package com.android.chrome | findstr versionName`)。
> ⚠️ 该固件 WebView 实现就是 Chrome,**不能卸载 Chrome/系统 webview**(卸了页面直接白屏)。
> 教训:**能力边界要实测或查版本,不要从系统版本号推**。
**与 WebView 版本无关的硬约束(务必遵守)**
| 约束 | 说明 | 对策 |
|---|---|---|
| 媒体查询里的 `rem` 按初始 16px 解析 | CSS 规范行为,任何版本都一样:写 `20.48rem` 实际是 327px,永不触发 | 断点用真实 px(第 1 节) |
| 新页面早期视口可能是 0×0 | 此时 `vw/vh` 全为 0 → rem 归零 → 白屏(真机实测过) | `viewport-fix.js` 已自愈,见下文「真机坑」 |
| `html { font-size: 7.8125vw }` 不能取整 | 取整会让 1rem 不是整 100px | 保持原值 |
| `content-box` 下加边框会撑大尺寸 | 给 0.36rem 盒子加 0.01rem 边框实际占 38px | 写 `box-sizing: border-box`(第 12 节) |
**新 API / 新语法:先确认再用(不要照抄旧结论)**
- 历史上为“老 WebView”规避过:flex `gap`、`replaceChildren`、`Element.append/prepend/before/after`、CSS `min()/max()/clamp()`、CSS Grid、无前缀 `position: sticky`。
其中 **`gap` 已实测可用**;其余**没有实测过是否必需**,属于保守写法:
- 视图层 renderjs 保持 ES5 写法(少一层降级不确定性);
- `position: sticky` 同时写 `-webkit-sticky`(老 WebView 只认前缀;新 Chrome 前缀仍有效、无副作用);
- 换 DOM 节点用 `appendChild` / `removeChild` 就够,没必要引入新 API。
- **要用新的 CSS/JS 特性前,先用上面的命令查真机版本或在真机上实测**,别拿本文件的历史结论当限制。
### 14. 页面规范:结构 / 骨架 / 公共类 / 新增页面自查
**页面文件结构(每个 `.vue`)**
- **只能有 2 个 `<script>` 块**:主逻辑 + `<script module="remInject" lang="renderjs">`;多一个 dev 就报
`Single file component can contain only one <script> element`(遮罩 + 页面卡住)。
- `<style>` 不带 `lang="scss"`(`uni.scss` 的变量在页面里不可用)。
- renderjs 的 `mounted()` **不要用 `#ifdef APP-PLUS … return … #endif` 的写法**(2026-09-26 统一改掉):
- 真机 rem 交给 `App.vue` 的 CSS,所以 rem 初始化包在 **`// #ifndef APP-PLUS`** 里(H5/Electron 照常执行,真机整块被抖掉);
- 视图层副作用(画二维码/条形码、`installZeroViewportFix()`、`installConsoleForward()`)H5 与真机都要跑,**直接写在最外层**,不要包进任何 `#ifdef`;
- 旧写法(`#ifdef APP-PLUS` + `return` + 后续代码)会让 esbuild 报 `[semicolon-after-return]`(真机死代码),而且后续新增的视图层代码会变成真机永不执行 —— 6 个页面已全部改为 `#ifndef` 包裹。
- 双 script 页面改 CSS,dev 下 HMR 会失败 → **必须刷新页面**才看到效果(`npm run build:h5` 不受影响)。
**页面骨架(每页只写差异项)**
| 项 | 基准来源 | 页面要不要写 |
|---|---|---|
| 页面底色 | `.page` → `--wms-page-bg` | 不写(要例外时写 token,不要写死色值) |
| 主体留白 25px | `.page-main` → `--wms-page-pad` | 不写;内层容器不要再加内边距 |
| 左右分栏间距 15px | `--wms-panel-gap`(**用 margin**) | 侧栏自己写 `margin-right` / `margin-left` |
| 顶栏 70px | `.top-nav` / `.mode-topbar`:`0.7rem` + 水平 `var(--wms-page-pad)` | 顶栏内 logo `1.33rem × 0.5rem` |
| 滚动方式 | 无基准 | 自己写:整块滚 `overflow-y: auto`;面板各自滚 `overflow: hidden` + 子面板 `auto` |
- **卡片三级**:页面级容器(`.container` / `.pack-card` / `.popup-card`)`0.13rem` 圆角;信息卡片(`.rp-card`、订单左栏卡片)`0.07rem`;**卡片内边距与卡片间距都 `0.15rem`**。
- **列表/表格**:行高 `0.5rem` 档(订单表格 `0.52`/`0.56rem` 以内容为准);表头要吸顶按第 13 节写前缀 `sticky`。
- **空状态**统一 `.empty-panel`(`0.07rem` 圆角),左栏用 `.empty-panel--left`(`margin-top: 0`)。
- **接入首页菜单**:在 `src/router/menuRoutes.js` 的 `menuRouteMap` 里同时注册短路径(`/order`)与完整路径(`/pages/order/index`),否则 URL 跳转解析不到页面。
**公共类清单(都在 `src/styles/base.css`,新增同类需求先看这里)**
- 骨架:`.page` / `.page-main`
- 工具类:`.scan-hidden-input`(隐藏的扫码输入框,四页共用;打包页只覆盖 `top: 0`)
- 按钮去默认边框的 `::after`:目前 12 个类集中写在 base.css 的选择器列表里,
**新增自定义 `uni-button` 按钮必须把类名补进这个列表**,否则会带上框架默认的 `1px solid rgba(0,0,0,.2)` 边框。
**新增/修改页面的自查(§10 只能盖住可量化部分)**
- [ ] dev 里真看过:用 `getBoundingClientRect()` 量过关键尺寸,或截图对比过
- [ ] 没有新增 flex `gap`;`sticky` 带了 `-webkit-` 前缀;图标符合第 12 节比例
- [ ] 从别的页面复制来的样式,把不属于本页的差异项删掉(内边距、`overflow`、残留 `@media`)
- [ ] 窄屏(H5 缩到 <1280 宽)与真机各看一遍布局没被压坏
## 真机调试热更新(dev:adb) ## 真机调试热更新(dev:adb)
`npm run dev:adb` 一条命令完成真机调试闭环: `npm run dev:adb` 一条命令完成真机调试闭环:
@ -260,7 +22,7 @@ console 转发原理(release 包 console 默认不进 logcat):
## ⚠️ 真机坑:登录页 reLaunch 到打包模式白屏(切后台回前台才恢复) ## ⚠️ 真机坑:登录页 reLaunch 到打包模式白屏(切后台回前台才恢复)
### 现象 ### 现象
- 真机(RK3288 工控机 / Android 7.1.2,WebView 由 Chrome 应用提供)上,从登录页 `uni.reLaunch` 到打包模式页(`/pages/packaging/index`)后**整个页面白屏**; - 真机(RK3288 工控机 / Android 7.1.2,系统 WebView = Chromium 52)上,从登录页 `uni.reLaunch` 到打包模式页(`/pages/packaging/index`)后**整个页面白屏**;
- 按 Home 退后台再切回前台,页面恢复正常显示; - 按 Home 退后台再切回前台,页面恢复正常显示;
- 服务层逻辑正常执行(页面 onLoad/onShow/mounted 都跑了,toast/语音也正常),只有渲染层白屏。 - 服务层逻辑正常执行(页面 onLoad/onShow/mounted 都跑了,toast/语音也正常),只有渲染层白屏。
@ -301,62 +63,3 @@ export default {
2. **不要**在新页面 WebView 创建早期(onLoad)调用 `plus.screen.lockOrientation` / `plus.webview.currentWebview().setStyle` 等 native 操作——实测无效且会触发 `AdaUniWebView` 的 `ViewOptions.updateViewData` NPE。横屏由 `manifest.json` 的全局 `screenOrientation` 配置承担,打包页的 lockLandscape 已因此移除; 2. **不要**在新页面 WebView 创建早期(onLoad)调用 `plus.screen.lockOrientation` / `plus.webview.currentWebview().setStyle` 等 native 操作——实测无效且会触发 `AdaUniWebView` 的 `ViewOptions.updateViewData` NPE。横屏由 `manifest.json` 的全局 `screenOrientation` 配置承担,打包页的 lockLandscape 已因此移除;
3. 若新增页面在真机出现同样白屏,按上面的示例接入 `installZeroViewportFix` 即可; 3. 若新增页面在真机出现同样白屏,按上面的示例接入 `installZeroViewportFix` 即可;
4. 排查白屏类问题先看**视口尺寸**(renderjs 里打 Log),而不是猜字体/样式——0×0 视口下 CSS 的 vw/vh 全部失效是这类白屏的典型特征。 4. 排查白屏类问题先看**视口尺寸**(renderjs 里打 Log),而不是猜字体/样式——0×0 视口下 CSS 的 vw/vh 全部失效是这类白屏的典型特征。
## ⚠️ 机型注意:X9R 工控机的供电 / USB 口 / 固件差异(2026-09-25 实测)
> 结论先说:这台机器的「扫码突然没反应」**多数不是软件问题**,而是供电不足或 USB 口上挂了耗电外设。
> 装机、巡检、换电源前请先读本节。实测机型:X9R(RK3288 / Android 7.1.2 / 内核 4.4.112)。
### 一、电源:必须 ≥12V/2.5A(推荐 3A)
| 电源 | 满载实测(屏幕最亮 + 4 核满载 60s) | 结果 |
|---|---|---|
| 12V/**2.5A** | USB 掉线 0 次,扫码枪全程在线(120/120) | ✅ 可用 |
| 12V/**2.0A**(24W) | dmesg 出现 **2 次 `usb 2-1: USB disconnect`**(内部 USB Hub 与扫码枪一起掉)、`device not accepting address, error -71`、4 次总线复位;采样中枪离线 13/120(约 6.5s) | ❌ 临界,不可用 |
24W 是**临界值**:屏背光最亮 + WiFi + 内部 USB Hub + 扫码枪 + 喇叭峰值很容易越过它。
### 二、⛔ 绝对不要从平板 USB 口给外设(音响)供电
**现象**:插上 USB 音响后「扫着扫着就扫不上」,重启设备才恢复;**12V/2.5A 电源现场同样复现**。
**根因**:音响与内部 USB Hub、扫码枪共用同一条 5V 支路(USB 口规范每口仅 0.5A,音响常远超)→ 一放音(尤其每次扫码后的**语音播报峰值**)Hub 就过流跳闸 → 先掉 Hub(`usb 2-1`)再掉枪(`usb 2-1.4`)→ 应用侧表现就是 **`keys=0`(一个按键都收不到)**。
**现场判据(不用拆机、不用 root)**:
```bash
adb shell "dmesg | grep -E 'USB disconnect|error -71' | tail -20"
```
- 同时出现 `usb 2-1:`(Hub)与 `usb 2-1.x`(枪)→ **USB 口上挂了耗电外设 / 供电不足**;
- 只有 `usb 2-1.4`(枪)单独掉 → 更可能是枪的线材/接头。
**正确接法**:① 音响自带电源适配器;② 用**带独立供电的 USB Hub**(Hub 自己给音响供电,平板只出信号);③ 蓝牙/自带电池音箱;④ 若必须吃 12V,从 12V 母线单独引一路,不要走平板 USB 口。
### 三、其他机型相关注意
| 项目 | 说明 |
|---|---|
| **adb 认不到设备** | 同一台机器**换个 USB 口可能就认**:实测某个口 Windows 会把 `USB\VID_2207&PID_0006` 绑成通用 WinUSB 驱动,`adb devices` 全空;换口后立刻正常。**先换口/换线,别急着装驱动** |
| **不要卸载 Chrome** | 该固件 WebView 实现就是 Chrome(`adb shell settings get global webview_provider` = `com.android.chrome`),卸了打包页直接白屏;`com.android.webview` 同样必须保留 |
| **开机自启的前提** | 自启靠原生 `BootReceiver`(`BOOT_COMPLETED` / `QUICKBOOT_POWERON`)。**新装机或被 `force-stop` 后必须手动启动一次**(Android 3.1+ 规则);检查:`adb shell dumpsys package com.gztbyc.sandan \| grep 'User 0'` 需为 `stopped=false notLaunched=false` |
| **扫码枪身份** | USB HID 键盘(`Newtologic DW-8200`,VID_060E:PID_0960),挂在 `usb-1.4` → `/dev/input/event4`,供后续排查对照 |
| **散热** | 4 核满载实测 75℃(室温环境、无散热片);7×24 使用建议加散热片/小风扇,否则会热降频 |
| **网络** | 建议走网线(`eth0` 存在但默认无链路,先确认机器有没有 RJ45 口);WiFi 是 Broadcom SDIO,做常驻服务不稳 |
### 四、现场排查工具
| 工具 | 用途 |
|---|---|
| 诊断面板 | 打包页标题**3 秒内连点 5 次**(退件页为「拆包工作台」同操作):实时看按键到达 / 丢弃原因 / 门控快照 / 自愈次数,可复制与一键上报 |
| `scripts/scan-forensics.ps1` | 故障**当场**一键取证:内核按键流 + dmesg + App 心跳 + 自动判据(内核有事件而 App `keys=0` → 上层;内核无事件 → 枪/线/供电) |
| `scripts/power-probe.sh`、`scripts/power-load-test.sh` | 电源/负载对比实测(采样 ADC、温度、CPU 频率、扫码枪是否仍在总线) |
| logcat | `adb logcat -s WMSScan`(扫码链路)、`WMSPage`(页面生命周期)、`UniConsole` / `UniViewConsole`(JS 日志) |
> 日志上行已做降噪(2026-09-25):本地明细全部保留(面板 + logcat + 环形缓存),**只有异常才上报服务端**(主线程卡顿、真自愈、活动突然中断),正常扫码不再产生上行记录。
### 五、排查口诀
1. 先看诊断面板的 `按键到达`:**`keys=0` → 按键根本没到 JS**,转第 2 步;有 `keys` 但业务没生效 → 看 `丢弃统计` 的 reason(属 JS 门控,按 reason 定位)。
2. `keys=0` 时执行上面那条 `dmesg | grep -E 'USB disconnect|error -71'`:**有输出 → 供电 / USB 口外接耗电外设**(见本节一、二);无输出 → 枪 / 线材 / 系统扫码服务。
3. 长跑中「突然扫不上、重启才好」几乎都是第 2 步命中的供电类问题:先换电源、拔掉 USB 音响,再复核。

View File

@ -96,10 +96,6 @@ async function createWindow() {
const win = new BrowserWindow({ const win = new BrowserWindow({
width: 1200, width: 1200,
height: 800, height: 800,
// 全站按 1280 设计宽做 rem 缩放(<1280 等比缩、下限 640px 对应 0.5 倍),
// 窗口再窄就会出现横向溢出(页面 min-width 约 614px),故限制最小尺寸
minWidth: 1024,
minHeight: 640,
webPreferences: { webPreferences: {
preload: path.join(__dirname, 'preload.js'), preload: path.join(__dirname, 'preload.js'),
contextIsolation: true, contextIsolation: true,

12
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "wms-worker-station", "name": "wms-worker-station",
"version": "1.0.35", "version": "1.0.24",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "wms-worker-station", "name": "wms-worker-station",
"version": "1.0.35", "version": "1.0.24",
"devDependencies": { "devDependencies": {
"@dcloudio/types": "^3.4.8", "@dcloudio/types": "^3.4.8",
"@dcloudio/uni-app": "3.0.0-5000720260410001", "@dcloudio/uni-app": "3.0.0-5000720260410001",
@ -20,7 +20,6 @@
"electron": "^33.4.11", "electron": "^33.4.11",
"electron-builder": "^26.15.3", "electron-builder": "^26.15.3",
"jsbarcode": "^3.12.3", "jsbarcode": "^3.12.3",
"qrcode-generator": "^2.0.4",
"vite": "5.2.8", "vite": "5.2.8",
"vue": "^3.4.21", "vue": "^3.4.21",
"vue-i18n": "^9.1.9" "vue-i18n": "^9.1.9"
@ -8849,13 +8848,6 @@
"node": ">=16.0.0" "node": ">=16.0.0"
} }
}, },
"node_modules/qrcode-generator": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-2.0.4.tgz",
"integrity": "sha512-mZSiP6RnbHl4xL2Ap5HfkjLnmxfKcPWpWe/c+5XxCuetEenqmNFf1FH/ftXPCtFG5/TDobjsjz6sSNL0Sr8Z9g==",
"dev": true,
"license": "MIT"
},
"node_modules/qs": { "node_modules/qs": {
"version": "6.11.0", "version": "6.11.0",
"resolved": "https://mirrors.cloud.tencent.com/npm/qs/-/qs-6.11.0.tgz", "resolved": "https://mirrors.cloud.tencent.com/npm/qs/-/qs-6.11.0.tgz",

View File

@ -1,7 +1,7 @@
{ {
"name": "wms-worker-station", "name": "wms-worker-station",
"version": "1.0.40", "version": "1.0.34",
"description": "WMS仓库工作台(Android端 + 桌面端)", "description": "WMS仓库工作台桌面端",
"author": "tianbao", "author": "tianbao",
"main": "electron/main.js", "main": "electron/main.js",
"scripts": { "scripts": {
@ -15,7 +15,6 @@
"build:exe": "node scripts/build-exe.cjs", "build:exe": "node scripts/build-exe.cjs",
"build:apk": "node scripts/build-apk.cjs", "build:apk": "node scripts/build-apk.cjs",
"android:pack:raw": "powershell -NoProfile -ExecutionPolicy Bypass -File android-offline/pack.ps1", "android:pack:raw": "powershell -NoProfile -ExecutionPolicy Bypass -File android-offline/pack.ps1",
"lint:layout": "node scripts/check-layout.cjs",
"start:electron": "electron electron/main.js" "start:electron": "electron electron/main.js"
}, },
"devDependencies": { "devDependencies": {
@ -31,7 +30,6 @@
"electron": "^33.4.11", "electron": "^33.4.11",
"electron-builder": "^26.15.3", "electron-builder": "^26.15.3",
"jsbarcode": "^3.12.3", "jsbarcode": "^3.12.3",
"qrcode-generator": "^2.0.4",
"vite": "5.2.8", "vite": "5.2.8",
"vue": "^3.4.21", "vue": "^3.4.21",
"vue-i18n": "^9.1.9" "vue-i18n": "^9.1.9"

View File

@ -1,96 +0,0 @@
/**
* UI 排版规范自检(对应 README「UI 排版规范」)
*
* node scripts/check-layout.cjs # 或 npm run lint:layout
*
* 可机械检查的项:
* 1. rem 值最多 2 位小数
* 2. font-size 只能取 10 档刻度
* 3. border-radius 只能取 3 档(或 50% / px)
* 4. padding / margin / gap 取 0.05rem 的倍数;小于 0.05rem 的微内边距取 0.02rem 的倍数
* 5. 高频色值不能再写死(要写 var(--wms-*))
* 例外面板:src/components/scan-diag-panel.vue(整块 px 的诊断面板)与退件页摄像头浮窗(px),已在 README 说明。
* 退出码:发现不合规为 1,可直接用于 CI / 提交前钩子。
*/
const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
const SKIP_FILES = ['src/components/scan-diag-panel.vue']
const FONT_TIERS = [0.15, 0.17, 0.18, 0.2, 0.21, 0.22, 0.25, 0.3, 0.35, 0.45]
const RADIUS_TIERS = [0.03, 0.07, 0.13]
const SPACE_PROPS = /^(row-gap|column-gap|gap|padding|margin)(-(top|right|bottom|left))?$/
// 高频色 → 必须用 token(与 base.css 的 :root 对应)
const COLOR_TOKENS = {
'#2f7dff': '--wms-primary', '#409eff': '--wms-primary-alt',
'#67c23a': '--wms-success', '#2fbf71': '--wms-success-alt',
'#ff7d00': '--wms-warning', '#f56c6c': '--wms-danger', '#e64340': '--wms-danger-strong',
'#333': '--wms-text', '#333333': '--wms-text', '#303133': '--wms-text-strong',
'#666': '--wms-text-secondary', '#666666': '--wms-text-secondary',
'#606266': '--wms-text-tertiary', '#909399': '--wms-text-muted',
'#999': '--wms-text-placeholder', '#999999': '--wms-text-placeholder',
'#c0c4cc': '--wms-text-disabled', '#fff': '--wms-card-bg / --wms-white', '#ffffff': '--wms-card-bg / --wms-white',
'#f8f8f8': '--wms-page-bg', '#f5f7fa': '--wms-bg-subtle', '#eef5ff': '--wms-bg-tint',
'#dcdfe6': '--wms-border', '#d9dde8': '--wms-border-alt',
'#ebeef5': '--wms-border-light', '#d0d5e0': '--wms-border-strong'
}
function walk (dir, out = []) {
for (const e of fs.readdirSync(path.join(root, dir), { withFileTypes: true })) {
const rel = dir + '/' + e.name
if (e.isDirectory()) walk(rel, out)
else if (/\.(vue|css)$/.test(e.name)) out.push(rel)
}
return out
}
const isMultiple = (v, step) => Math.abs(v / step - Math.round(v / step)) < 1e-6
const problems = []
for (const rel of walk('src')) {
if (SKIP_FILES.includes(rel)) continue
const src = fs.readFileSync(path.join(root, rel), 'utf8')
const m = src.match(/<style[^>]*>([\s\S]*?)<\/style>/)
const css = (m ? m[1] : rel.endsWith('.css') ? src : '')
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/:root\s*\{[\s\S]*?\n\}/, '') // token 定义块不算使用
if (!css) continue
// 1. 小数位
for (const mm of css.matchAll(/([\d.]+)rem/g)) {
const dec = (mm[1].split('.')[1] || '').length
if (dec > 2) problems.push(`${rel}: rem 小数位超过 2 位 → ${mm[0]}`)
}
// 2. 字号
for (const mm of css.matchAll(/font-size:\s*([\d.]+)rem/g)) {
if (!FONT_TIERS.includes(Number(mm[1]))) problems.push(`${rel}: 字号不在 10 档内 → ${mm[0]}`)
}
// 3. 圆角
for (const mm of css.matchAll(/border-radius:\s*([^;{}]+)/g)) {
for (const v of mm[1].matchAll(/([\d.]+)rem/g)) {
if (!RADIUS_TIERS.includes(Number(v[1]))) problems.push(`${rel}: 圆角不在 3 档内 → border-radius: ${mm[1].trim()}`)
}
}
// 4. 间距
for (const mm of css.matchAll(/([-\w]+)\s*:\s*([^;{}]+)/g)) {
if (!SPACE_PROPS.test(mm[1])) continue
for (const v of mm[2].matchAll(/([\d.]+)rem/g)) {
const val = Number(v[1])
const ok = val >= 0.05 ? isMultiple(val, 0.05) : isMultiple(val, 0.02)
if (!ok) problems.push(`${rel}: 间距不在网格上 → ${mm[1]}: ${mm[2].trim()}`)
}
}
// 5. 高频色写死
for (const mm of css.matchAll(/#[0-9a-fA-F]{3,8}\b/g)) {
const token = COLOR_TOKENS[mm[0].toLowerCase()]
if (token) problems.push(`${rel}: 高频色应写 var(${token}) → ${mm[0]}`)
}
}
if (problems.length === 0) {
console.log('✅ 排版规范自检通过(字号 10 档 / 圆角 3 档 / 间距 5px 网格 / rem ≤2 位小数 / 颜色用 token)')
} else {
console.log('❌ 发现 ' + problems.length + ' 处不合规:')
for (const p of problems) console.log(' ' + p)
process.exitCode = 1
}

View File

@ -1,42 +0,0 @@
#!/system/bin/sh
# power-load-test.sh - put the X9R under a reproducible load while sampling the power picture.
#
# Load = screen brightness max + N CPU busy loops (+ whatever the app/scanner does concurrently).
# Sampling = SARADC channels / thermals / CPU freq / whether the USB scanner is still enumerated.
# The busy loops are killed at the end (never left running) and brightness is restored by the caller.
#
# usage: power-load-test.sh [seconds] [cpus] [outfile]
SECS=${1:-120}
CPUS=${2:-4}
OUT=${3:-/data/local/tmp/pwr_load.txt}
DEV=/sys/bus/iio/devices/iio:device0
PIDS=""
i=0
while [ "$i" -lt "$CPUS" ]; do
(while :; do :; done) &
PIDS="$PIDS $!"
i=$((i + 1))
done
: > "$OUT"
n=0
while [ "$n" -lt "$SECS" ]; do
u=$(cat /proc/uptime); u=${u%% *}
a0=$(cat $DEV/in_voltage0_raw 2>/dev/null)
a1=$(cat $DEV/in_voltage1_raw 2>/dev/null)
a2=$(cat $DEV/in_voltage2_raw 2>/dev/null)
t0=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null)
t1=$(cat /sys/class/thermal/thermal_zone1/temp 2>/dev/null)
f0=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null)
f3=$(cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq 2>/dev/null)
gun=$(grep -c Newtologic /proc/bus/input/devices 2>/dev/null)
echo "$u $a0 $a1 $a2 $t0 $t1 $f0 $f3 $gun" >> "$OUT"
n=$((n + 1))
sleep 0.5
done
for p in $PIDS; do kill -9 "$p" 2>/dev/null; done
sleep 1
echo "done $SECS samples -> $OUT"
echo "load pids killed:$PIDS"

View File

@ -1,30 +0,0 @@
#!/system/bin/sh
# power-probe.sh - sample the power picture on the RK3288 X9R (needs adb root)
#
# Why: on 2026-09-25 the field unit behaved badly on a 12V/2A adapter and fine on 12V/2.5A,
# which points at input brown-out. The OS has no "rated power" field and the RK818 driver
# reports 0mA for every rail, so the only usable telemetry is:
# - SARADC channels (ff100000.saradc, 10-bit, 1.7578125 mV/LSB)
# - SoC / GPU thermal
# - whether the USB scanner is still enumerated (brown-out can drop the HID device)
# Run it once on each adapter and compare (min/max/mean + gun=0 count).
#
# usage: pwr_sample.sh [samples] [outfile] (0.5 s per sample)
N=${1:-120}
OUT=${2:-/data/local/tmp/pwr_sample.txt}
DEV=/sys/bus/iio/devices/iio:device0
i=0
: > "$OUT"
while [ "$i" -lt "$N" ]; do
u=$(cat /proc/uptime); u=${u%% *}
a0=$(cat $DEV/in_voltage0_raw 2>/dev/null)
a1=$(cat $DEV/in_voltage1_raw 2>/dev/null)
a2=$(cat $DEV/in_voltage2_raw 2>/dev/null)
t0=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null)
t1=$(cat /sys/class/thermal/thermal_zone1/temp 2>/dev/null)
gun=$(grep -c Newtologic /proc/bus/input/devices 2>/dev/null)
echo "$u $a0 $a1 $a2 $t0 $t1 $gun" >> "$OUT"
i=$((i + 1))
sleep 0.5
done
echo "done $N samples -> $OUT"

View File

@ -1,120 +0,0 @@
# scan-forensics.ps1
# One-shot evidence capture for the "scanner stops working" fault (WMS X9R tablet).
#
# Why: on 2026-09-25 the field log proved the break is BELOW the JS layer
# (60s heartbeat keys=0 while every JS gate was green). The only thing JS cannot see is
# whether the kernel/Activity still gets the key events. This script captures that layer.
#
# Usage (tablet plugged in, USB debugging on):
# powershell -NoProfile -ExecutionPolicy Bypass -File scripts\scan-forensics.ps1
# powershell -NoProfile -ExecutionPolicy Bypass -File scripts\scan-forensics.ps1 -Seconds 30
#
# Run it WHILE the fault is present, and scan the gun 3-5 times during the capture window.
# Everything is kept (no cleanup) under -OutDir.
#
# Verdict rules:
# kernel key DOWN > 0 but app heartbeat keys=0 -> Android dispatch / WebView / IME layer
# kernel key DOWN = 0 -> gun / cable / USB port (hardware) or scan service
#
# ASCII only on purpose: `powershell -File` reads non-ASCII scripts as ANSI on this machine.
param(
[int]$Seconds = 20,
[string]$OutDir = ''
)
$ErrorActionPreference = 'Continue'
function Find-Adb {
$candidates = @(
(Join-Path $env:LOCALAPPDATA 'Android\Sdk\platform-tools\adb.exe'),
'C:\Android\Sdk\platform-tools\adb.exe',
'D:\Android\Sdk\platform-tools\adb.exe'
)
foreach ($c in $candidates) {
if (Test-Path $c) { return $c }
}
$cmd = Get-Command adb -ErrorAction SilentlyContinue
if ($cmd) { return $cmd.Source }
throw 'adb.exe not found. Set PATH or edit Find-Adb in this script.'
}
if (-not $OutDir) {
$OutDir = Join-Path $env:TEMP ('scan-forensics\' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
}
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
$adb = Find-Adb
Write-Host "adb = $adb"
Write-Host "out dir = $OutDir"
Write-Host ''
function Sh($cmd) { & $adb shell $cmd 2>&1 }
function Save($name, $lines) {
$path = Join-Path $OutDir $name
$lines | Out-File -FilePath $path -Encoding utf8
Write-Host (" saved {0}" -f $name)
}
# 1) device present?
$devices = & $adb devices 2>&1
$serial = ($devices | Select-String -Pattern '^\S+\s+device$' | ForEach-Object { $_.Line.Split()[0] }) | Select-Object -First 1
if (-not $serial) {
Write-Host '!! no adb device. Check: USB debugging on, try another USB port (this box only works on some ports), replug.' -ForegroundColor Red
Write-Host ($devices -join "`n")
exit 2
}
Write-Host "device = $serial"
& $adb root 2>&1 | Out-Null
& $adb wait-for-device 2>&1 | Out-Null
# 2) static environment
Save '00-device.txt' @(
"serial = $serial",
"captured = $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
"id = $(Sh 'id')",
"model = $(Sh 'getprop ro.product.model')",
"android = $(Sh 'getprop ro.build.version.release') build=$(Sh 'getprop ro.build.type') selinux=$(Sh 'getenforce')",
"uptime = $(Sh 'cat /proc/uptime') (seconds since boot - tells whether a reboot just happened)",
"pkg = $(Sh 'dumpsys window | grep -E ''mCurrentFocus|mFocusedApp''')"
)
Save '01-input-devices.txt' (Sh 'cat /proc/bus/input/devices')
Save '02-dmesg-usb-input.txt' (Sh "dmesg | grep -iE 'usb|newtologic|hid|input:' | tail -n 120")
Save '03-app-logcat.txt' (Sh "logcat -d -s WMSScan:V WMSPage:V UniConsole:V UniViewConsole:V | tail -n 400")
Save '04-dumpsys-input.txt' (Sh 'dumpsys input | head -n 250')
# 3) kernel key stream (scan now!)
$gevPath = Join-Path $OutDir '05-getevent.txt'
Write-Host ''
Write-Host ("==> SCAN THE GUN 3-5 TIMES NOW (you have {0} seconds) <==" -f $Seconds) -ForegroundColor Yellow
& $adb shell "timeout $Seconds getevent -lt" 2>&1 | Out-File -FilePath $gevPath -Encoding utf8
Write-Host (" saved 05-getevent.txt")
# 4) verdict
$gev = Get-Content $gevPath -ErrorAction SilentlyContinue
$keyDown = @($gev | Select-String -Pattern 'EV_KEY\s+(KEY_[0-9A-Z_]+)\s+DOWN' -AllMatches)
$enterDown = @($gev | Select-String -Pattern 'EV_KEY\s+KEY_ENTER\s+DOWN')
$gunLines = @($gev | Select-String -Pattern 'event\d+.*EV_KEY')
$logcat = Get-Content (Join-Path $OutDir '03-app-logcat.txt') -ErrorAction SilentlyContinue
$health = @($logcat | Select-String -Pattern 'health.*keys=' | Select-Object -Last 1)
Write-Host ''
Write-Host '================ VERDICT ================'
Write-Host ("kernel : key DOWN events = {0} (ENTER = {1})" -f $keyDown.Count, $enterDown.Count)
Write-Host (" gun/kernel EV_KEY lines = {0}" -f $gunLines.Count)
if ($health.Count -gt 0) {
Write-Host ("app : last heartbeat -> {0}" -f $health[0].Line.Trim())
} else {
Write-Host 'app : no WMSScan heartbeat in logcat buffer (buffer may have wrapped)'
}
Write-Host ''
if ($keyDown.Count -ge 3) {
Write-Host 'kernel HAS key events -> the break is ABOVE the kernel (Android dispatch / WebView / IME / app).' -ForegroundColor Green
Write-Host ' Next: compare with the app heartbeat keys= above. keys=0 here means the app never got them.'
} else {
Write-Host 'kernel has NO (or almost no) key events -> gun / cable / USB port / scan service (hardware).' -ForegroundColor Red
Write-Host ' Next: swap cable+port, watch dmesg in 02-dmesg-usb-input.txt for disconnect/reconnect.'
}
Write-Host ''
Write-Host 'Keep this folder for the vendor/customer report. Nothing was deleted.'

View File

@ -1,10 +1,14 @@
<script> <script>
import { guardCurrentPage } from './core/nav-guard' import { guardCurrentPage } from './core/nav-guard'
import { flushClientErrorReport } from './core/error-report' import { flushClientErrorReport } from './core/error-report'
// rem 基准统一走 render-common/rem-base.js:底座 100 × 缩放 1 = 满格 100px(宽度 ≥1280 一律 100px), // rem 基准:以 1920×1280 设计稿为准,100px = 1rem,按宽高取小(contain)缩放
// 缩放默认 1(只缩不放、只看宽度):窄于 1280 才按比例缩小,大屏/矮窗口只做布局变更 const DESIGN_WIDTH = 1920
// 真机 APP-PLUS 的 rem 由下方全局纯 CSS 承担(7.8125vw = 100/1280;框架会以内联样式锁死 html font-size,故用 !important 覆盖),JS 仅 H5 参与计算 const DESIGN_HEIGHT = 1280
import { applyRemBase } from './render-common/rem-base.js' const BASE_FONT_SIZE = 100
// 整体缩放系数:<1 整体缩小,>1 整体放大(布局偏大就调小这个值)
// 0.45 平板触摸尺寸基准偏大;桌面 H5/Electron(1920×1080)统一调整为 0.42(0.28 基础上整体放大 50%)
// 真机 APP-PLUS 的 rem 由下方全局纯 CSS 承担(2.5vw,框架锁死 16px 基础上整体放大 50% → 24px),JS 仅 H5 参与计算
const REM_SCALE = 0.42
// #ifdef APP-PLUS // #ifdef APP-PLUS
// 打开应用后将系统音量调至最大(仓库环境语音播报需要;setStreamVolume 无需额外权限) // 打开应用后将系统音量调至最大(仓库环境语音播报需要;setStreamVolume 无需额外权限)
@ -69,10 +73,11 @@ function setRemBase () {
// #ifdef H5 // #ifdef H5
if (typeof document !== 'undefined' && document.documentElement) { if (typeof document !== 'undefined' && document.documentElement) {
const docEl = document.documentElement const docEl = document.documentElement
const width = docEl.clientWidth const width = docEl.clientWidth || window.innerWidth || DESIGN_WIDTH
const height = docEl.clientHeight const height = docEl.clientHeight || window.innerHeight || DESIGN_HEIGHT
// 基准计算与写入集中在 render-common/rem-base.js,与各页面 renderjs 共用同一套基准 const scale = Math.min(width / DESIGN_WIDTH, height / DESIGN_HEIGHT)
applyRemBase() docEl.style.fontSize = (scale * BASE_FONT_SIZE * REM_SCALE) + 'px'
console.log('[rem] html fontSize =', docEl.style.fontSize, 'width =', width, 'height =', height, 'scale =', scale)
console.log('[screen-h5] screenWidth =', window.screen.width, 'screenHeight =', window.screen.height, console.log('[screen-h5] screenWidth =', window.screen.width, 'screenHeight =', window.screen.height,
'availWidth =', window.screen.availWidth, 'availHeight =', window.screen.availHeight, 'availWidth =', window.screen.availWidth, 'availHeight =', window.screen.availHeight,
'devicePixelRatio =', window.devicePixelRatio) 'devicePixelRatio =', window.devicePixelRatio)
@ -110,17 +115,12 @@ export default {
</script> </script>
<style> <style>
/* 全局基准样式全在 src/styles/base.css(设计 token / 元素重置 / 页面骨架 .page、.page-main / /*每个页面公共css */
公共工具类 .scan-hidden-input / H5 组件库修正),页面只写自己的个性化差异 */ /* rem 基准:设计稿 1920×1280,100px = 1rem(min(w/1920, h/1280) × 100)
@import './styles/base.css'; H5/Electron:由 setRemBase()(JS,REM_SCALE=0.42)以内联样式运行时计算,此处仅首帧兜底;
/* 本文件只保留 rem 基准相关的全局规则(与 render-common/rem-base.js 强绑定,且含条件编译) */
/* rem 基准:底座 100 × 缩放 1 = 满格 100px(宽度 ≥1280 一律 100px,窄于 1280 按比例缩,下限 50px)
H5/Electron:由 render-common/rem-base.js 的 applyRemBase() 以内联样式运行时计算,
此处仅首帧兜底,数值与 JS 一致(7.8125vw = 100/1280,50px = 缩放下限 0.5);
真机 APP-PLUS:由下方 #ifdef APP-PLUS 的 !important 规则承担(见下) */ 真机 APP-PLUS:由下方 #ifdef APP-PLUS 的 !important 规则承担(见下) */
html { html {
font-size: clamp(50px, 7.8125vw, 100px); font-size: min(5.2734375vw, 7.91015625vh);
} }
/* #ifdef APP-PLUS */ /* #ifdef APP-PLUS */
@ -128,13 +128,27 @@ html {
窗口宽度/23.4375;真机 innerWidth=961 刚好超过框架 rpxCalcMaxDeviceWidth=960 → 窗口宽度/23.4375;真机 innerWidth=961 刚好超过框架 rpxCalcMaxDeviceWidth=960 →
走 base 375 → 16px。内联样式优先级高于普通样式表,故上面的 CSS 对真机无效。 走 base 375 → 16px。内联样式优先级高于普通样式表,故上面的 CSS 对真机无效。
用 !important 让样式表反超非 important 的内联样式。 用 !important 让样式表反超非 important 的内联样式。
目标:与 H5 公式同一结果(7.8125vw = 100/1280,平板 960 宽 → 75px); 目标:在框架锁死的 16px 基础上整体放大 50% → 24px = 2.5vw。
老 WebView 可能不支持 CSS min(),真机恒为 960 宽(宽度就是瓶颈),故直接用 vw。 */ 横屏锁定 960×640(3:2) 与设计稿 1920×1280(3:2) 同比例,vw 与 min(vw,vh) 等价;
老 WebView 可能不支持 CSS min(),故直接用 vw。 */
html { html {
font-size: 7.8125vw !important; font-size: 2.5vw !important;
} }
/* #endif */ /* #endif */
/* 原先放在这里的 H5/Electron picker 样式修正(下拉宽度/选项居左)已移入 /* H5/Electron 下 picker 下拉弹窗宽度与触发下拉框一致(高特异性覆盖库默认 300px),阴影调淡 */
src/styles/base.css 第 5 节「H5/Electron 组件库修正」 */ uni-picker .uni-picker-container .uni-picker-custom,
.uni-picker-container .uni-picker-custom.uni-picker-custom {
width: 6.656rem !important;
box-shadow: 0 0 0.4rem 0.1rem rgba(0, 0, 0, 0.1) !important;
}
/* H5/Electron 下 picker 下拉选项居左显示(覆盖库默认居中 text-align:center) */
uni-picker .uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
.uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
uni-picker .uni-picker-container .uni-picker-view-content .uni-picker-item,
.uni-picker-container .uni-picker-view-content .uni-picker-item {
text-align: left;
padding-left: 0.512rem;
}
</style> </style>

View File

@ -434,22 +434,18 @@ export default {
<style scoped> <style scoped>
.top-nav { .top-nav {
width: 100%; width: 100%;
/* 高度 0.7rem = 70px:内行 50px(由行内最高的 logo 决定)+ 上下内边距各 0.1rem */ margin-bottom: 0.614rem;
height: 0.7rem; padding: 0.461rem 0.717rem;
margin-bottom: 0.2rem;
/* 水平内边距 = --wms-page-pad(25px):与所有页面的主体内容左右对齐 */
padding: 0.1rem var(--wms-page-pad);
box-sizing: border-box; box-sizing: border-box;
background-color: var(--wms-primary); background-color: #2f7dff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.top-nav-logo { .top-nav-logo {
/* 内行高基准:0.5rem = 50px(用户指定,行内最高元素就是它);宽度按原宽高比折半 */ width: 6.144rem;
width: 1.33rem; height: 2.304rem;
height: 0.5rem;
flex-shrink: 0; flex-shrink: 0;
} }
@ -461,14 +457,14 @@ export default {
.top-nav-menu-wrap { .top-nav-menu-wrap {
display: flex; display: flex;
align-items: center; align-items: center;
margin-left: 0.3rem; margin-left: 0.922rem;
gap: 0.1rem; gap: 0.358rem;
min-width: 0; min-width: 0;
} }
.top-nav-menu-item { .top-nav-menu-item {
padding: 0.1rem 0.15rem; padding: 0.256rem 0.461rem;
border-radius: 0.07rem; border-radius: 0.205rem;
} }
.top-nav-menu-item--active { .top-nav-menu-item--active {
@ -476,75 +472,75 @@ export default {
} }
.top-nav-menu-text { .top-nav-menu-text {
font-size: 0.22rem; font-size: 0.819rem;
color: var(--wms-white); color: #fff;
font-weight: 500; font-weight: 500;
} }
.top-nav-user { .top-nav-user {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.1rem; gap: 0.256rem;
cursor: pointer; cursor: pointer;
} }
.top-nav-user-name { .top-nav-user-name {
color: var(--wms-white); color: #fff;
font-size: 0.22rem; font-size: 0.819rem;
line-height: 1; line-height: 1;
} }
.top-nav-mine-icon { .top-nav-mine-icon {
width: 0.36rem; width: 1.126rem;
height: 0.36rem; height: 1.126rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 50%; border-radius: 25.574rem;
background-color: rgba(255, 255, 255, 0.2); background-color: rgba(255, 255, 255, 0.2);
box-sizing: border-box; box-sizing: border-box;
} }
.top-nav-mine-icon-head { .top-nav-mine-icon-head {
width: 0.1rem; width: 0.307rem;
height: 0.1rem; height: 0.307rem;
border: 0.02rem solid var(--wms-white); border: 0.051rem solid #fff;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
} }
.top-nav-mine-icon-body { .top-nav-mine-icon-body {
width: 0.16rem; width: 0.512rem;
height: 0.08rem; height: 0.256rem;
margin-top: 0.04rem; margin-top: 0.102rem;
border: 0.02rem solid var(--wms-white); border: 0.051rem solid #fff;
border-top: none; border-top: none;
border-radius: 0 0 0.13rem 0.13rem; border-radius: 0 0 0.307rem 0.307rem;
box-sizing: border-box; box-sizing: border-box;
} }
.popup-card { .popup-card {
position: absolute; position: absolute;
right: 0; right: 0;
top: 0.57rem; top: 1.792rem;
min-width: 2.7rem; min-width: 8.448rem;
background: var(--wms-card-bg); background: #fff;
border-radius: 0.13rem; border-radius: 0.307rem;
box-shadow: 0 0.1rem 0.26rem rgba(0, 0, 0, 0.16); box-shadow: 0 0.307rem 0.819rem rgba(0, 0, 0, 0.16);
padding: 0.15rem; padding: 0.41rem;
box-sizing: border-box; box-sizing: border-box;
z-index: 30; z-index: 30;
} }
.popup-user-info { .popup-user-info {
max-height: 2.62rem; max-height: 8.192rem;
overflow-y: auto; overflow-y: auto;
} }
.popup-user-item { .popup-user-item {
padding: 0.1rem; padding: 0.307rem;
border-radius: 0.07rem; border-radius: 0.205rem;
} }
.popup-user-item--current { .popup-user-item--current {
@ -552,28 +548,28 @@ export default {
} }
.popup-user-text { .popup-user-text {
font-size: 0.2rem; font-size: 0.717rem;
color: var(--wms-text); color: #333;
} }
.popup-user-item--current .popup-user-text { .popup-user-item--current .popup-user-text {
color: var(--wms-primary); color: #2f7dff;
} }
.logout-btn { .logout-btn {
margin-top: 0.15rem; margin-top: 0.41rem;
height: 0.36rem; /* 控件 36px */ height: 1.536rem;
line-height: 0.36rem; line-height: 1.536rem;
font-size: 0.2rem; font-size: 0.717rem;
} }
.close-btn { .close-btn {
margin-top: 0.1rem; margin-top: 0.256rem;
height: 0.36rem; /* 控件 36px */ height: 1.536rem;
line-height: 0.36rem; line-height: 1.536rem;
font-size: 0.2rem; font-size: 0.717rem;
background-color: #f5f7fb; background-color: #f5f7fb;
color: var(--wms-text); color: #333;
} }
.switch-mask { .switch-mask {
@ -582,7 +578,7 @@ export default {
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: var(--wms-page-bg); background-color: #f8f8f8;
z-index: 9999; z-index: 9999;
pointer-events: none; pointer-events: none;
opacity: 0; opacity: 0;

View File

@ -8,10 +8,7 @@
* 上报内容: * 上报内容:
* 1. 运行时错误:Vue 渲染/生命周期异常、window error/unhandledrejection、uni 未处理 Promise; * 1. 运行时错误:Vue 渲染/生命周期异常、window error/unhandledrejection、uni 未处理 Promise;
* 2. 扫码链路异常(由 scan-diag 通过 setDiagSink 外送): * 2. 扫码链路异常(由 scan-diag 通过 setDiagSink 外送):
* scan-stall(主线程卡顿)/ scan-heal(真自愈)/ scan-drop(扫码被丢弃,带收到的码) * scan-stall(主线程卡顿)/ scan-heal(自愈动作)/ scan-drop(扫码被丢弃,带收到的码);
* / scan-health(异常触发的健康快照,带 trigger 标明是卡顿、真自愈还是“活动突然中断”);
* 注:设计内的正常自愈(scan-diag 的 QUIET_HEAL_REASONS,如每次扫码都会发生的锁重置)
* 在 scan-diag 一侧就被拦下,不会进到这里(2026-09-25 上行降噪);
* 3. 现场手动上报(诊断面板「上报」按钮):scan-manual,带完整精简快照。 * 3. 现场手动上报(诊断面板「上报」按钮):scan-manual,带完整精简快照。
* *
* 设计约束(务必保持): * 设计约束(务必保持):

View File

@ -8,10 +8,6 @@
* 2. 真机同步写 logcat(tag: WMSScan),release 包也能 `adb logcat -s WMSScan` 事后追踪。 * 2. 真机同步写 logcat(tag: WMSScan),release 包也能 `adb logcat -s WMSScan` 事后追踪。
* 3. 60 秒健康心跳:记录区间内按键数 / 丢弃增量 / 门控快照, * 3. 60 秒健康心跳:记录区间内按键数 / 丢弃增量 / 门控快照,
* 可精确定位「哪一分钟开始收不到按键」以及当时的门控状态。 * 可精确定位「哪一分钟开始收不到按键」以及当时的门控状态。
* 4. 上行降噪(2026-09-25 用户要求):本地日志保留全部事实,**外送服务端只保留异常** ——
* 设计内的正常自愈(QUIET_HEAL_REASONS,如每次扫码都会发生的锁重置)不上行;
* 健康快照由「每 10 分钟定时」改成「出现异常才外送(最短 30 分钟间隔)」。
* 诊断面板 / logcat / 本地环形日志不受影响,仍是完整证据链。
* *
* 约定:本模块只做记录,不做任何业务决策,任何异常都不得向上抛。 * 约定:本模块只做记录,不做任何业务决策,任何异常都不得向上抛。
*/ */
@ -38,13 +34,8 @@ const KEY_RESUME_GAP_MS = 60 * 1000
const KEY_BURST_GAP_MS = 500 const KEY_BURST_GAP_MS = 500
// 心跳定时器迟到判定:实际间隔 > 设定周期 * 该倍数 → 主线程被卡住 // 心跳定时器迟到判定:实际间隔 > 设定周期 * 该倍数 → 主线程被卡住
const STALL_FACTOR = 2.5 const STALL_FACTOR = 2.5
// 服务端健康快照的**最短间隔**:正常运行时基本不上行,只有区间内出现异常才带快照外送 // 服务端健康快照间隔:服务端拿到连续轨迹,而不只是异常点
// (异常判据见 diagHeartbeat:主线程卡顿 / 真自愈 / “上一区间还在扫、这一区间一个键都没到”) const REPORT_HEALTH_INTERVAL_MS = 10 * 60 * 1000
const REPORT_HEALTH_INTERVAL_MS = 30 * 60 * 1000
// 属于“设计内正常行为”的自愈原因:只写本地日志/logcat,不作为异常外送服务端。
// event-type-lock-idle-reset 每次扫码都会发生(空闲 1.2s 后重置事件类型锁),
// 上报只会给服务端刷噪音并掩盖真正的自愈记录。
const QUIET_HEAL_REASONS = ['event-type-lock-idle-reset']
const state = { const state = {
scope: 'unknown', scope: 'unknown',
@ -60,10 +51,6 @@ const state = {
healthKeys: 0, healthKeys: 0,
healthDrops: 0, healthDrops: 0,
healthHeals: 0, healthHeals: 0,
reportedHeals: 0, // 真正外送服务端的自愈次数(不含 QUIET_HEAL_REASONS)
healthReportStalls: 0, // 上次外送快照时的 stallCount
healthReportHeals: 0, // 上次外送快照时的 reportedHeals
lastIntervalKeys: 0, // 上一个 60s 心跳区间的按键数(判断“活动突然中断”)
dropLoggedAt: {}, dropLoggedAt: {},
lastTickAt: 0, lastTickAt: 0,
maxTickGapMs: 0, maxTickGapMs: 0,
@ -399,12 +386,6 @@ export function diagFlush(info) {
export function diagHeal(reason, data) { export function diagHeal(reason, data) {
state.counters.heals += 1 state.counters.heals += 1
push('heal', `reason=${reason} count=${state.counters.heals}`, data) push('heal', `reason=${reason} count=${state.counters.heals}`, data)
// 设计内的正常自愈(如每次扫码都会发生的锁重置)只留本地日志/logcat,
// 外送服务端只保留“真的把链路救回来”的那些,避免正常行为刷满上报库
if (QUIET_HEAL_REASONS.indexOf(String(reason || '')) >= 0) {
return
}
state.reportedHeals += 1
emitSink('heal', { reason, data }) emitSink('heal', { reason, data })
} }
@ -487,34 +468,18 @@ export function diagHeartbeat(options) {
`最近按键=${idleAgo} tick=${tickGap || intervalMs}ms 最大tick=${state.maxTickGapMs}ms 卡顿=${state.stallCount}`, `最近按键=${idleAgo} tick=${tickGap || intervalMs}ms 最大tick=${state.maxTickGapMs}ms 卡顿=${state.stallCount}`,
state.gates state.gates
) )
// 服务端健康快照(降噪后):正常运行时不上行,只有区间内出现“值得事后追查”的异常才带快照外送: // 服务端健康快照:本会话确实收到过按键后,每 10 分钟外送一次,
// ① 主线程卡顿(stall);② 真自愈(非 QUIET_HEAL_REASONS);③ 活动突然中断 // 这样"某一刻开始收不到按键"即使无人上报也能在服务端看出来(轨迹而不是只有异常点)
// (上一区间还在扫、本区间一个键都没到,且页面在用/未暂停——正是现场“扫不上”的形态)。
// 最短间隔 REPORT_HEALTH_INTERVAL_MS,避免异常持续时刷屏。
if (state.counters.keys > 0 && now - state.lastHealthReportAt >= REPORT_HEALTH_INTERVAL_MS) { if (state.counters.keys > 0 && now - state.lastHealthReportAt >= REPORT_HEALTH_INTERVAL_MS) {
const stallDelta = state.stallCount - state.healthReportStalls
const healDelta = state.reportedHeals - state.healthReportHeals
const activityStopped =
keys === 0 &&
state.lastIntervalKeys > 0 &&
state.gates.pageActive !== false &&
state.gates.paused !== true
if (stallDelta > 0 || healDelta > 0 || activityStopped) {
const keysSinceReport = state.counters.keys - state.healthReportKeys const keysSinceReport = state.counters.keys - state.healthReportKeys
state.lastHealthReportAt = now state.lastHealthReportAt = now
state.healthReportKeys = state.counters.keys state.healthReportKeys = state.counters.keys
state.healthReportStalls = state.stallCount
state.healthReportHeals = state.reportedHeals
emitSink('health', { emitSink('health', {
trigger: stallDelta > 0 ? 'stall' : healDelta > 0 ? 'heal' : 'activity-stop',
stallDelta,
healDelta,
keysSinceReport, keysSinceReport,
keysTotal: state.counters.keys, keysTotal: state.counters.keys,
flushes: state.counters.flushes, flushes: state.counters.flushes,
drops: state.counters.drops, drops: state.counters.drops,
heals: state.counters.heals, heals: state.counters.heals,
reportedHeals: state.reportedHeals,
lastKeyAgoMs: state.lastKeyAt ? now - state.lastKeyAt : null, lastKeyAgoMs: state.lastKeyAt ? now - state.lastKeyAt : null,
stallCount: state.stallCount, stallCount: state.stallCount,
maxTickGapMs: state.maxTickGapMs, maxTickGapMs: state.maxTickGapMs,
@ -523,9 +488,6 @@ export function diagHeartbeat(options) {
}) })
} }
} }
// 记住本区间的按键数,下一次心跳用它判断“活动是否突然中断”
state.lastIntervalKeys = keys
}
/** 立即落盘(页面 onHide/onUnload 时调用,避免节流窗口内丢日志) */ /** 立即落盘(页面 onHide/onUnload 时调用,避免节流窗口内丢日志) */
export function diagPersistNow() { export function diagPersistNow() {
@ -620,10 +582,6 @@ export function diagClear() {
state.healthDrops = 0 state.healthDrops = 0
state.healthHeals = 0 state.healthHeals = 0
state.lastHealthAt = 0 state.lastHealthAt = 0
state.reportedHeals = 0
state.healthReportStalls = state.stallCount
state.healthReportHeals = 0
state.lastIntervalKeys = 0
state.dropLoggedAt = {} state.dropLoggedAt = {}
push('note', 'log-cleared') push('note', 'log-cleared')
diagPersistNow() diagPersistNow()

View File

@ -1,7 +1,7 @@
{ {
"name" : "WMS工作台", "name" : "WMS工作台",
"appid" : "__UNI__900BDC1", "appid" : "__UNI__900BDC1",
"description" : "WMS仓库工作台(Android端 + 桌面端)", "description" : "",
"versionName" : "1.0.1", "versionName" : "1.0.1",
"versionCode" : "101", "versionCode" : "101",
"transformPx" : false, "transformPx" : false,

View File

@ -44,7 +44,7 @@
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "wms_worker_station", "navigationBarTitleText": "wms_worker_station",
"navigationBarBackgroundColor": "#E8EAED", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#E8EAED" "backgroundColor": "#F8F8F8"
} }
} }

View File

@ -231,21 +231,26 @@ export default {
</script> </script>
<script module="remInject" lang="renderjs"> <script module="remInject" lang="renderjs">
import { applyRemBase } from '../../render-common/rem-base.js'
export default { export default {
mounted() { mounted() {
// #ifndef APP-PLUS // #ifdef APP-PLUS
// rem 基准统一走 render-common/rem-base.js(满格 1rem = 100px,>1280 宽不再放大字体), // 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// 字号偏大靠改 CSS 的 font-size 值(已全局 ×0.85),不动基准 // renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
// 各页面不再各算一份,避免系数漂移(历史上 returns 页曾写成 0.20,与其他页相差 2.1 倍) return
// 真机(APP-PLUS)rem 由 App.vue 全局纯 CSS(html { font-size: 7.8125vw !important }=100/1280)承担。
// ⚠️ 这里用 #ifndef,不要写成 `#ifdef APP-PLUS + return`:后者会让 esbuild 报
// “semicolon-after-return”,且以后往 mounted 里补的视图层代码会变成真机永不执行。
this._remResizeHandler = applyRemBase
applyRemBase()
window.addEventListener('resize', this._remResizeHandler)
// #endif // #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920
const height = docEl.clientHeight || window.innerHeight || 1280
const scale = Math.min(width / 1920, height / 1280)
docEl.style.fontSize = (scale * 100 * REM_SCALE) + 'px'
console.log('[rem-renderjs] fontSize =', docEl.style.fontSize, 'width =', width, 'height =', height, 'scale =', scale, 'REM_SCALE =', REM_SCALE, 'dpr =', window.devicePixelRatio)
}
this._remResizeHandler = setFontSize
setFontSize()
window.addEventListener('resize', setFontSize)
}, },
beforeDestroy() { beforeDestroy() {
if (this._remResizeHandler) { if (this._remResizeHandler) {
@ -260,14 +265,14 @@ export default {
height: 100vh; height: 100vh;
min-height: 100vh; min-height: 100vh;
overflow: hidden; overflow: hidden;
min-width: 6.14rem; min-width: 19.2rem;
box-sizing: border-box; box-sizing: border-box;
padding: 0; padding: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: stretch; align-items: stretch;
justify-content: flex-start; justify-content: flex-start;
background-color: var(--wms-page-bg); background-color: #f8f8f8;
} }
.layout-main { .layout-main {
@ -280,21 +285,31 @@ export default {
} }
.module-placeholder { .module-placeholder {
background-color: var(--wms-card-bg); background-color: #fff;
border-radius: 0.13rem; border-radius: 0.41rem;
padding: 0.25rem; padding: 0.717rem;
} }
.module-placeholder-title { .module-placeholder-title {
display: block; display: block;
font-size: 0.21rem; font-size: 0.768rem;
color: var(--wms-text); color: #333;
} }
.module-placeholder-desc { .module-placeholder-desc {
display: block; display: block;
margin-top: 0.1rem; margin-top: 0.256rem;
font-size: 0.17rem; font-size: 0.614rem;
color: var(--wms-text-placeholder); color: #999;
}
@media screen and (max-width: 20.48rem) {
.layout-page {
min-width: 15.2rem;
}
.layout-main {
padding: 0 0.512rem 0.205rem;
}
} }
</style> </style>

View File

@ -32,8 +32,13 @@
<view v-show="loginMode === 'scan'" class="panel panel--scan panel--mode"> <view v-show="loginMode === 'scan'" class="panel panel--scan panel--mode">
<text class="scan-tip-top">打开微信,扫描二维码登录</text> <text class="scan-tip-top">打开微信,扫描二维码登录</text>
<view class="scan-box"> <view class="scan-box">
<!-- 二维码由视图层本地绘制(qr-render.js):data-qr-text 是二维码内容,不是图片地址 --> <image
<view v-if="scanQrText" class="scan-image" :data-qr-text="scanQrText"></view> v-if="scanQrImage"
class="scan-image"
:src="scanQrImage"
mode="aspectFit"
@error="handleScanImageError"
></image>
<text v-else class="scan-placeholder">{{ scanCode || '二维码区域' }}</text> <text v-else class="scan-placeholder">{{ scanCode || '二维码区域' }}</text>
</view> </view>
<text class="scan-tip-bottom">{{ scanStatus }}</text> <text class="scan-tip-bottom">{{ scanStatus }}</text>
@ -93,9 +98,14 @@
<block v-else> <block v-else>
<text class="scan-tip-top">工作台尚未绑定,请在PDA使用绑定工作台界面扫码绑定</text> <text class="scan-tip-top">工作台尚未绑定,请在PDA使用绑定工作台界面扫码绑定</text>
<view class="scan-box"> <view class="scan-box">
<!-- 绑定码二维码由视图层本地绘制(qr-render.js):内容即绑定码本身 --> <image
<view v-if="workbenchBindCode" class="scan-image" :data-qr-text="workbenchBindCode"></view> v-if="workbenchQrImage"
<text v-else class="scan-placeholder">绑定码生成中...</text> class="scan-image"
:src="workbenchQrImage"
mode="aspectFit"
@error="handleWorkbenchQrError"
></image>
<text v-else class="scan-placeholder">{{ workbenchBindCode || '绑定码生成中...' }}</text>
</view> </view>
<!-- 绑定码文本:二维码扫不出/需人工输入时直接读这里(与二维码内容为同一个码) --> <!-- 绑定码文本:二维码扫不出/需人工输入时直接读这里(与二维码内容为同一个码) -->
<view class="wb-code-box"> <view class="wb-code-box">
@ -172,8 +182,8 @@ import {
} from '@/core/scan' } from '@/core/scan'
import { diagBegin, diagDrop, diagNote, diagPersistNow } from '@/core/scan-diag' import { diagBegin, diagDrop, diagNote, diagPersistNow } from '@/core/scan-diag'
// 二维码内容(不是图片地址):登录码 = 小程序页面链接,工作台码 = 绑定码。 const qrBaseUrl = 'https://ye4s.wms.gztbyc.com/grcode/build?text='
// 图片改由视图层本地绘制(src/render-common/qr-render.js),不再依赖远程出图服务。 const qrFallbackBaseUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=280x280&data='
const loginLinkTemplate = 'https://ye4s.wms.gztbyc.com/mini/?spm=0.4.${code}.1.4' const loginLinkTemplate = 'https://ye4s.wms.gztbyc.com/mini/?spm=0.4.${code}.1.4'
// Android KeyEvent 符号键映射(KEYCODE_* → 字符)。 // Android KeyEvent 符号键映射(KEYCODE_* → 字符)。
// 这些 keyCode 与 ASCII 字母/数字区间重叠,必须优先于 ASCII 分支判断, // 这些 keyCode 与 ASCII 字母/数字区间重叠,必须优先于 ASCII 分支判断,
@ -235,7 +245,7 @@ export default {
scanHiddenFocused: false, scanHiddenFocused: false,
pageActive: true, pageActive: true,
scanCode: '', scanCode: '',
scanQrText: '', scanQrImage: '',
scanMiniProgramUrl: '', scanMiniProgramUrl: '',
scanStatus: '等待扫码...', scanStatus: '等待扫码...',
scanPollTimer: null, scanPollTimer: null,
@ -251,7 +261,7 @@ export default {
hasStoredWorkbench: false, hasStoredWorkbench: false,
workbenchClientCode: '', workbenchClientCode: '',
workbenchBindCode: '', workbenchBindCode: '',
workbenchQrText: '', workbenchQrImage: '',
workbenchStatus: '等待绑定...', workbenchStatus: '等待绑定...',
workbenchPollTimer: null, workbenchPollTimer: null,
workbenchPollInterval: 1500, workbenchPollInterval: 1500,
@ -476,7 +486,7 @@ export default {
// 切到扫码登录:清空旧码,直接强制加载一次二维码 // 切到扫码登录:清空旧码,直接强制加载一次二维码
this.scanClientCode = '' this.scanClientCode = ''
this.scanCode = '' this.scanCode = ''
this.scanQrText = '' this.scanQrImage = ''
this.scanMiniProgramUrl = '' this.scanMiniProgramUrl = ''
this.handleScanLogin(false) this.handleScanLogin(false)
} else if (mode === 'workbench') { } else if (mode === 'workbench') {
@ -1221,6 +1231,32 @@ export default {
return loginLinkTemplate.replace('${code}', code) return loginLinkTemplate.replace('${code}', code)
}, },
buildQrImageUrlByPageUrl(pageUrl) {
if (!pageUrl) {
return ''
}
return `${qrBaseUrl}${encodeURIComponent(pageUrl)}`
},
buildFallbackQrImageUrlByPageUrl(pageUrl) {
if (!pageUrl) {
return ''
}
return `${qrFallbackBaseUrl}${encodeURIComponent(pageUrl)}`
},
handleScanImageError() {
if (!this.isPageActive()) {
return
}
const fallbackUrl = this.buildFallbackQrImageUrlByPageUrl(this.scanMiniProgramUrl)
if (fallbackUrl && this.scanQrImage !== fallbackUrl) {
this.scanQrImage = fallbackUrl
return
}
this.scanStatus = '二维码加载失败,请重试'
},
startScanLongPolling() { startScanLongPolling() {
if (!this.isPageActive()) { if (!this.isPageActive()) {
return return
@ -1310,6 +1346,30 @@ export default {
this.handleWorkbenchBind(false) this.handleWorkbenchBind(false)
} }
}, },
buildWorkbenchQrImageUrl(code) {
if (!code) {
return ''
}
return `${qrBaseUrl}${encodeURIComponent(code)}`
},
buildFallbackWorkbenchQrImageUrl(code) {
if (!code) {
return ''
}
return `${qrFallbackBaseUrl}${encodeURIComponent(code)}`
},
handleWorkbenchQrError() {
if (!this.isPageActive()) {
return
}
const fallbackUrl = this.buildFallbackWorkbenchQrImageUrl(this.workbenchBindCode)
if (fallbackUrl && this.workbenchQrImage !== fallbackUrl) {
this.workbenchQrImage = fallbackUrl
return
}
this.workbenchQrImage = ''
this.workbenchStatus = '二维码加载失败,请使用下方绑定码'
},
handleWorkbenchRefresh() { handleWorkbenchRefresh() {
if (!this.isPageActive()) { if (!this.isPageActive()) {
return return
@ -1320,7 +1380,7 @@ export default {
// 不传 clientCode:由服务端分配新客户端并立即返回新的绑定码(旧绑定码随即失效) // 不传 clientCode:由服务端分配新客户端并立即返回新的绑定码(旧绑定码随即失效)
this.workbenchClientCode = '' this.workbenchClientCode = ''
this.workbenchBindCode = '' this.workbenchBindCode = ''
this.workbenchQrText = '' this.workbenchQrImage = ''
this.workbenchStatus = '正在刷新绑定码...' this.workbenchStatus = '正在刷新绑定码...'
this.stopWorkbenchLongPolling() this.stopWorkbenchLongPolling()
this.handleWorkbenchBind(false) this.handleWorkbenchBind(false)
@ -1364,7 +1424,7 @@ export default {
} }
if (bindCode) { if (bindCode) {
this.workbenchBindCode = bindCode this.workbenchBindCode = bindCode
this.workbenchQrText = bindCode this.workbenchQrImage = this.buildWorkbenchQrImageUrl(bindCode)
} }
if (status === 'bound' && token) { if (status === 'bound' && token) {
@ -1526,7 +1586,7 @@ export default {
this.hasStoredWorkbench = false this.hasStoredWorkbench = false
this.stopWorkbenchLongPolling() this.stopWorkbenchLongPolling()
this.workbenchBindCode = '' this.workbenchBindCode = ''
this.workbenchQrText = '' this.workbenchQrImage = ''
this.workbenchClientCode = '' this.workbenchClientCode = ''
this.workbenchStatus = '正在获取绑定码...' this.workbenchStatus = '正在获取绑定码...'
this.handleWorkbenchBind(false) this.handleWorkbenchBind(false)
@ -1568,19 +1628,20 @@ export default {
body?.clientCode || body?.clientCode ||
body?.client_code || body?.client_code ||
'' ''
const qrImageFromApi = payload?.qrCodeUrl || payload?.qrcodeUrl || payload?.codeUrl || payload?.wechatCodeUrl || payload?.image || ''
const loginCode = payload?.loginWechatCode || payload?.wechatCode || payload?.qrCode || payload?.code || '' const loginCode = payload?.loginWechatCode || payload?.wechatCode || payload?.qrCode || payload?.code || ''
const miniProgramPageUrl = this.buildMiniProgramUrlByCode(loginCode) const miniProgramPageUrl = this.buildMiniProgramUrlByCode(loginCode)
const qrImageFromTemplate = this.buildQrImageUrlByPageUrl(miniProgramPageUrl)
if (clientCode) { if (clientCode) {
this.scanClientCode = clientCode this.scanClientCode = clientCode
} }
this.scanMiniProgramUrl = miniProgramPageUrl || '' this.scanMiniProgramUrl = miniProgramPageUrl || ''
// 二维码内容:视图层据此本地绘制(不再是远程图片地址) this.scanQrImage = qrImageFromTemplate || qrImageFromApi || ''
this.scanQrText = miniProgramPageUrl || ''
this.scanCode = loginCode || '' this.scanCode = loginCode || ''
if (this.scanQrText || this.scanCode) { if (this.scanQrImage || this.scanCode) {
this.scanStatus = '等待扫码...' this.scanStatus = '等待扫码...'
} else { } else {
this.scanStatus = body?.message || body?.msg || '二维码获取失败' this.scanStatus = body?.message || body?.msg || '二维码获取失败'
@ -1813,58 +1874,32 @@ export default {
</script> </script>
<script module="remInject" lang="renderjs"> <script module="remInject" lang="renderjs">
import { applyRemBase } from '../../render-common/rem-base.js'
// 二维码本地绘制:登录二维码 / 工作台绑定码都在视图层画成 SVG,不依赖远程出图服务
import { paintQrIn, watchQrIn } from '../../render-common/qr-render.js'
export default { export default {
mounted() { mounted() {
// 二维码绘制:H5 / 真机都要跑(视图层副作用统一放在条件编译之外,不要依赖“提前 return”) // #ifdef APP-PLUS
this.paintQrCodes() // 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
// #ifndef APP-PLUS return
// rem 基准统一走 render-common/rem-base.js(满格 1rem = 100px,>1280 宽不再放大字体),
// 字号偏大靠改 CSS 的 font-size 值(已全局 ×0.85),不动基准
// 各页面不再各算一份,避免系数漂移
// 真机(APP-PLUS)rem 由 App.vue 全局纯 CSS(html { font-size: 7.8125vw !important }=100/1280)承担。
// ⚠️ 这里用 #ifndef,不要写成 `#ifdef APP-PLUS + return`:后者会让 esbuild 报
// “semicolon-after-return”,且以后往 mounted 里补的视图层代码会变成真机永不执行。
this._remResizeHandler = applyRemBase
applyRemBase()
window.addEventListener('resize', this._remResizeHandler)
// #endif // #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920
const height = docEl.clientHeight || window.innerHeight || 1280
const scale = Math.min(width / 1920, height / 1280)
docEl.style.fontSize = (scale * 100 * REM_SCALE) + 'px'
console.log('[rem-renderjs] fontSize =', docEl.style.fontSize, 'width =', width, 'height =', height, 'scale =', scale, 'REM_SCALE =', REM_SCALE, 'dpr =', window.devicePixelRatio)
}
this._remResizeHandler = setFontSize
setFontSize()
window.addEventListener('resize', setFontSize)
}, },
beforeDestroy() { beforeDestroy() {
if (this._stopQrWatch) {
this._stopQrWatch()
this._stopQrWatch = null
}
if (this._remResizeHandler) { if (this._remResizeHandler) {
window.removeEventListener('resize', this._remResizeHandler) window.removeEventListener('resize', this._remResizeHandler)
this._remResizeHandler = null this._remResizeHandler = null
} }
},
methods: {
paintQrCodes() {
const paint = () => {
try {
paintQrIn(document)
} catch (e) {
// 单个二维码绘制失败不影响登录流程
}
}
// 首次 + 若干次延时兜底:首屏 DOM 未就绪、登录码/绑定码稍后返回时各补一次
paint()
setTimeout(paint, 80)
setTimeout(paint, 600)
setTimeout(paint, 1500)
// 内容后续变化(轮询到绑定码、刷新绑定码、重新获取登录码)→ 自动重绘
try {
this._stopQrWatch = watchQrIn(document)
} catch (e) {
this._stopQrWatch = null
}
}
} }
} }
</script> </script>
@ -1883,11 +1918,11 @@ export default {
} }
.update-dialog { .update-dialog {
width: 4.92rem; width: 15.36rem;
max-width: 90%; max-width: 90%;
background-color: var(--wms-card-bg); background-color: #ffffff;
border-radius: 0.13rem; border-radius: 0.307rem;
padding: 0.25rem; padding: 0.819rem;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -1899,97 +1934,96 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: 0.15rem; margin-bottom: 0.512rem;
} }
.update-dialog__title { .update-dialog__title {
font-size: 0.21rem; font-size: 0.768rem;
font-weight: 600; font-weight: 600;
color: var(--wms-text); color: #333;
} }
.update-dialog__close { .update-dialog__close {
font-size: 0.3rem; font-size: 1.024rem;
color: var(--wms-text-placeholder); color: #999;
line-height: 1; line-height: 1;
padding: 0 0.05rem; padding: 0 0.205rem;
} }
.update-dialog__desc { .update-dialog__desc {
font-size: 0.15rem; font-size: 0.563rem;
color: var(--wms-text-secondary); color: #666;
text-align: center; text-align: center;
margin-bottom: 0.15rem; margin-bottom: 0.512rem;
} }
.update-progress-track { .update-progress-track {
width: 100%; width: 100%;
height: 0.1rem; height: 0.307rem;
background-color: #eef1f6; background-color: #eef1f6;
border-radius: 0.07rem; border-radius: 0.154rem;
overflow: hidden; overflow: hidden;
margin-bottom: 0.1rem; margin-bottom: 0.256rem;
} }
.update-progress-fill { .update-progress-fill {
height: 100%; height: 100%;
background-color: var(--wms-primary); background-color: #2f7dff;
border-radius: 0.07rem; border-radius: 0.154rem;
transition: width 0.2s ease; transition: width 0.2s ease;
} }
.update-progress-text { .update-progress-text {
font-size: 0.15rem; font-size: 0.512rem;
color: #888; color: #888;
margin-bottom: 0.1rem; margin-bottom: 0.256rem;
} }
.update-dialog__actions { .update-dialog__actions {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
gap: 0.15rem; gap: 0.512rem;
margin-top: 0.1rem; margin-top: 0.256rem;
} }
.update-dialog__btn { .update-dialog__btn {
width: 1.76rem; width: 5.5rem;
margin: 0; margin: 0;
font-size: 0.15rem; font-size: 0.563rem;
} }
.update-dialog__btn--skip { .update-dialog__btn--skip {
background-color: #f2f4f8; background-color: #f2f4f8;
color: var(--wms-text-secondary); color: #666;
} }
.update-dialog__btn--skip::after { .update-dialog__btn--skip::after {
border: 0.01rem solid var(--wms-border); border: 0.026rem solid #dcdfe6;
} }
.update-dialog__btn--disabled { .update-dialog__btn--disabled {
opacity: 0.45; opacity: 0.45;
} }
/* 基准(src/styles/base.css 的 .page):box-sizing / display: flex / flex-direction: column /
flex: 1 / min-height: 0 / 页面底色(--wms-page-bg,全站统一),本页只写差异项 */
.page { .page {
/* 本页是「横向两栏卡片 + 整体居中」,基准的 column 方向会把居中轴转 90°,显式改回 row */
flex-direction: row;
min-height: 100vh; min-height: 100vh;
min-width: 6.14rem; min-width: 19.2rem;
display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0.25rem; box-sizing: border-box;
padding: 0.819rem;
background-color: #f2f2f2;
} }
.login-card { .login-card {
width: 100%; width: 100%;
max-width: 8.19rem; max-width: 25.6rem;
min-width: 4.92rem; min-width: 15.36rem;
background-color: var(--wms-card-bg); background-color: #fff;
border-radius: 0.13rem; border-radius: 0.41rem;
box-shadow: 0 0.1rem 0.26rem rgba(0, 0, 0, 0.10), 0 0.02rem 0.07rem rgba(0, 0, 0, 0.05); box-shadow: 0 0.307rem 0.819rem rgba(0, 0, 0, 0.10), 0 0.077rem 0.205rem rgba(0, 0, 0, 0.05);
display: flex; display: flex;
overflow: hidden; overflow: hidden;
} }
@ -2001,56 +2035,56 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-sizing: border-box; box-sizing: border-box;
padding: 0.4rem 0.35rem; padding: 1.229rem 1.024rem;
background: linear-gradient(135deg, var(--wms-primary), #4d97ff); background: linear-gradient(135deg, #2f7dff, #4d97ff);
text-align: center; text-align: center;
} }
.visual-logo { .visual-logo {
display: block; display: block;
width: 1.97rem; width: 6.144rem;
max-width: 100%; max-width: 100%;
margin: 0 auto 0.15rem; margin: 0 auto 0.41rem;
} }
.visual-desc { .visual-desc {
font-size: 0.25rem; font-size: 0.922rem;
font-weight: 800; font-weight: 800;
line-height: 1.3; line-height: 1.3;
letter-spacing: 0.01rem; letter-spacing: 0.026rem;
color: var(--wms-white); color: #fff;
} }
.form-side { .form-side {
width: 55%; width: 55%;
box-sizing: border-box; box-sizing: border-box;
padding: 0.35rem 0.35rem; padding: 1.024rem 1.024rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.header { .header {
margin-bottom: 0.15rem; margin-bottom: 0.512rem;
} }
.title { .title {
display: block; display: block;
font-size: 0.25rem; font-size: 0.922rem;
font-weight: 600; font-weight: 600;
color: var(--wms-text); color: #333;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.subtitle { .subtitle {
font-size: 0.17rem; font-size: 0.614rem;
color: var(--wms-text-secondary); color: #666;
} }
.scan-hint { .scan-hint {
display: block; display: block;
font-size: 0.17rem; font-size: 0.614rem;
color: var(--wms-success-alt); color: #2fbf71;
margin-bottom: 0.04rem; margin-bottom: 0.102rem;
} }
.scan-hint--hidden { .scan-hint--hidden {
@ -2060,51 +2094,45 @@ export default {
.switch-tabs { .switch-tabs {
display: flex; display: flex;
background-color: #f5f7fb; background-color: #f5f7fb;
border-radius: 0.07rem; border-radius: 0.205rem;
margin-bottom: 0.15rem; margin-bottom: 0.41rem;
overflow: hidden; overflow: hidden;
} }
.tab-item { .tab-item {
flex: 1; flex: 1;
text-align: center; text-align: center;
padding: 0.1rem 0; padding: 0.307rem 0;
font-size: 0.18rem; font-size: 0.666rem;
color: var(--wms-text-secondary); color: #666;
} }
.tab-item--active { .tab-item--active {
color: #007aff; color: #007aff;
font-weight: 600; font-weight: 600;
background-color: var(--wms-bg-tint); background-color: #eef5ff;
} }
.panel { .panel {
background-color: #fdfdfd; background-color: #fdfdfd;
border: 0.01rem solid #f0f0f0; border: 0.026rem solid #f0f0f0;
border-radius: 0.07rem; border-radius: 0.205rem;
padding: 0.15rem; padding: 0.41rem;
} }
.panel-stage { .panel-stage {
position: relative; position: relative;
/* 原来是写死 height: 2.7rem:工作台面板内容(提示 + 二维码框 + 绑定码 + 状态 + 刷新)比它高, height: 8.448rem;
flex 会把虚线框压扁,而框里的二维码图片尺寸不变 → 图片顶出虚线框、盖住绑定码(真机字体行高更高,溢出更明显)。
改成最小高度 + 内容撑高:短面板仍撑满 2.7rem(面板高度稳定),长面板自适应长高 */
display: flex;
flex-direction: column;
min-height: 2.7rem;
} }
.panel--mode { .panel--mode {
position: static; position: static;
/* flex: 1 0 auto —— 可拉伸填满 stage(短面板保持 2.7rem),但绝不压缩(避免内容被挤爆) */ height: 100%;
flex: 1 0 auto;
box-sizing: border-box; box-sizing: border-box;
} }
.panel--scan { .panel--scan {
padding: 0.15rem; padding: 0.41rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
@ -2118,7 +2146,7 @@ export default {
} }
.panel--account .primary-btn { .panel--account .primary-btn {
margin-top: 0.2rem; margin-top: 0.614rem;
} }
.panel--workbench { .panel--workbench {
@ -2126,67 +2154,97 @@ export default {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 0.15rem; padding: 0.41rem;
}
/* 工作台面板的子项一律不参与压缩:虚线框/绑定码被压扁就会出现"二维码顶出框外盖住绑定码" */
.panel--workbench > * {
flex-shrink: 0;
} }
.wb-tip-top { .wb-tip-top {
display: block; display: block;
text-align: center; text-align: center;
font-size: 0.17rem; font-size: 0.614rem;
line-height: 1.5; line-height: 1.5;
color: var(--wms-text-secondary); color: #666;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.wb-code-box { .wb-code-box {
width: 100%; width: 100%;
max-width: 2.29rem; max-width: 7.168rem;
box-sizing: border-box; box-sizing: border-box;
border: 0.02rem dashed #bcd7ff; border: 0.051rem dashed #bcd7ff;
border-radius: 0.13rem; border-radius: 0.307rem;
background: linear-gradient(135deg, var(--wms-bg-tint), #f8fbff); background: linear-gradient(135deg, #eef5ff, #f8fbff);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0.1rem; padding: 0.307rem;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
}
.wb-qr-image {
width: 4.608rem;
height: 4.608rem;
}
.wb-code-text {
display: block;
text-align: center;
font-size: 0.666rem;
font-weight: 700;
letter-spacing: 0.102rem;
text-indent: 0.102rem;
color: #1f5fd6;
font-family: 'Courier New', Consolas, monospace;
margin-bottom: 0.205rem;
}
.wb-code {
font-size: 1.28rem;
font-weight: 800;
letter-spacing: 0.307rem;
text-indent: 0.307rem;
color: #1f5fd6;
font-family: 'Courier New', Consolas, monospace;
}
.wb-code-placeholder {
font-size: 0.614rem;
color: #9aa7bd;
} }
.wb-tip-bottom { .wb-tip-bottom {
display: block; display: block;
text-align: center; text-align: center;
font-size: 0.17rem; font-size: 0.614rem;
color: var(--wms-success-alt); color: #2fbf71;
margin-bottom: 0.04rem; margin-bottom: 0.102rem;
} }
.wb-client-hint { .wb-client-hint {
display: block; display: block;
text-align: center; text-align: center;
font-size: 0.15rem; font-size: 0.512rem;
color: #b0b8c6; color: #b0b8c6;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.wb-refresh-btn { .wb-refresh-btn {
width: 1.64rem; width: 5.12rem;
height: 0.36rem; /* 控件 36px */ height: 1.434rem;
line-height: 0.36rem; line-height: 1.434rem;
box-sizing: border-box; box-sizing: border-box;
font-size: 0.17rem; font-size: 0.614rem;
color: #007aff; color: #007aff;
background-color: var(--wms-bg-tint); background-color: #eef5ff;
border: 0.01rem solid #bcd7ff; border: 0.026rem solid #bcd7ff;
border-radius: 0.07rem; border-radius: 0.205rem;
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
.wb-refresh-btn::after {
border: none;
}
.wb-refresh-btn[disabled] { .wb-refresh-btn[disabled] {
color: #a9b4c6; color: #a9b4c6;
background-color: #f2f3f5; background-color: #f2f3f5;
@ -2196,30 +2254,30 @@ export default {
.wb-quick-box { .wb-quick-box {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
border: 0.01rem solid #e5e5e5; border: 0.026rem solid #e5e5e5;
border-radius: 0.07rem; border-radius: 0.205rem;
background-color: #fafbfc; background-color: #fafbfc;
padding: 0.1rem; padding: 0.256rem;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.wb-quick-title { .wb-quick-title {
display: block; display: block;
font-size: 0.18rem; font-size: 0.666rem;
color: var(--wms-text); color: #333;
font-weight: 600; font-weight: 600;
margin-bottom: 0.04rem; margin-bottom: 0.102rem;
} }
.wb-quick-desc { .wb-quick-desc {
display: block; display: block;
font-size: 0.15rem; font-size: 0.512rem;
color: var(--wms-text-placeholder); color: #999;
line-height: 1.5; line-height: 1.5;
} }
.wb-enter-btn { .wb-enter-btn {
margin-top: 0.04rem; margin-top: 0.102rem;
} }
.wb-rebind-link { .wb-rebind-link {
@ -2227,54 +2285,40 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
padding: 0.05rem 0 0; padding: 0.205rem 0 0;
font-size: 0.15rem; font-size: 0.563rem;
color: var(--wms-primary); color: #2f7dff;
} }
.scan-box { .scan-box {
width: 1.64rem; width: 5.12rem;
height: 1.64rem; height: 5.12rem;
border: 0.02rem dashed #d9d9d9; border: 0.051rem dashed #d9d9d9;
border-radius: 0.07rem; border-radius: 0.205rem;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0 auto 0.05rem; margin: 0 auto 0.205rem;
} }
.scan-image { .scan-image {
/* 二维码由视图层本地画成 SVG(qr-render.js)后挂到这里 */ width: 4.608rem;
/* 固定正方形,始终不超出虚线框(quiet zone 由渲染器自己留白) */ height: 4.608rem;
flex-shrink: 0;
max-width: 100%;
max-height: 100%;
width: 1.47rem;
height: 1.47rem;
display: flex;
align-items: center;
justify-content: center;
}
.scan-image svg {
display: block;
width: 100%;
height: 100%;
} }
.scan-tip-top { .scan-tip-top {
display: block; display: block;
text-align: center; text-align: center;
font-size: 0.17rem; font-size: 0.614rem;
color: var(--wms-text-secondary); color: #666;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.scan-tip-bottom { .scan-tip-bottom {
display: block; display: block;
text-align: center; text-align: center;
font-size: 0.15rem; font-size: 0.563rem;
color: var(--wms-text-placeholder); color: #999;
margin-bottom: 0; margin-bottom: 0;
} }
@ -2283,22 +2327,22 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-bottom: 0.05rem; margin-bottom: 0.205rem;
} }
.wb-code-label { .wb-code-label {
font-size: 0.15rem; font-size: 0.563rem;
color: var(--wms-text-secondary); color: #666;
margin-right: 0.05rem; margin-right: 0.205rem;
} }
.wb-code-value { .wb-code-value {
font-size: 0.2rem; font-size: 0.717rem;
font-weight: bold; font-weight: bold;
color: var(--wms-primary); color: #2f7dff;
letter-spacing: 0.02rem; letter-spacing: 0.051rem;
font-family: Consolas, Menlo, monospace; font-family: Consolas, Menlo, monospace;
max-width: 1.79rem; max-width: 5.6rem;
word-break: break-all; word-break: break-all;
text-align: center; text-align: center;
user-select: text; user-select: text;
@ -2309,25 +2353,32 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
padding: 0.05rem 0 0; padding: 0.205rem 0 0;
font-size: 0.15rem; font-size: 0.563rem;
color: var(--wms-primary); color: #2f7dff;
} }
/* 隐藏扫码输入框:样式在全局基准 src/styles/base.css(登录/订单/打包/退件共用同一份) */ .scan-hidden-input {
position: absolute;
width: 0.02rem;
height: 0.02rem;
opacity: 0;
left: -199.98rem;
top: -199.98rem;
}
.scan-placeholder { .scan-placeholder {
color: var(--wms-text-placeholder); color: #999;
font-size: 0.15rem; font-size: 0.563rem;
} }
.input { .input {
height: 0.36rem; height: 1.638rem;
border: 0.01rem solid #e5e5e5; border: 0.026rem solid #e5e5e5;
border-radius: 0.07rem; border-radius: 0.205rem;
padding: 0 0.15rem; padding: 0 0.41rem;
margin-bottom: 0.1rem; margin-bottom: 0.307rem;
font-size: 0.18rem; font-size: 0.666rem;
} }
.input:focus { .input:focus {
@ -2337,25 +2388,25 @@ export default {
.input-wrap, .input-wrap,
.password-wrap { .password-wrap {
position: relative; position: relative;
border: 0.01rem solid #e5e5e5; border: 0.026rem solid #e5e5e5;
border-radius: 0.07rem; border-radius: 0.205rem;
background-color: var(--wms-card-bg); background-color: #fff;
transition: border-color 0.2s ease, box-shadow 0.2s ease; transition: border-color 0.2s ease, box-shadow 0.2s ease;
margin-bottom: 0.1rem; margin-bottom: 0.307rem;
} }
.input-wrap--focused { .input-wrap--focused {
border-color: #007aff; border-color: #007aff;
box-shadow: 0 0 0 0.03rem rgba(0, 122, 255, 0.08); box-shadow: 0 0 0 0.102rem rgba(0, 122, 255, 0.08);
} }
.password-wrap { .password-wrap {
margin-top: 0.1rem; margin-top: 0.307rem;
} }
.password-input { .password-input {
margin-bottom: 0; margin-bottom: 0;
padding-right: 1.3rem; padding-right: 3.994rem;
font-family: system-ui; font-family: system-ui;
} }
@ -2365,7 +2416,7 @@ export default {
} }
.input--with-clear { .input--with-clear {
padding-right: 0.7rem; padding-right: 2.15rem;
} }
.input-wrap .input, .input-wrap .input,
@ -2377,13 +2428,13 @@ export default {
.clear-trigger { .clear-trigger {
position: absolute; position: absolute;
right: 0.05rem; right: 0.563rem;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
/* 点击热区 36px(与输入框等高,透明不参与视觉);可见的圆标在 __icon 上 */ width: 1.024rem;
box-sizing: border-box; height: 1.024rem;
width: 0.36rem; border-radius: 50%;
height: 0.36rem; border: 0.026rem solid #cfd6e4;
background-color: transparent; background-color: transparent;
display: flex; display: flex;
align-items: center; align-items: center;
@ -2391,41 +2442,30 @@ export default {
} }
.clear-trigger--password { .clear-trigger--password {
right: 0.44rem; right: 2.253rem;
} }
.clear-trigger__icon { .clear-trigger__icon {
/* 可见圆标 22px:在 36px 输入框内上下各留 7px font-size: 0.614rem;
(原来圆标就写在 .clear-trigger 上 = 和输入框同高 36px,加上 1px 边框还会溢出输入框) */ line-height: 1;
box-sizing: border-box;
display: inline-block;
width: 0.22rem;
height: 0.22rem;
border: 0.01rem solid #cfd6e4;
border-radius: 50%;
font-size: 0.15rem;
line-height: 0.2rem;
text-align: center;
color: #a9b4c6; color: #a9b4c6;
} }
.toggle-password { .toggle-password {
position: absolute; position: absolute;
right: 0.05rem; right: 0.563rem;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
/* 控件 36px(与 36px 输入框等高) */ width: 1.434rem;
width: 0.36rem; height: 1.434rem;
height: 0.36rem;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.pwd-eye { .pwd-eye {
/* 可见眼睛图标 20px(原来 0.3rem=30px,几乎顶满 36px 输入框,比清除圆标还大) */ width: 0.922rem;
width: 0.2rem; height: 0.922rem;
height: 0.2rem;
display: block; display: block;
line-height: 0; line-height: 0;
} }
@ -2438,12 +2478,41 @@ export default {
.primary-btn { .primary-btn {
width: 100%; width: 100%;
margin-top: 0.15rem; margin-top: 0.41rem;
font-size: 0.22rem; font-size: 0.8rem;
} }
.scan-login-btn { .scan-login-btn {
background-color: var(--wms-success-alt); background-color: #2fbf71;
color: var(--wms-white); color: #fff;
}
.scan-login-btn::after {
border: none;
}
@media screen and (max-width: 16rem) {
.page {
min-width: 14.4rem;
}
.login-card {
max-width: 22.528rem;
min-width: 13.824rem;
}
.visual-side {
width: 45%;
padding: 1.024rem 0.819rem;
}
.form-side {
width: 55%;
padding: 0.819rem 0.819rem;
}
.panel-stage {
height: 8.448rem;
}
} }
</style> </style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -31,21 +31,26 @@ export default {
</script> </script>
<script module="remInject" lang="renderjs"> <script module="remInject" lang="renderjs">
import { applyRemBase } from '../../render-common/rem-base.js'
export default { export default {
mounted() { mounted() {
// #ifndef APP-PLUS // #ifdef APP-PLUS
// rem 基准统一走 render-common/rem-base.js(满格 1rem = 100px,>1280 宽不再放大字体), // 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// 字号偏大靠改 CSS 的 font-size 值(已全局 ×0.85),不动基准 // renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
// 各页面不再各算一份,避免系数漂移 return
// 真机(APP-PLUS)rem 由 App.vue 全局纯 CSS(html { font-size: 7.8125vw !important }=100/1280)承担。
// ⚠️ 这里用 #ifndef,不要写成 `#ifdef APP-PLUS + return`:后者会让 esbuild 报
// “semicolon-after-return”,且以后往 mounted 里补的视图层代码会变成真机永不执行。
this._remResizeHandler = applyRemBase
applyRemBase()
window.addEventListener('resize', this._remResizeHandler)
// #endif // #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920
const height = docEl.clientHeight || window.innerHeight || 1280
const scale = Math.min(width / 1920, height / 1280)
docEl.style.fontSize = (scale * 100 * REM_SCALE) + 'px'
console.log('[rem-renderjs] fontSize =', docEl.style.fontSize, 'width =', width, 'height =', height, 'scale =', scale, 'REM_SCALE =', REM_SCALE, 'dpr =', window.devicePixelRatio)
}
this._remResizeHandler = setFontSize
setFontSize()
window.addEventListener('resize', setFontSize)
}, },
beforeDestroy() { beforeDestroy() {
if (this._remResizeHandler) { if (this._remResizeHandler) {
@ -56,15 +61,22 @@ export default {
} }
</script> </script>
<style> <style>
/* 基准(src/styles/base.css 的 .page、.page-main):整屏 flex 列布局 + 内容区吃满剩余高度
+ 四周内间距(上 0.05、左右下 0.25),本页只写差异项 */
.page { .page {
height: 100%; height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden; overflow: hidden;
box-sizing: border-box;
background-color: #f8f8f8;
} }
.page-main { .page-main {
flex: 1;
min-height: 0;
overflow-y: auto; overflow-y: auto;
padding: 0.205rem 0.819rem 0.819rem;
box-sizing: border-box;
} }
.dynamic-view--catch-weight { .dynamic-view--catch-weight {
@ -72,23 +84,23 @@ export default {
} }
.module-card { .module-card {
background-color: var(--wms-card-bg); background-color: #fff;
border-radius: 0.13rem; border-radius: 0.41rem;
padding: 0.25rem; padding: 0.819rem;
box-sizing: border-box; box-sizing: border-box;
} }
.module-card-title { .module-card-title {
display: block; display: block;
font-size: 0.22rem; font-size: 0.819rem;
color: var(--wms-text); color: #333;
font-weight: 600; font-weight: 600;
margin-bottom: 0.1rem; margin-bottom: 0.307rem;
} }
.module-card-desc { .module-card-desc {
display: block; display: block;
font-size: 0.18rem; font-size: 0.666rem;
color: #888; color: #888;
line-height: 1.5; line-height: 1.5;
} }

View File

@ -1,134 +0,0 @@
/**
* 本地二维码渲染(视图层,供各页 renderjs 调用)
*
* 为什么要本地生成:登录页扫码登录的二维码、工作台绑定码原先都是**远程服务出图**
* (`https://ye4s.wms.gztbyc.com/grcode/build?text=`,兜底 `api.qrserver.com`)——
* 断网、内网隔离、或那两个服务不可用时二维码就出不来,而且真机每次都要走网络。
* 现在改为在视图层本地绘制,与"扫码指令条形码"(jsbarcode 画进 `<svg>`,见 returns 页)同一套思路:
* 直接用 DOM 画 SVG,H5 / Electron / 真机 WebView 表现一致。
*
* 依赖 `qrcode-generator`:纯 ES5、零运行时依赖、约 15KB,只给模块矩阵,
* 不依赖 canvas / 网络,老 WebView 也能跑。
*
* 用法(约定用属性传内容,避免逻辑层/视图层来回传对象):
* <view class="qr-box" :data-qr-text="qrText"></view>
* 视图层 renderjs 里调用 paintQrIn()(首次 + 若干次延时兜底;属性变化时重新绘制)
*/
import qrcode from 'qrcode-generator'
// 静区(模块数):二维码规范要求四周留 ≥4 个模块的空白,少了真机扫不出来
const QUIET_MODULES = 4
const SVG_NS = 'http://www.w3.org/2000/svg'
/**
* 把二维码画进指定容器(会先清掉容器里已有的 svg)
* @param {Element} el 容器元素
* @param {string} text 二维码内容
* @param {{ errorCorrectionLevel?: string, dark?: string, light?: string }} [options]
* @returns {boolean} 是否绘制成功
*/
export function drawQrInto (el, text, options) {
const opts = options || {}
const value = text === null || text === undefined ? '' : String(text).trim()
if (!el || !value) return false
const qr = qrcode(0, opts.errorCorrectionLevel || 'M') // 版本 0 = 自动选能装下的最小版本
qr.addData(value) // 默认 Byte 模式,链接/中文都按 UTF-8 编码
qr.make()
const count = qr.getModuleCount()
const size = count + QUIET_MODULES * 2
const svg = document.createElementNS(SVG_NS, 'svg')
svg.setAttribute('xmlns', SVG_NS)
svg.setAttribute('viewBox', '0 0 ' + size + ' ' + size)
svg.setAttribute('width', '100%')
svg.setAttribute('height', '100%')
// 模块是整数方块:缩放时不要抗锯齿模糊,否则老 WebView 上可能扫不出
svg.setAttribute('shape-rendering', 'crispEdges')
// 白底:避免透明底叠在深色背景/阴影上后对比度不足
const bg = document.createElementNS(SVG_NS, 'rect')
bg.setAttribute('x', '0')
bg.setAttribute('y', '0')
bg.setAttribute('width', String(size))
bg.setAttribute('height', String(size))
bg.setAttribute('fill', opts.light || '#ffffff')
svg.appendChild(bg)
// 逐行把连续暗模块合并成一个 rect,节点数比逐格少一半以上
const dark = opts.dark || '#000000'
for (let row = 0; row < count; row++) {
let col = 0
while (col < count) {
if (!qr.isDark(row, col)) {
col++
continue
}
let end = col
while (end + 1 < count && qr.isDark(row, end + 1)) end++
const rect = document.createElementNS(SVG_NS, 'rect')
rect.setAttribute('x', String(col + QUIET_MODULES))
rect.setAttribute('y', String(row + QUIET_MODULES))
rect.setAttribute('width', String(end - col + 1))
rect.setAttribute('height', '1')
rect.setAttribute('fill', dark)
svg.appendChild(rect)
col = end + 1
}
}
// 清空容器(不用 innerHTML:老 WebView 下自定义元素上更稳)
while (el.firstChild) el.removeChild(el.firstChild)
el.appendChild(svg)
return true
}
/**
* 扫描带 data-qr-text 的容器并绘制(内容没变则跳过)
* @param {Document|Element} [root] 查询范围,默认当前文档
* @returns {number} 本次实际绘制的个数
*/
export function paintQrIn (root) {
const scope = root || (typeof document !== 'undefined' ? document : null)
if (!scope || !scope.querySelectorAll) return 0
const nodes = scope.querySelectorAll('[data-qr-text]')
let painted = 0
for (let i = 0; i < nodes.length; i++) {
const el = nodes[i]
const text = el.getAttribute('data-qr-text') || ''
if (!text) continue
if (el.getAttribute('data-qr-drawn') === text) continue // 内容未变,不重画
try {
if (drawQrInto(el, text)) {
el.setAttribute('data-qr-drawn', text)
painted++
}
} catch (e) {
// 单个二维码绘制失败不影响其他;内容过长(超出二维码容量)时也会走到这里
}
}
return painted
}
/**
* 观察 data-qr-text 变化并自动重绘(Vue 更新属性 → 这里重画)
* @param {Document|Element} [root]
* @returns {Function} 取消观察的函数
*/
export function watchQrIn (root) {
const scope = root || (typeof document !== 'undefined' ? document : null)
if (!scope || typeof MutationObserver === 'undefined') return function () {}
const observer = new MutationObserver(function () {
paintQrIn(scope)
})
observer.observe(scope === document ? document.body : scope, {
subtree: true,
childList: true, // 容器是 v-if 新插入的:新增节点也要触发一次绘制
attributes: true,
attributeFilter: ['data-qr-text']
})
return function () {
observer.disconnect()
}
}

View File

@ -1,56 +0,0 @@
/**
* rem 基准(H5 / Electron 唯一来源,各页面请勿再各写一份,否则系数会漂移)
*
* 设计稿 1280 宽,底座与缩放分开(两个因子都是标准值,不要再往里塞观感):
* BASE_FONT_SIZE = 100 ← 设计底座:1rem = 设计稿 100px(rem 值 = 设计稿 px ÷ 100)
* REM_SCALE = 1 ← 显示缩放:标准值 1(1 = 不动;不考虑改)
* 缩放 = min(1, vw / 1280) ← 视口缩放:默认 1,只缩不放,只看宽度
* html.fontSize = BASE_FONT_SIZE × REM_SCALE × 缩放
*
* 满格(宽度 ≥1280)= 100px(1280 / 1920 / 2560 / 4K 都一样,也不看窗口高度);
* 窄于 1280 时按比例缩小,缩到一半(640 宽)为止 → 下限 50px。
* 换算:CSS 里的 rem 值 × 100 = 屏幕实际 px(0.22rem → 22px)。
* rem 值约定:最多 2 位小数(2026-09-25 全站四舍五入统一)。
* 字号偏大不通过动基准解决,而是在 CSS 里改 font-size 值(2026-09-25 已把全站 font-size ×0.85)。
*
* 注意:真机 APP-PLUS 不参与本计算,由 App.vue 中 `html { font-size: 7.8125vw !important }`
* 承担(uni-app 框架会把 html font-size 以内联样式锁为 窗口宽/23.4375;7.8125vw = 100/1280)。
*/
export const DESIGN_WIDTH = 1280
// 设计底座:1280 宽设计稿下 1rem = 100px(rem 值 = 设计稿 px ÷ 100)
export const BASE_FONT_SIZE = 100
// 显示缩放:标准值 1(不要再拿它当观感旋钮;字号大小改 CSS 里的 font-size 值)
export const REM_SCALE = 1
// 缩放下限:窗口窄于设计稿一半后不再缩小(100 × 0.5 = 50px)
export const MIN_SCALE = 0.5
/**
* 计算当前视口的缩放比(未四舍五入)。
* @returns {{ width: number, height: number, scale: number } | null} 无 DOM 环境(APP 逻辑层)返回 null
*/
export function calcRemBase () {
if (typeof document === 'undefined' || !document.documentElement) return null
const docEl = document.documentElement
const win = typeof window !== 'undefined' ? window : null
const width = docEl.clientWidth || (win && win.innerWidth) || DESIGN_WIDTH
const height = docEl.clientHeight || (win && win.innerHeight) || 0
// 缩放默认 1:只看宽度 —— 窗口窄于设计稿才按比例缩小,宽于 1280(或窗口矮)不缩小不放大
const scale = Math.max(MIN_SCALE, Math.min(1, width / DESIGN_WIDTH))
return { width, height, scale }
}
/**
* 应用 html font-size,幂等、可重复调用(首次渲染与 resize 共用)。
* @returns {number | null} 实际写入的 px 值;无 DOM 环境返回 null
*/
export function applyRemBase () {
const info = calcRemBase()
if (!info) return null
// 保留 1 位小数:避免 33.1078125px 这类长小数带来的亚像素抖动与噪音日志
const fontSize = Math.round(BASE_FONT_SIZE * REM_SCALE * info.scale * 10) / 10
document.documentElement.style.fontSize = fontSize + 'px'
console.log('[rem] 1rem =', fontSize + 'px', '(= 底座 ' + BASE_FONT_SIZE + ' × 缩放 ' + REM_SCALE + ' × 视口 ' + Number(info.scale.toFixed(4)) + ')',
'视口 =', info.width + '×' + info.height)
return fontSize
}

View File

@ -1,179 +0,0 @@
/**
* WMS 工作台 · 全局基准样式(base)
*
* 【怎么被加载】App.vue 的 <style> 顶部 @import 本文件。uni-app 里 App.vue 的样式就是全局样式,
* 编译后进入所有页面共用的 app.css,且顺序在页面自身 <style> 之前 ——
* 所以:**公共基准写这里,页面只写自己的个性化差异**(同权重时页面规则天然覆盖基准)。
*
* 【分层顺序 = 优先级,越靠下越具体】
* 1. 设计 token(CSS 变量,供全站取值/换肤)
* 2. 元素重置(对 uni-app 组件库默认样式的统一修正)
* 3. 页面骨架(.page / .page-main:所有业务页共用的最外层结构)
* 4. 公共工具类(原先跨页面逐字重复的类)
* 5. H5/Electron 下组件库默认样式的修正
*
* 【新增样式放哪】
* - 6 个页面都要用的 → 放本文件;
* - 单个页面用的、或与基准不同的 → 写在页面 <style> 里,覆盖基准对应项即可。
*
* 【尺寸口径】rem 基准见 src/render-common/rem-base.js:1rem = 100px(设计稿 1280 宽,
* 宽度 ≥1280 不再放大,窄于 1280 等比缩,下限 50px)。
* 【控件/行高口径】PC 横屏:**控件(按钮 / 输入框 / 下拉 / tab)统一 `0.36rem` = 36px**;
* 表格、列表行 ≈ `0.5rem`(50px);顶栏 `0.7rem` = 70px(内行由 logo 决定)。
* `0.8rem` / `1.2rem`(80 / 120px)是移动端口径,PC 上不要用。
* 【小数位口径】所有 rem 值最多 2 位小数(2026-09-25 全站四舍五入统一,0.1965rem → 0.2rem);
* 2 位小数在底座 100 时 = 1px 精度,最大误差 0.5px。注意 `vw` 值(7.8125vw)必须保持精确,别动。
* 【字号口径】本文件与页面里的 font-size 都是「设计稿值 ×0.85」—— 2026-09-25 全站把字号降了 15%
* (只降文字,布局尺寸未降),即 0.18rem ≈ 18px,观感等于设计稿的 21px 字。
*/
/* ==================== 1. 设计 token ==================== */
/* 全站色值/圆角/字号的高频取值(数字为当前出现次数)。页面里暂时仍写死色值,
后续要统一改主题时,把页面里的值逐步换成 var(--wms-xxx) 即可,无需再全局搜替换。 */
:root {
/* 品牌色 / 状态色 */
--wms-primary: #2f7dff; /* 主蓝:顶栏、主按钮、选中态(39 次) */
--wms-primary-alt: #409eff; /* 次级蓝(9 次) */
--wms-success: #67c23a; /* 成功(12 次) */
--wms-success-alt: #2fbf71; /* 成功-深(9 次,打包页绑定态) */
--wms-warning: #ff7d00; /* 警告(7 次) */
--wms-danger: #f56c6c; /* 错误/危险(15 次) */
--wms-danger-strong: #e64340; /* 错误-深(12 次,退出登录等) */
/* 文字 */
--wms-text: #333; /* 正文基准色(42 次) */
--wms-text-strong: #303133; /* 标题/强调(15 次) */
--wms-text-secondary: #666; /* 次要文字(16 次) */
--wms-text-tertiary: #606266; /* 次要文字-深(12 次) */
--wms-text-muted: #909399; /* 说明/占位(31 次) */
--wms-text-placeholder: #999; /* 输入框占位(19 次) */
--wms-text-disabled: #c0c4cc; /* 禁用(7 次) */
--wms-white: #fff; /* 纯白:文字/描边用(底色请用 --wms-card-bg) */
/* 背景 / 边框 */
--wms-page-bg: #e8eaed; /* 页面底色(全站统一)=比 #f8f8f8 深一档,白卡片才“立”得起来:与 #fff 对比 1.21:1(#f8f8f8 只有 1.06:1) */
--wms-card-bg: #fff; /* 卡片/面板底色(89 次) */
--wms-bg-subtle: #f5f7fa; /* 表头、hover 底色(8 次) */
--wms-bg-tint: #eef5ff; /* 浅蓝底:提示块、当前项(8 次) */
--wms-border: #dcdfe6; /* 常规边框(13 次) */
--wms-border-alt: #d9dde8; /* 另一种常规边框(13 次) */
--wms-border-light: #ebeef5; /* 浅分隔线(8 次,表格行线) */
--wms-border-strong: #d0d5e0; /* 强边框:表格外框(9 次) */
/* 圆角 */
--wms-radius-sm: 0.07rem; /* 小圆角:输入框/按钮/标签(39 次)=7px */
--wms-radius-md: 0.13rem; /* 卡片圆角(12 次)=13px */
/* 字号(已含全站 ×0.85) */
--wms-font-xs: 0.15rem; /* 小标签/表格辅助文字(29 次) */
--wms-font-sm: 0.17rem; /* 说明文字(30 次) */
--wms-font-base: 0.18rem; /* 正文/表格(35 次,最常用) */
--wms-font-md: 0.2rem; /* 正文强调(27 次) */
--wms-font-lg: 0.21rem; /* 卡片标题(22 次) */
--wms-font-xl: 0.22rem; /* 导航菜单/大标题(11 次) */
--wms-font-title: 0.25rem; /* 页面级标题(8 次) */
--wms-font-2xl: 0.3rem; /* 大号数值:称重输入、数量 */
--wms-font-3xl: 0.35rem; /* 合计、重点数字 */
--wms-font-4xl: 0.45rem; /* 强调大字:打包拦截提示等 */
/* 结构尺寸(与各页面/组件保持一致,改尺寸时先看这里) */
/* PC 横屏口径(2026-09-25 用户两次更正后定稿):控件统一 0.36rem=36px;
表格/列表行 ≈ 0.5rem=50px;0.8rem/1.2rem(80/120px)是移动端口径,PC 上不用 */
--wms-nav-height: 0.7rem; /* 顶栏高度(top-nav.vue)=70px(内行由 0.5rem 的 logo 决定) */
--wms-control-h: 0.36rem; /* 控件高度:按钮/输入框/下拉/tab/步进 =36px(全站唯一一档) */
--wms-row-h: 0.5rem; /* 表格/列表行高 ≈50px(订单表格实为 0.52/0.56rem) */
--wms-sidebar-width: 3.8rem; /* 侧栏统一宽度(订单左栏/打包右栏/退件左栏)=380px */
--wms-gap: 0.1rem; /* 常用间距=10px */
--wms-page-pad: 0.25rem; /* 主体内容到页边的内间距=25px(与顶栏水平内边距一致,全站统一) */
--wms-panel-gap: 0.15rem; /* 主体内左右面板间距=15px(三页统一用 margin 写,保持一致) */
}
/* ==================== 2. 元素重置(组件库默认样式的统一修正) ==================== */
/* uni-app 的 button 组件默认带一条 ::after 细边框(框架规则:
uni-button:after { border: 1px solid rgba(0, 0, 0, .2) }),
本项目所有按钮都自己画边框/背景,不需要这条边框。
原先这 12 个按钮类在各自页面里各写了一份 `.xxx::after { border: none }`,现集中到这里一份。
注意:这里刻意不用通用的 `button::after` —— 那会把 logout-btn / close-btn /
update-dialog__btn 等靠框架默认边框出效果的按钮也一起改掉,出现未预期的观感变化。
新增自定义按钮时,把类名补进下面的列表即可。 */
.retry-btn::after,
.operator-btn::after,
.pack-verify-cancel-btn::after,
.op-btn::after,
.img-preview-btn::after,
.left-summary-refresh::after,
.weigh-btn::after,
.batch-review-fill::after,
.tool-btn::after,
.rp-btn::after,
.wb-refresh-btn::after,
.scan-login-btn::after {
border: none;
}
/* ==================== 3. 页面骨架 ==================== */
/* 页面根容器:整屏纵向 flex 列布局,具体滚动交给内容区。
各页面只需要写与基准不同的部分,例如:
- login:居中 + 自己的底色(.page 里显式 flex-direction: row)
- packaging:height: 100vh(底色与全站一致,已不再单独写灰底)
- order/returns/weighing:height: 100% / overflow: hidden */
.page {
box-sizing: border-box;
flex: 1; /* 被首页布局壳(pages/index 的 .layout-main)内嵌时撑满剩余高度 */
min-height: 0;
display: flex;
flex-direction: column;
background-color: var(--wms-page-bg);
}
/* 页面内容区:吃掉顶栏后的剩余高度,纵向 flex 列布局,四周内间距全站统一
(上 0.05 + 顶栏 margin-bottom 0.2 = 25px,与 --wms-page-pad 一致,四边都是 25px 视觉留白)。
滚动方式各页面不同,故基准不写 overflow:
- order:overflow-y: auto(整块滚)
- returns:overflow: hidden + 内部左右面板各自滚
- weighing:overflow-y: auto
- packaging 用的是自己的 .mode-main(同样吃满剩余高度,内间距取同一个 token) */
.page-main {
box-sizing: border-box;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 0.05rem var(--wms-page-pad) var(--wms-page-pad);
}
/* 主体内左右分栏的间距:统一用 margin 实现,三个页面写法一致(flex gap 真机也支持,只是保持原有写法):
- order:.panel-left 的 margin-right
- returns:.rp-left 的 margin-right
- packaging:.pack-right 的 margin-left */
/* ==================== 4. 公共工具类 ==================== */
/* 扫码枪隐藏输入框:必须「存在且可聚焦」(真机 WebView 才派发按键),但完全不可见、不占位、
不触发软键盘,配合 src/core/scanKey.js。原先登录/订单/打包/退件各写一份,逐字相同。
打包页要求它在屏幕内(top: 0),该页自行覆盖 top 即可。 */
.scan-hidden-input {
position: absolute;
width: 0.01rem;
height: 0.01rem;
opacity: 0;
left: -63.99rem;
top: -63.99rem;
}
/* ==================== 5. H5/Electron 组件库修正 ==================== */
/* 仅 H5/Electron 生效;APP 端由原生组件渲染,不涉及这些 class */
/* picker 下拉弹窗宽度与触发它的下拉框一致(高特异性覆盖库默认 300px),阴影调淡 */
uni-picker .uni-picker-container .uni-picker-custom,
.uni-picker-container .uni-picker-custom.uni-picker-custom {
width: 2.13rem !important;
box-shadow: 0 0 0.13rem 0.03rem rgba(0, 0, 0, 0.1) !important;
}
/* picker 下拉选项居左(覆盖库默认 text-align: center) */
uni-picker .uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
.uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
uni-picker .uni-picker-container .uni-picker-view-content .uni-picker-item,
.uni-picker-container .uni-picker-view-content .uni-picker-item {
text-align: left;
padding-left: 0.15rem;
}