WEB/docs/项目瘦身-未引用页面清单.md
2026-09-22 18:10:52 +08:00

8.8 KiB
Raw Permalink Blame History

项目瘦身 · 未引用页面清单

扫描时间:2026-09-22 · 扫描脚本:scripts/find-unused-modules.mjs · 原始数据:unused-report.json

一、判定方法(为什么不能只看 map.ts)

src/router/index.ts 里有一段兜底逻辑:

const viewModules = import.meta.glob('@/views/**/*.vue')

这意味着 src/views 下的每一个 .vue 都会被 Vite 收集进构建图(各自一个懒加载 chunk), 运行时后端菜单只要 component 字段能拼出路径,就能命中最上面的 glob。

所以"未被引用"必须区分两种情况:

口径 含义 能否直接删
静态不可达 从 src/main.ts 出发,经 import / import() / require() 到不了 需先确认后端菜单没有指向它
完全死代码 既静态不可达,也不被任何 glob 模式匹配 可以直接删

本次扫描结果(src 下共 582 个模块):

  • 静态可达:480
  • 仅被 glob 兜底匹配:80(全部在 src/views 下)
  • 完全死代码:22
  • 待处理合计:102 个文件(约 974 KB 源码)

二、第一批:整目录废弃(同功能新版已在 map.ts 中生效)

这批是"做了新版没删旧版"的复制目录,判断依据充分,可优先处理。 证据:废弃目录的文件修改时间统一停在 2026-08-11(模板生成日),而现行目录仍在持续更新。

废弃目录/文件 文件数 现行替代(map.ts 指向) 备注
src/views/order/waveOrder2/ 9 order/waveOrder/(order/waveOrder、wave/index) waveOrder 最近更新 09-21,waveOrder2 停在 08-11
src/views/data/newpackingflow/ 11 data/packingflow/(data/packingflow) packingflow 更新 09-16
src/views/material/packageMaterial2/ 8 material/packageMaterial/(material/packageMaterial/index)
src/views/system/setting/encoding2/ 8 system/setting/encoding/(system/setting/encoding/index)
src/views/mode/ 8 — 页面模板脚手架(【页面模板 v2】)
src/views/video/camera/ 3 video/newcamara/(video/camera/index 已重指向)
src/views/video/cameraServer/ 1 video/newcamaraserver/(video/cameraServer/index 已重指向)
src/views/store/shipperSigning/ 1 Externalwarehouse/shipperSigning/ 同名页面两份
src/views/system/setting/workbench/ 2 system/setting/workbench2/ map.ts 的 key 仍是 system/setting/workbench/index
src/views/system/setting/basicManagement/(旧 index.vue、ApiOpenInterface.vue) 2 system/setting/basicManagement/newview/ 旧路径已在 map.ts 里重指向 newview
src/views/warehouse/ 旧三件套 zone.vue、SpaceList.vue、SpaceForm.vue 3 ZoneManagement.vue / RackSpaceManagement.vue warehouse/index.vue 已不再 import 这三个

三、第二批:页面内孤立组件(页面本身在用,组件已废弃)

文件 体积 说明
order/orderManagement/component/detail.vue 0.3 KB 只 import 了 OrderDetailPanel.vue
order/orderManagement/component/orderdetail.vue 2.5 KB
order/orderManagement/component/OrderDetailPanel.vue 2.1 KB 仅被上面的 detail.vue 引用(链式死)
order/orderManagement/component/ManualOutboundPanel.vue 6.0 KB
order/orderManagement/component/OrderReviewDialog.vue 2.7 KB
order/waveOrder/component/WaveBatchPrintPreviewDialog.vue 10.8 KB
express/returnUnpack/components/ExportDialog.vue 9.7 KB 已被通用导出弹窗替代
express/returnUnpack/components/VideoListDialog.vue 4.3 KB 该目录下 VideoPlayerDialog.vue 仍在使用
express/waybill/components/TabArea.vue 2.6 KB
express/waybill/pages/ExampleFormDialog.vue 2.7 KB 模板残留
store/stores/component/ExportDialog.vue 7.6 KB
storage/entry/component/QuickInboundForm.vue 9.2 KB storage/entry/index.vue 未引用
storage/inventory/component/InventoryStockPickerDialog.vue 14.7 KB
afterSale/detail/HandleDialog.vue 4.6 KB 处理逻辑已内联在 detail/index.vue
system/setting/printStation/components/Printer.vue 3.2 KB 该页只 import info.vue / add.vue
system/setting/printStation/components/expressCompany.vue 2.4 KB 同上
system/setting/printStation/components/printComputer.vue 2.7 KB 同上
system/setting/printcomputer/config/components/DetailPanel.vue 4.6 KB
system/setting/printcomputer/config/components/LogPanel.vue 5.9 KB
system/setting/printcomputer/pages/ExampleFormDialog.vue 2.7 KB 模板残留
system/setting/workbench2/pages/ExampleFormDialog.vue 2.7 KB 模板残留
system/setting/basicManagement/newview/pages/ExampleFormDialog.vue 2.7 KB 模板残留
system/setting/basicManagement/newview/pages/ExportReportDialog.vue 6.7 KB
video/newcamaraserver/components/OperationCellRenderer.vue 5.1 KB 该页未 import(TabArea / ColumnCellRenderer 在用)
video/newcamara/pages/ExampleFormDialog.vue 2.7 KB 模板残留
afterSale/typelist/pages/ExampleFormDialog.vue 2.7 KB 模板残留
storage/generalreport/pages/ExampleFormDialog.vue 2.7 KB 模板残留
views/account/index.vue 0.1 KB 空壳(注意:map.ts 的 account/index 指向 system/setting/account/index.vue)
views/permission/index.vue 0.1 KB 空壳

