From 91dd317867f049c12232c380c4f23d32717a6a0e Mon Sep 17 00:00:00 2001
From: yin <3313488199@qq.com>
Date: Sat, 17 Oct 2026 18:05:39 +0800
Subject: [PATCH] 1
---
src/App.vue | 80 ++++++-
src/composables/useEntryScene.ts | 3 +-
src/composables/useEntrySections.ts | 10 +-
src/composables/useLegalLinks.ts | 60 +++++
src/main.ts | 6 +
src/manifest.json | 4 +
src/pages.json | 20 --
src/pages/index/index.vue | 22 +-
src/pages/login/confirm-login.vue | 2 +-
src/pages/mine/mine.vue | 33 ++-
src/pages/mine/user-info.vue | 45 ++--
src/pagesA/demo/required.vue | 120 ----------
src/pagesA/test/index.vue | 338 ----------------------------
src/pagesA/tools/barcode.vue | 26 +--
src/pagesA/tools/calculator.vue | 3 +-
src/router/entries.ts | 20 +-
src/router/pages.ts | 42 +---
src/router/scenes.ts | 11 +-
src/shims-wx.d.ts | 16 +-
src/sitemap.json | 9 +
src/store/modules/permission.ts | 4 +-
src/store/modules/user.ts | 11 +-
src/utils/debug-log.ts | 22 ++
src/utils/identity-log.ts | 5 +-
src/utils/wechat.ts | 7 +-
微信小程序开发清单.md | 73 ++++--
26 files changed, 354 insertions(+), 638 deletions(-)
create mode 100644 src/composables/useLegalLinks.ts
delete mode 100644 src/pagesA/demo/required.vue
delete mode 100644 src/pagesA/test/index.vue
create mode 100644 src/sitemap.json
create mode 100644 src/utils/debug-log.ts
diff --git a/src/App.vue b/src/App.vue
index cfa9819..6d6421d 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,5 +1,5 @@
diff --git a/src/composables/useEntryScene.ts b/src/composables/useEntryScene.ts
index d55a0db..7f357e5 100644
--- a/src/composables/useEntryScene.ts
+++ b/src/composables/useEntryScene.ts
@@ -16,13 +16,14 @@
import { onShow } from '@dcloudio/uni-app'
import { takePendingEntry } from '@/utils/entry'
import { handleEntryScene } from '@/router/scenes'
+import { debugLog } from '@/utils/debug-log'
export function useEntryScene(): void {
onShow(() => {
const entry = takePendingEntry()
if (!entry) return
- console.log('[entry] 消费待处理入口', entry)
+ debugLog('[entry] 消费待处理入口', { scene: entry.scene, page: entry.page })
handleEntryScene(entry).catch((err) => {
// 入口处理失败不能影响页面正常渲染
console.warn('[entry] 入口场景处理失败', err)
diff --git a/src/composables/useEntrySections.ts b/src/composables/useEntrySections.ts
index 21dd381..fac8e9e 100644
--- a/src/composables/useEntrySections.ts
+++ b/src/composables/useEntrySections.ts
@@ -1,14 +1,14 @@
/**
* 首页入口区渲染状态
*
- * 首页的入口区 = **动态菜单段**(`user.info` 的 menus × `PAGE_REGISTRY`)+ **本地「工具」段**
+ * 首页的入口区 = **动态菜单段**(`user.info` 的 menus × `PAGE_REGISTRY`)+ **本地「辅助工具」段**
* (`LOCAL_COMMON_ENTRIES`,前端写死),两段形态一致、动态段在前,合成逻辑在 `toHomeSections()`。
*
* 这个 composable 负责把「取数 / 加载态 / 空态文案 / 点击跳转」收口在一处,
* 页面只负责 `onShow` 调一次 `loadEntries()`,然后把 `sections` 交给模板。
*
* 登录态差异(2026-10-14 起):
- * - 「工具」段不依赖接口 ⇒ **未登录时也一定有内容**,不再是「空态 + 去登录」那种形态
+ * - 「辅助工具」段不依赖接口 ⇒ **未登录时也一定有内容**,不再是「空态 + 去登录」那种形态
* - 未登录 / 未绑定 / 拉取失败只影响「动态菜单段」有无;已登录但拉不到菜单时,
* 页面用 `hasDynamicEntries` 判断并给一条**轻量重试提示**(工具段照常可用,不阻断)
* - `emptyStateProps` 只在**连本地段都为空**时才会走到(正常配置下不会出现,留作兜底)
@@ -37,7 +37,7 @@ export interface UseEntrySectionsReturn {
/**
* 动态菜单段是否有内容
*
- * 首页用它判断「已登录但菜单没拉回来」:此时「工具」段仍在,不白屏,
+ * 首页用它判断「已登录但菜单没拉回来」:此时「辅助工具」段仍在,不白屏,
* 只需在那之下补一条轻量重试提示(不用大块空态盖住可用内容)。
*/
hasDynamicEntries: ComputedRef
@@ -73,7 +73,7 @@ export function useEntrySections(
const loading = ref(false)
- /** 入口分段 = 动态菜单段(在前)+ 本地「工具」段(固定在后,不登录也渲染) */
+ /** 入口分段 = 动态菜单段(在前)+ 本地「辅助工具」段(固定在后,不登录也渲染) */
const sections = computed(() => toHomeSections(permissionStore.entries, { looseTitle }))
/** 动态菜单段是否有内容(未登录 / 未绑定 / 失败时都为 false) */
@@ -82,7 +82,7 @@ export function useEntrySections(
/**
* 空态文案(按“为什么是空的”分三种,**不要用服务端故障文案盖住未登录场景**)
*
- * ⚠️ 只在**连本地「工具」段都为空**(`LOCAL_COMMON_ENTRIES` 为空)时才会显示 ——
+ * ⚠️ 只在**连本地「辅助工具」段都为空**(`LOCAL_COMMON_ENTRIES` 为空)时才会显示 ——
* 正常配置下首页永远至少有工具段,走不到这里,这里只做「绝不白屏」的兜底。
*
* | 场景 | 文案 | 动作 |
diff --git a/src/composables/useLegalLinks.ts b/src/composables/useLegalLinks.ts
new file mode 100644
index 0000000..566c399
--- /dev/null
+++ b/src/composables/useLegalLinks.ts
@@ -0,0 +1,60 @@
+/**
+ * 协议与隐私入口(「我的」页等公共位置共用)
+ *
+ * 为什么抽成 composable:
+ * 这两个入口属于**全局信息**、且**不依赖登录**,放在多个页面里各写一份很容易出现
+ * 「一处改了另一处没改」的漂移(本项目已经踩过注释/文案漂移的坑)。
+ *
+ * 用法:
+ * ```vue
+ * const { agreementVisible, openAgreement, openPrivacyContract } = useLegalLinks()
+ * ```
+ * ```vue
+ *
+ *
+ * ```
+ */
+
+import { ref } from 'vue'
+import type { Ref } from 'vue'
+
+export interface UseLegalLinksReturn {
+ /** 《用户须知》弹窗是否显示(页面用 `v-model:show` 绑定 ``) */
+ agreementVisible: Ref
+ /** 打开《用户须知》(`view` 只读模式,不要求滑到底) */
+ openAgreement: () => void
+ /** 打开微信官方《小程序用户隐私保护指引》 */
+ openPrivacyContract: () => void
+}
+
+export function useLegalLinks(): UseLegalLinksReturn {
+ const agreementVisible = ref(false)
+
+ const openAgreement = (): void => {
+ agreementVisible.value = true
+ }
+
+ /**
+ * 打开微信侧的《小程序用户隐私保护指引》
+ *
+ * 内容由公众平台后台「设置 → 服务内容声明 → 用户隐私保护指引」配置,不是小程序自己的页面;
+ * 用户在**未登录**状态下也可以查看(这正是它必须放在一级页的原因)。
+ *
+ * ⚠️ `wx.openPrivacyContract` 仅微信小程序端存在 ⇒ 必须条件编译,
+ * 否则 H5 / App 端运行时会报 `wx is not defined`。
+ */
+ const openPrivacyContract = (): void => {
+ // #ifdef MP-WEIXIN
+ wx.openPrivacyContract({
+ fail: () => uni.$u.toast('打开失败,可在右上角「…」→ 设置 中查看')
+ })
+ return
+ // #endif
+
+ // #ifndef MP-WEIXIN
+ uni.$u.toast('请在微信小程序中查看')
+ // #endif
+ }
+
+ return { agreementVisible, openAgreement, openPrivacyContract }
+}
diff --git a/src/main.ts b/src/main.ts
index ea37dbd..c451d65 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -10,6 +10,12 @@ export function createApp() {
app.use(Pinia.createPinia());
// 注册 uview-plus,注册后才可使用 uni.$u 等全局工具方法
app.use(uviewPlus);
+
+ // 本项目只有**一套浅色设计**(背景 / 卡片 / 文字都是写死的浅色调),不做深色模式。
+ // uview-plus 默认跟随系统主题,深色模式下会把文字算成 #f5f5f5、弹层背景算成 #1c1c1e
+ // ⇒ 白底白字 / 深底深字。这里强制锁成浅色(会写入 storage `u-theme-mode`,后续启动一致)。
+ uni.$u.setThemePreference('light')
+
return {
app,
Pinia,
diff --git a/src/manifest.json b/src/manifest.json
index bde5f14..4d865a6 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -59,6 +59,10 @@
上传模板代码 / 作为开放平台模板发布时,记得切回模板小程序 AppID。 */
"appid" : "wx31f8d1ee127bc64b",
"projectname" : "wms_mp_weixin",
+ /* 明确声明**不做**深色模式适配(本项目只有浅色设计)。
+ uni-app 会把该字段写进产物 app.json;
+ 如将来要真正支持深色,需改 true + 配置 themeLocation 并逐页改造配色。 */
+ "darkmode" : false,
/* 微信开发者工具项目设置 */
"setting" : {
/* 是否校验安全域名与 TLS 版本:仅影响开发者工具内的请求校验,
diff --git a/src/pages.json b/src/pages.json
index 3fdf2e9..21fd53e 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -43,18 +43,6 @@
{
"root": "pagesA",
"pages": [
- {
- "path": "demo/required",
- "style": {
- "navigationBarTitleText": "需登录示例"
- }
- },
- {
- "path": "test/index",
- "style": {
- "navigationBarTitleText": "测试页"
- }
- },
{
"path": "tools/calculator",
"style": {
@@ -167,14 +155,6 @@
"name": "条形码",
"path": "pagesA/tools/barcode"
},
- {
- "name": "需登录示例页",
- "path": "pagesA/demo/required"
- },
- {
- "name": "测试页",
- "path": "pagesA/test/index"
- },
{
"name": "外仓商品",
"path": "pagesA/external-stock/list"
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 16648a9..e38679e 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -27,7 +27,7 @@
-
+
@@ -37,13 +37,13 @@
-
+
登录以使用更多功能
-
-
-
-
-
diff --git a/src/pagesA/test/index.vue b/src/pagesA/test/index.vue
deleted file mode 100644
index 9092c4b..0000000
--- a/src/pagesA/test/index.vue
+++ /dev/null
@@ -1,338 +0,0 @@
-
-
-
-
-
-
-
-
- 页面信息
-
-
-
-
-
-
-
-
- 当前账号
-
-
-
-
-
-
-
-
-
-
- 后端菜单(根节点 {{ permissionStore.menus.length }} 个)
-
-
- 后端没有下发任何菜单 → 说明 platform=miniProgram 时 menus 未取自
- miniprogram_pages,或当前账号的角色未授权 628。
-
-
-
- 下列 path 若包含 /test/index,说明后端已按 miniprogram_pages 下发。
-
- {{ item }}
- …(只显示前 30 条)
-
-
-
-
- 入口解析结果
-
-
-
-
-
- 以下 key 后端下发了但本地未登记(会被忽略):
-
-
- {{ item }}
-
-
-
- 身份 / token 诊断
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 现象对照:① 「本地选中身份ID」≠「user.info 身份ID」→ 前端状态与服务端不同步;
- ② 「token.current_role_id」还是旧身份 → 新 token 没落地,
- 切换后重进小程序必然变回旧身份(后端按 (账号, platform_code) 记当前身份)。
-
-
-
-
-
-
-
- 身份操作流水(最新在前)
- 暂无记录
-
-
- {{ item.at }}
- {{ item.event }}
-
- {{ item.detail }}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pagesA/tools/barcode.vue b/src/pagesA/tools/barcode.vue
index e3ef13d..01795c6 100644
--- a/src/pagesA/tools/barcode.vue
+++ b/src/pagesA/tools/barcode.vue
@@ -29,16 +29,6 @@
@click="copyContent"
>
-
-
-
(value * windowWidth) / 750
/** 可用宽度 = 屏宽 −(页面左右 24rpx + 卡片左右 32rpx) */
@@ -209,14 +198,11 @@ function copyContent(): void {
uni.setClipboardData({
data: text,
- fail: () => uni.$u.toast('复制失败')
+ // 剪切板是隐私接口(官方清单「读取你的剪切板」):未声明/未同意时会直接失败
+ fail: () => uni.$u.toast('复制失败,请确认已同意《隐私保护指引》')
})
}
-function useSample(): void {
- content.value = SAMPLE
-}
-
function reset(): void {
content.value = ''
}
diff --git a/src/pagesA/tools/calculator.vue b/src/pagesA/tools/calculator.vue
index fd8a968..4c95249 100644
--- a/src/pagesA/tools/calculator.vue
+++ b/src/pagesA/tools/calculator.vue
@@ -364,7 +364,8 @@ function copyResult(): void {
uni.setClipboardData({
data: text,
- fail: () => uni.$u.toast('复制失败')
+ // 剪切板是隐私接口(官方清单「读取你的剪切板」):未声明/未同意时会直接失败
+ fail: () => uni.$u.toast('复制失败,请确认已同意《隐私保护指引》')
})
}
diff --git a/src/router/entries.ts b/src/router/entries.ts
index 078195f..ac88920 100644
--- a/src/router/entries.ts
+++ b/src/router/entries.ts
@@ -11,7 +11,7 @@
* | 未命中 | **忽略该项**,记入 `missing`(不影响其它入口,由调用方告警) |
* | 分组节点无子项命中 | 整组丢弃(避免渲染出空分组) |
* | `hidden = 1` | 不进导航入口 |
- * | `common: true` 的本地页面 | 无论后端是否下发,都进首页「工具」段(见 `LOCAL_COMMON_ENTRIES`) |
+ * | `common: true` 的本地页面 | 无论后端是否下发,都进首页「辅助工具」段(见 `LOCAL_COMMON_ENTRIES`) |
*
* ⚠️ **输出固定为两层**(`EntryGroup.children` 只能是 `EntryLeaf`):
* 小程序首页是「分组标题 + 子项九宫格」(决策点 4),
@@ -184,7 +184,7 @@ export function generateEntries(menus: MenuNode[] | null | undefined): GenerateE
}
/**
- * 首页「工具」—— **本地维护**的页面列表(与后端菜单无关)
+ * 首页「辅助工具」—— **本地维护**的页面列表(与后端菜单无关)
*
* 为什么单独搞一份:这个段要在**任何登录态 / 授权 / 接口故障 / 后端未配置**的情况下都稳定,
* 用来常驻放「必须有」或「随时要进」的页面(公开工具页关系到微信审核)。
@@ -269,23 +269,23 @@ export function toSections(nodes: EntryNode[], options: ToSectionsOptions = {}):
return sections
}
-/** 首页本地「工具」段的段标题(= `PageMeta.common` 选出来的那一组) */
-export const TOOLS_SECTION_TITLE = '工具'
+/** 首页本地「辅助工具」段的段标题(= `PageMeta.common` 选出来的那一组) */
+export const TOOLS_SECTION_TITLE = '辅助工具'
/**
- * 首页入口分段 = **动态菜单段** + **本地「工具」段**
+ * 首页入口分段 = **动态菜单段** + **本地「辅助工具」段**
*
- * 顺序(2026-10-14 定):**动态菜单段在前、「工具」段固定在后** ——
+ * 顺序(2026-10-14 定):**动态菜单段在前、「辅助工具」段固定在后** ——
* 业务功能随角色 / 权限变化,是首页主体;工具是固定入口,放最后不抢视线。
*
* 形态完全一致(都是「标题 + 子项九宫格」),差别只在来源:
* 前者由 `user.info` 的 `menus` 驱动,后者前端写死。
*
- * - **「工具」段无论是否登录都渲染**(纯本地清单、不看接口)⇒ 未登录时首页也一定有内容,
+ * - **「辅助工具」段无论是否登录都渲染**(纯本地清单、不看接口)⇒ 未登录时首页也一定有内容,
* 这正是微信审核「不能出现需登录才能看到任何内容」的落点
* - **去重**:本地段里已有的 key 会从动态段中剔除
- * (后端也配了同一个页面时,只在「工具」段出现一次)
- * - 动态段为空(未登录 / 后端没配 / 拉取失败)时,结果就是纯粹的「工具」段
+ * (后端也配了同一个页面时,只在「辅助工具」段出现一次)
+ * - 动态段为空(未登录 / 后端没配 / 拉取失败)时,结果就是纯粹的「辅助工具」段
*/
export function toHomeSections(
nodes: EntryNode[],
@@ -302,7 +302,7 @@ export function toHomeSections(
sections.push({ ...section, leaves })
}
- // ② 本地「工具」段:固定最后、固定存在
+ // ② 本地「辅助工具」段:固定最后、固定存在
if (LOCAL_COMMON_ENTRIES.length) {
sections.push({ key: 'tools', title: TOOLS_SECTION_TITLE, leaves: LOCAL_COMMON_ENTRIES })
}
diff --git a/src/router/pages.ts b/src/router/pages.ts
index c93b085..eae32a1 100644
--- a/src/router/pages.ts
+++ b/src/router/pages.ts
@@ -42,13 +42,13 @@ export interface PageMeta {
/** 是否不进导航入口(九宫格 / 功能菜单):可被跳转,但不作为入口展示 */
hidden?: boolean
/**
- * 是否进首页**本地**「工具」列表
+ * 是否进首页**本地**「辅助工具」列表
*
* - **必须显式写 `common: true` 才会进**(不设置 = 不进)
* - 该列表在 `router/entries.ts` 的 `LOCAL_COMMON_ENTRIES`,**与后端菜单无关**:
* 不受登录态 / 授权 / 接口故障 / 后端是否配置影响 → 「无论是否登录都会显示」
* - 后端 `miniprogram_pages` 只负责「登录后**还**能看到什么」,
- * 在首页以**分类段**(如「外仓商品」)排在「工具」段**前面**;两处重复的 key 会自动去重
+ * 在首页以**分类段**(如「外仓商品」)排在「辅助工具」段**前面**;两处重复的 key 会自动去重
*
* ⚠️ `auth: 'public'` 的页面请一并标 `common: true` —— 否则未登录时首页会没有任何入口
*(微信审核要求「不能需登录才能看到任何内容」)
@@ -107,9 +107,9 @@ export const PAGE_REGISTRY: PageMeta[] = [
hidden: true
},
- // ─────────────── 工具(分包 pagesA):首页「工具」段,**不登录也能用** ───────────────
+ // ─────────────── 辅助工具(分包 pagesA):首页「辅助工具」段,**不登录也能用** ───────────────
// ⚠️ 这两页是「未登录也要有可浏览内容」这条微信审核要求的落点:
- // 标了 `common: true` ⇒ 常驻首页「工具」段(不受登录态 / 后端菜单 / 接口故障影响),
+ // 标了 `common: true` ⇒ 常驻首页「辅助工具」段(不受登录态 / 后端菜单 / 接口故障影响),
// 位置固定在**动态菜单段之后**(见 entries.ts 的 `toHomeSections`)。
{
key: '/tools/calculator',
@@ -128,31 +128,13 @@ export const PAGE_REGISTRY: PageMeta[] = [
common: true
},
- // ──────── 框架示例页(分包 pagesA):验证三态渲染与权限,业务页上线后可删 ────────
- {
- key: '/demo/required',
- path: 'pagesA/demo/required',
- title: '需登录示例',
- icon: 'lock',
- auth: 'required',
- // 需登录的页不进公共入口;登录后由后端菜单下发才出现在九宫格
- hidden: true
- },
- {
- key: '/test/index',
- path: 'pagesA/test/index',
- title: '测试页',
- icon: 'grid',
- auth: 'required',
- // 2026-10-14 起**不在首页展示**,两处一起堵:
- // - 去掉 `common: true` → 不再进本地「工具」段
- // - 加 `hidden: true` → 后端菜单(wms_permission id=628)下发了也不渲染入口
- // (只去掉 common 不够:登录后仍会由后端菜单那一侧冒出来)
- // 需要联调时:微信开发者工具「编译模式」选「测试页」直接进(pages.json 的 condition 已保留)
- hidden: true
- },
-
// ─────────────── 业务页(分包)───────────────
+ // ⚠️ 调试页已**彻底删除**(2026-10-17):
+ // `/demo/required`(需登录示例)与 `/test/index`(身份 / token 诊断页)——
+ // 页面文件、`pages.json`(含 `condition`)与 `PAGE_REGISTRY` 登记全部移除
+ // (提审自检要求「移除测试入口页」)。
+ // 今后若再需要临时诊断页:新建 .vue → 登记 `pages.json` + 这里 → 跑 `check:pages`,
+ // 并在**提审前**再次摘除(诊断页会显示身份 / 权限点 / token 指纹,不能上线)。
{
key: '/external-stock/list',
path: 'pagesA/external-stock/list',
@@ -161,7 +143,7 @@ export const PAGE_REGISTRY: PageMeta[] = [
auth: 'required'
// ⚠️ 后端 wms_permission 里这条记录的 path(type='miniprogram_pages')
// 必须与上面的 key **逐字符相等**,否则入口会被忽略并进 permissionStore.missing
- // 未设 common → 不进本地「工具」(它属于后端菜单那一侧)
+ // 未设 common → 不进本地「辅助工具」(它属于后端菜单那一侧)
// 不设 hidden → 登录后由后端菜单下发才出现,首页以「外仓商品」**分类段**展示
},
{
@@ -172,7 +154,7 @@ export const PAGE_REGISTRY: PageMeta[] = [
auth: 'required'
// 对应后端 id=642(父节点 641「外部仓库」分类,2026-10-14 新增)—— 同样必须与 key 逐字符相等
// 不设 hidden → 登录后由后端菜单下发才出现(未授权该页 id 的角色看不到)
- // 未设 common → 不进本地「工具」(它属于后端菜单那一侧)
+ // 未设 common → 不进本地「辅助工具」(它属于后端菜单那一侧)
// 接口 storeWarehouse.warehouse.list(**货主侧**,与 new3 views/warehouses 同源),
// 见 api/warehouse/external-warehouse.ts
},
diff --git a/src/router/scenes.ts b/src/router/scenes.ts
index 52d885d..354ab93 100644
--- a/src/router/scenes.ts
+++ b/src/router/scenes.ts
@@ -19,6 +19,7 @@
import { getPageByKey } from '@/router/pages'
import { navigateToPath } from '@/utils/navigate'
+import { debugLog } from '@/utils/debug-log'
import type { EntryInfo } from '@/utils/entry'
/** 场景处理函数签名 */
@@ -80,14 +81,8 @@ export async function handleEntryScene(entry: EntryInfo): Promise {
return
}
- console.log(
- `[entry] ${scene.name}:code =`,
- entry.code,
- '| userId =',
- entry.userId,
- '| extra =',
- entry.extra
- )
+ // ⚠️ 不打印 code / userId:前者是登录码(电脑端登录凭证),后者是用户标识
+ debugLog(`[entry] ${scene.name}`, { hasCode: Boolean(entry.code) })
await scene.handle(entry)
}
diff --git a/src/shims-wx.d.ts b/src/shims-wx.d.ts
index a4e3ca4..2d94816 100644
--- a/src/shims-wx.d.ts
+++ b/src/shims-wx.d.ts
@@ -5,7 +5,8 @@
* `@dcloudio/types` 的 `uni-app/uni-patches/wx/index.d.ts` 只声明了 `UniNamespace`
* 命名空间,**未**在编译单元内声明全局 `wx`,因此 uni-app 项目里直接写 `wx.xxx`
* 会报 `TS2304: Cannot find name 'wx'`。
- * 这里按需声明本项目用到的原生 API(目前只有 `wx.getAccountInfoSync`)。
+ * 这里按需声明本项目用到的原生 API(目前:`wx.getAccountInfoSync`、`wx.exitMiniProgram`、
+ * `wx.openPrivacyContract`)。
*
* 后续若原生调用变多,建议安装 `miniprogram-api-typings` 并加入 tsconfig 的 `types`,
* 然后删除本文件。
@@ -45,4 +46,17 @@ declare const wx: {
fail?: () => void
complete?: () => void
}): void
+
+ /**
+ * 打开《小程序用户隐私保护指引》页面(基础库 2.32.3+)
+ *
+ * 内容由公众平台后台「设置 → 服务内容声明 → 用户隐私保护指引」配置,
+ * 不是小程序自己的页面 —— 用户可随时复查隐私条款。
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/privacy/wx.openPrivacyContract.html
+ */
+ openPrivacyContract(options?: {
+ success?: () => void
+ fail?: () => void
+ complete?: () => void
+ }): void
}
diff --git a/src/sitemap.json b/src/sitemap.json
new file mode 100644
index 0000000..8aa1497
--- /dev/null
+++ b/src/sitemap.json
@@ -0,0 +1,9 @@
+{
+ "desc": "内部仓储管理系统(WMS):页面属于登录后的业务操作界面,不需要被微信搜索索引",
+ "rules": [
+ {
+ "action": "disallow",
+ "page": "*"
+ }
+ ]
+}
diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts
index 07a23d3..355450b 100644
--- a/src/store/modules/permission.ts
+++ b/src/store/modules/permission.ts
@@ -52,7 +52,9 @@ export const usePermissionStore = defineStore('permission', {
/**
* 用 `user.info` 的 menus 重建入口树
*
- * 后端 `miniprogram_pages` 已开始配置(测试页 628 + 外仓商品分类 630 / 页面 631):
+ * 后端 `miniprogram_pages` 现状(2026-10-17 实查 `wms.wms_permission`):
+ * 分类 630「外仓商品」+ 页面 631;分类 632「外仓库存」+ 633/637/638/639;
+ * 分类 641「外部仓库」+ 642 —— **没有任何测试页记录**(原 id=628 已删除)。
* 命中本地 `PAGE_REGISTRY` 的项成为入口,未命中的进 `missing`(只告警不报错)。
* 若当前角色未授权这些节点,`entries` 会是空数组,这是**预期行为**:
* UI 回退到本地公共入口 + 空态文案,不报错。
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 1687e2e..79bfad8 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -12,6 +12,7 @@
import { defineStore } from 'pinia'
import { getLoginChannel, getToken, removeToken, setLoginChannel, setToken } from '@/utils/auth'
import { appendIdentityLog } from '@/utils/identity-log'
+import { debugLog } from '@/utils/debug-log'
import { parseTokenPayload, tokenFingerprint } from '@/utils/token'
import type { LoginChannel } from '@/utils/auth'
import {
@@ -330,18 +331,14 @@ export const useUserStore = defineStore('user', {
*/
async wechatBind(payload: { username: string; password: string }): Promise {
const current = getToken()
- // 调试日志:确认「请求带了 token」(绑定失败最常见的原因是登录态丢了)
- console.log('[wechat] bindUser 发起', {
- username: payload.username.trim(),
- hasToken: !!current,
- tokenHead: current ? `${current.slice(0, 20)}...` : '(空)'
- })
+ // 只记「有没有带 token」:username / token / 用户对象都是敏感信息,不打日志
+ debugLog('[wechat] bindUser 发起', { hasToken: !!current })
const resp = await apiWechatBindUser({
username: payload.username.trim(),
password: payload.password
})
- console.log('[wechat] bindUser 返回', { flag: resp.flag, code: resp.code, user: resp.data?.user })
+ debugLog('[wechat] bindUser 返回', { flag: resp.flag, code: resp.code })
const token = resp.data?.token || ''
if (!token) {
diff --git a/src/utils/debug-log.ts b/src/utils/debug-log.ts
new file mode 100644
index 0000000..3f80d3b
--- /dev/null
+++ b/src/utils/debug-log.ts
@@ -0,0 +1,22 @@
+/**
+ * 开发期日志(生产构建自动失效)
+ *
+ * 为什么要这层封装:
+ * 1. `console.log` 会原样打进线上包,真机开调试模式就能看到 ——
+ * 里面一旦带**登录码 / token / 用户信息**就是信息泄露(安全风险,不是"代码不干净"那么简单)
+ * 2. 提审自检要求「移除调试代码 / console.log」,但排查问题又确实需要它
+ *
+ * 做法:只在 **开发态** 输出。Vite 在构建时会把 `import.meta.env.DEV` 折叠成常量,
+ * 生产包里这个分支直接消失(可用 `dist/build/mp-weixin/utils/debug-log.js` 验证)。
+ *
+ * ⚠️ 约定(比"用不用 debugLog"更重要):
+ * - **登录码 / token / 密码 / 完整用户对象** —— 连 `debugLog` 都不许打印,直接删
+ * - `console.warn` / `console.error` 保留:只用于异常诊断,同样不得带上述敏感数据
+ */
+
+/** 开发期日志:仅 `import.meta.env.DEV` 为真时输出 */
+export function debugLog(...args: unknown[]): void {
+ if (import.meta.env.DEV) {
+ console.log(...args)
+ }
+}
diff --git a/src/utils/identity-log.ts b/src/utils/identity-log.ts
index 960efc8..00159fe 100644
--- a/src/utils/identity-log.ts
+++ b/src/utils/identity-log.ts
@@ -9,7 +9,8 @@
* ## 开 / 关
* 把 `IDENTITY_LOG_ENABLED` 改成 `true` 即可启用:
* - store / App.vue 里的 `appendIdentityLog(...)` 调用**一直都在**(关闭时只是空转),无需改它们
- * - 测试页会自动出现「身份操作流水」卡(同一个开关控制)
+ * - 需要展示时调 `readIdentityLog()`(最新在前)——原先的测试页已于 2026-10-17 删除,
+ * 临时排查可新建一个页面/卡片直接渲染它
*
* 2026-09-26 首轮使用完毕(当时定位了后端 `user.changeRole` 写库正确但 token 用旧身份的缺陷,
* 后端已修复)⇒ 先关闭,不启用;以后再排查身份 / 菜单 / 权限类问题时再打开。
@@ -19,7 +20,7 @@
* ⇒ 「退出登录 → 重新登录」以及「重进小程序」之后,仍然能看到切换前后的全过程
* 2. **只记关键字段**(身份 id / store / token 指纹),**绝不记完整 token**(凭证不进日志/截图)
*
- * 清空入口:测试页「身份操作流水」卡的「清空流水」按钮,或开发者工具「清除数据缓存」。
+ * 清空入口:`clearIdentityLog()`,或开发者工具「清除数据缓存」。
*/
/** 总开关:`false` = 不记录、不展示(埋点调用保留,空转) */
diff --git a/src/utils/wechat.ts b/src/utils/wechat.ts
index 2a97073..15c2538 100644
--- a/src/utils/wechat.ts
+++ b/src/utils/wechat.ts
@@ -19,15 +19,14 @@
*
* 开发者工具中若项目未填 AppID,这里会拿到 `touristappid`(调用方按「拿不到」处理即可)。
*/
+import { debugLog } from '@/utils/debug-log'
export function getMiniProgramAppid(): string {
let appid = ''
// #ifdef MP-WEIXIN
try {
const accountInfo = wx.getAccountInfoSync()
- // 调试输出:在微信开发者工具控制台核对运行时真实 AppID
- // (重点看 miniProgram.appId;envVersion=develop/trial/release 可确认当前环境)
- console.log('[wechat] wx.getAccountInfoSync() =', accountInfo)
- console.log('[wechat] 小程序 AppID =', accountInfo.miniProgram.appId, '环境 =', accountInfo.miniProgram.envVersion)
+ // 开发期日志:核对运行时真实 AppID 与环境(生产构建自动失效,见 utils/debug-log)
+ debugLog('[wechat] 小程序 AppID =', accountInfo.miniProgram.appId, '环境 =', accountInfo.miniProgram.envVersion)
appid = accountInfo.miniProgram.appId || ''
} catch (err) {
diff --git a/微信小程序开发清单.md b/微信小程序开发清单.md
index c6d02b3..d17ce0d 100644
--- a/微信小程序开发清单.md
+++ b/微信小程序开发清单.md
@@ -23,21 +23,21 @@
| 分包(pages.json 注册) | 🚧 部分注册 | `pagesA` 已注册(当前放框架示例页);`pagesB` / `pagesC` 待业务页一起注册 |
| 请求封装(第 5 节) | ✅ 已完成 | `utils/request.ts`,对齐 new3,含 token 注入 / 响应头续期 / 401 处理 |
| 登录鉴权(第 6 节) | ✅ 已完成 | 账号密码登录 + 注册;登录入口在「我的」页头部(启动页为首页,不强制登录);401 按需引导登录 |
-| 「我的」页结构 | ✅ 已完成(2026-09-22) | **菜单 + 二级页面**:本页只留「登录入口 + 菜单」;细项全收进 `pages/mine/user-info`(用户信息 / 待绑定 WMS 账号 / 微信资料 / 电脑端登录码 / 退出登录) |
+| 「我的」页结构 | ✅ 已完成(2026-09-22,10-17 增协议入口) | **菜单 + 二级页面**:本页只留「登录入口 + 菜单 + 协议与隐私」;细项全收进 `pages/mine/user-info`(用户信息 / 待绑定 WMS 账号 / 微信资料 / 电脑端登录码 / 退出登录)。
⚠️ 用户须知 / 隐私保护指引 **不依赖登录**,所以不能放二级页(未登录进不去),统一放本页 |
| Pinia 状态管理(第 8 节) | ✅ 已完成 | `pinia@2.1.7`(Vue 3.4 兼容版),见 `store/modules/user.ts` |
| 环境变量(第 11 节) | ✅ 已完成 | `.env.development` / `.env.production`:`VITE_APP_BASE_API` / `VITE_APP_PLATFORM` / `VITE_APP_PROJECT` |
| 静态路由表(阶段 1) | ✅ 已完成 | `src/router/pages.ts`:`PAGE_REGISTRY`(逻辑路径 → 物理页面 + `auth` 策略)+ `PAGE_MAP`;配置 `npm run check:pages` 一致性校验 |
| 菜单/权限 store(阶段 2) | ✅ 已完成 | `src/router/entries.ts`(菜单 × 路由表 → 入口树)+ `store/modules/permission.ts`;`getInfo()` 触发时机收口到「登录成功 / 启动带 token / 切换身份」 |
| 三态渲染组件(阶段 3) | ✅ 已完成 | `composables/usePageAuth.ts` + `components/auth-gate/`(public / optional / required)+ `components/empty-state/`(统一空态文案 + 重试);「去登录」收口到 `goLogin()` |
| 页面接入(阶段 4) | ✅ 已完成 | 首页九宫格改为 store 驱动(分组标题 + 子项两层渲染,空态走 `empty-state`);「我的」新增功能菜单 |
-| 首页入口分段(2026-10-14) | ✅ 已完成 | **动态菜单段(在前)+ 本地「工具」段(固定在后)**,合成逻辑在 `router/entries.ts` 的 `toHomeSections()`;「工具」段 = `common: true` 的页面(计算器 / 条形码),**与登录态、后端菜单、接口无关 ⇒ 未登录也一定显示**(微信审核要求)。已删除原 `pagesA/demo/public.vue`(被计算器页取代) |
+| 首页入口分段(2026-10-14,段名 10-17 改为「辅助工具」) | ✅ 已完成 | **动态菜单段(在前)+ 本地「辅助工具」段(固定在后)**,合成逻辑在 `router/entries.ts` 的 `toHomeSections()`;「辅助工具」段 = `common: true` 的页面(计算器 / 条形码),**与登录态、后端菜单、接口无关 ⇒ 未登录也一定显示**(微信审核要求)。已删除原 `pagesA/demo/public.vue`(被计算器页取代) |
| 页面渲染框架 | 🚧 开发中(阶段 1、2、2.5、3、4 已完成) | 见第 12 节与《页面渲染框架-设计与任务清单.md》 |
| 身份(角色/仓库)展示 | ✅ 已完成 | 「我的」页登录后显示:姓名 / 身份类型 / 所属组织 / 员工 ID / 授权到期;数据来自 `user.info` 的 `employees[]`,**不改数据库** |
| 身份切换 `changeRole` | 🚧 已实现待联调 | 入口在「我的」页(多身份时出现);接口已实测存在,返回结构待后端确认 |
| 微信一键登录 | ✅ 已完成 | `wechat.loginByCode`(不是 `user.loginByCode`);AppID 运行时取(`wx.getAccountInfoSync`,适配开放平台模板多仓库);token 立即落地(未绑定也算免登录态);绑定可跳过、入口常驻「我的」页 |
| 微信资料(昵称/头像) | ✅ 已完成(2026-09-22) | `wechat.updateInfo`(改昵称)+ `wechat.uploadHeadimg`(传头像);走微信「头像昵称填写能力」(`chooseAvatar` + `input type=nickname`),头像经 `utils/avatar.ts` 裁剪转 PNG(<500K)后上传;入口仅未绑定态可见 |
| 我的登录码(电脑端登录) | ✅ 已完成(2026-09-22) | `wechat.getMyLoginCode`(无入参,码**稳定不变**);入口在「我的」页(需微信登录态);同时新增登录渠道记录 `login_channel` |
-| 用户须知(协议文案) | ✅ 已完成(2026-09-23) | 弹窗抽为共享组件 `components/agreement-modal/`(`agree` 勾选 / `view` 只读);入口两处:登录面板勾选区 + 「用户信息」页;正文后端下发(免登录按 AppID / 已登录按仓库),本地常量仅兵底 |
+| 用户须知(协议文案) | ✅ 已完成(2026-09-23) | 弹窗抽为共享组件 `components/agreement-modal/`(`agree` 勾选 / `view` 只读);入口两处:登录面板勾选区 + **「我的」页**(2026-10-17 由「用户信息」页移来,因为未登录时二级页不可达);正文后端下发(免登录按 AppID / 已登录按仓库),本地常量仅兜底 |
> 📄 **配套文档**:`页面渲染框架-设计与任务清单.md` —— 菜单 / 权限 / 页面渲染的决策与任务清单(第 12 节为摘要)
> ⚠️ **已知坑**:同时跑两个 `dev:mp-weixin` 进程会写坏产物,导致预览报
@@ -103,9 +103,12 @@
- [x] **`transformPx` 保持 `false`** ✅
该选项已废弃,仅部分平台生效,新项目不推荐开启(当前已是 `false`,保持即可)。
-- [ ] **(暂缓)配置 `sitemap.json`**
- 不配置时微信使用默认索引规则(收录全部页面)。
- 内部仓储工具通常不需要被微信搜索收录,故暂缓;若需禁止收录或精细控制,再补该文件。
+- [x] **配置 `sitemap.json`** ✅ 2026-10-17
+ `src/sitemap.json`(构建后原样拷到产物根目录,已实测)→ 全部页面 `disallow`:
+ 内部仓储工具不应被微信搜索收录,也避免业务页面被外部检索到。
+ ```json
+ { "rules": [{ "action": "disallow", "page": "*" }] }
+ ```
- [x] **不要提交个人调试配置** ✅
微信开发者工具会在打开的产物目录生成 `project.private.config.json`;
@@ -153,15 +156,17 @@ d:\wechat\
│ ├── auth-guard.ts # 登录跳转(LOGIN_PAGE / redirectToLogin,不做全局拦截)
│ ├── barcode.ts # Code128(B) 编码(输出条空宽度序列,供工具页渲染)
│ ├── calculator.ts # 四则运算求值(自写解析器,不用 eval)
+ │ ├── debug-log.ts # 开发期日志(生产构建自动空转)
│ ├── navigate.ts # 统一跳转(自动区分 switchTab / navigateTo)
│ └── request.ts # uni.request 封装
├── pages/ # 主包页面(启动页 + tabBar 页)
│ ├── login/login.vue # 登录 / 注册页(非启动页,仅 401 兜底 / 直接访问)
- │ ├── index/index.vue # 首页(启动页):动态菜单段 + 本地「工具」段
+ │ ├── index/index.vue # 首页(启动页):动态菜单段 + 本地「辅助工具」段
│ └── mine/mine.vue # 我的
+ ├── sitemap.json # 禁止微信搜索索引(全部 disallow)
├── pagesA/ # 分包 A(已注册)
- │ ├── tools/ # 计算器 / 条形码(公共工具页,`common: true` → 首页「工具」段)
- │ └── demo/ # required.vue(需登录 + 按钮级权限示例)
+ │ ├── tools/ # 计算器 / 条形码(公共工具页,`common: true` → 首页「辅助工具」段)
+ │ └── external-*/ # 业务页(外仓商品 / 外部仓库 / 收货单 / 库存报表 / 入库单 / 商品流水)
├── pagesB/ # 分包 B(规划:出库,待注册)
├── pagesC/ # 分包 C(规划:库存/盘点,待注册)
└── static/ # 静态资源
@@ -480,13 +485,24 @@ d:\wechat\
## 7. 权限与隐私合规(提审重点)
-- [ ] **梳理隐私接口清单**
- 涉及定位、相册、摄像头、麦克风、剪贴板、通讯录、蓝牙等的 API 需逐一确认。
- 仓储场景重点:**扫码(摄像头)、上传图片(相册/相机)、定位(如库位导航)、蓝牙打印**。
+- [x] **梳理隐私接口清单** ✅ 2026-10-17
+ 全仓搜索确认**实际只用两个**隐私能力(其余定位/相册/相机/麦克风/通讯录/蓝牙/手机号均未使用,
+ `manifest` 也没有 `permission` / `requiredPrivateInfos`,与实际一致):
-- [ ] **配置《小程序用户隐私保护指引》**
- 微信公众平台 → 设置 → 基本设置 → 服务内容声明 → 用户隐私保护指引,声明实际收集的信息类型。
- 未声明而调用隐私接口,会在真机上被拦截。
+ | 用到的能力 | 代码位置 | 官方清单归属 |
+ |---|---|---|
+ | `