四、第三批:完全死代码(非页面,共 22 个 / 324 KB)

Vue2 迁移残留(8 个 / 43.4 KB)

  • src/utils/index.js(2.7 KB)— vue-element-admin 工具集
  • src/utils/warehouseData.js(20.4 KB)
  • src/utils/zhijian.js(6.3 KB)+ src/utils/zhijian.ts(6.9 KB)— 双份同名,均无引用
  • src/icons/index.js(0.3 KB)— SVG 图标已改走 vite-plugin-svg-icons
  • src/layout/AppMain.vue(0.1 KB)— 实际使用的是 src/layout/component/AppMain.vue
  • src/stores/counter.ts(0.3 KB)— Pinia 示例
  • src/stores/modules/localCameraServer.ts(4.9 KB)

三维可视化遗留(5 个 / 约 114 KB)

  • src/utils/threeScene.js(36.2 KB)
  • src/utils/threeUtils.js(10.8 KB)
  • src/utils/overlookControls.js(11.3 KB)
  • src/utils/CanvasRenderer.js(26.6 KB)+ src/utils/CanvasRenderer.ts(28.8 KB)— 双份

模板配置残留

  • src/views/mode/config/template-config.ts(24.7 KB)
  • src/views/material/packageMaterial2/config/template-config.ts(24.6 KB)
  • src/views/system/setting/encoding2/config/template-config.ts(24.6 KB)
  • src/views/data/newpackingflow/config/packingflow-config.ts(26.0 KB)
  • src/views/order/waveOrder2/config/waveorder-config.ts(54.7 KB)
  • src/views/system/setting/workbench/workbench-config.ts(4.6 KB)

API 模块(3 个 / 9.3 KB,建议单独确认后再删)

  • src/api/order.packing/packing.ts(7.6 KB)
  • src/api/config/config.ts(1.3 KB)
  • src/api/printer.station/printerstation.ts(0.4 KB)

对照:src/api/waybill.warehouse/index.ts 一开始被误判为死代码,实际 express/waybill 在用,不要删。 (原因是该目录名自带点号,脚本早期用 path.extname 判断扩展名导致解析失败,已修复。)

五、删除前必须做的核对

因为 import.meta.glob 兜底的存在,静态不可达 ≠ 可以删。删之前请确认后端菜单 component 字段没有指向待删路径:

  1. 导出菜单表里所有 component 字段值(形如 order/waveOrder、system/setting/role/index)
  2. 与上表路径求交集,有交集的一律保留
  3. 更省事的做法:直接在浏览器里按后台配的菜单逐个点一遍,确认页面不是待删文件
  4. 特别注意 map.ts 里那些值相同、key 不同的兼容项,例如:
    • system/setting/basicManagement / system/setting/basicManagement/index / basicManagement → 全部指向 newview
    • video/camera/index → newcamara;video/cameraServer/index → newcamaraserver
    • system/setting/workbench/index → workbench2
    • stock/combo_stock 相关 key 已注释掉(combo_stock 现为 stockManagement 内的标签页)

六、如何复跑

node scripts/find-unused-modules.mjs            # 完整报告
node scripts/find-unused-modules.mjs --views-only  # 只看页面

脚本会打印分组清单 + 目录级汇总,并把机器可读结果写到 unused-report.json。

判定口径:

  • 静态可达:从 src/main.ts 经 import / import() / require() / SCSS @use / @import 可达
  • glob 兜底:被 import.meta.glob(...) 模式匹配
  • 死代码:以上都不属于

已知盲区:仅覆盖 src 目录;不解析 component 字段的字符串拼接路径(本项目已确认无此类写法)。