diff --git a/.github/workflows/coding-linter.yml b/.github/workflows/coding-linter.yml index 6a2eeb0e..b12f9183 100644 --- a/.github/workflows/coding-linter.yml +++ b/.github/workflows/coding-linter.yml @@ -80,32 +80,17 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v7 - - name: Setup Node - uses: actions/setup-node@v6 - with: - node-version: latest - - name: Install pnpm - uses: pnpm/action-setup@v6 - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash + - name: Setup Deno + uses: denoland/setup-deno@v2 + - name: Install dependencies run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - name: Setup pnpm cache - uses: actions/cache@v6 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Run pnpm install + deno install + - name: Run biome check run: | - pnpm i - - name: Run pnpm lint + deno task biome:check + - name: Run type check run: | - pnpm biome:check + deno task typecheck lint-frontend-totp: name: "Frontend: Lint (TOTP)" @@ -124,3 +109,6 @@ jobs: - name: Run biome check run: | deno task biome:check + - name: Run type check + run: | + deno task typecheck diff --git a/AGENTS.md b/AGENTS.md index 09896f95..3c7e1537 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,7 +21,7 @@ yansongda-application/ │ ├── application-util/ # 第三方 HTTP 对接(微信/华为) │ └── database/ # SQL 迁移脚本 ├── wechat/miniprogram/ -│ ├── yansongda/ # 主微信小程序(pnpm) +│ ├── yansongda/ # 主微信小程序(Deno) │ └── totp/ # TOTP 独立微信小程序(Deno) └── huawei/atomicservice/MFA/ # 华为元服务(ohpm / Hvigor) └── entry/src/main/ets/ # ArkTS 业务代码 @@ -59,7 +59,7 @@ yansongda-application/ ## CONVENTIONS - 跨前后端改动时,分别遵循对应目录下的 `AGENTS.md`,不要用一端规则约束另一端。 -- 必须提交的锁文件:`Cargo.lock`、`pnpm-lock.yaml`(yansongda)、`deno.lock`(totp)、`oh-package-lock.json5`(华为)。 +- 必须提交的锁文件:`Cargo.lock`、`deno.lock`(yansongda / totp)、`oh-package-lock.json5`(华为)。 - 禁止提交的敏感内容:`config.toml`、`*.private.*`、密钥、Token、密码、生产连接串。 - 禁止提交的构建/IDE 目录:`target/`、`node_modules/`、`miniprogram_npm/`、`oh_modules/`、`.idea/`、`.vscode/`。 - 影响公共 API / 配置 / 数据结构时,需说明兼容策略与迁移方式。 @@ -75,7 +75,7 @@ yansongda-application/ ## UNIQUE STYLES -- **多包管理器并存**:后端 cargo,微信主小程序 pnpm,TOTP 小程序 Deno,华为 ohpm。 +- **多包管理器并存**:后端 cargo,微信主小程序 Deno,TOTP 小程序 Deno,华为 ohpm。 - **Rust workspace 使用较新的工具链特性**,依赖使用 `~` 约束。 - **无 ORM 的数据库层**:通过自定义宏(`query_optional!` / `insert!` / `update!` / `delete!`)统一记录 SQL、耗时和参数。 - **微信/华为前端共享同一后端**,但登录方式不同:微信用 `wx.login` code,华为用 HuaweiID authorizationCode。 @@ -92,8 +92,9 @@ cargo test --all-features cargo build --release # 微信主小程序(在 wechat/miniprogram/yansongda/ 下执行) -pnpm i -pnpm biome:check +deno install +deno task biome:check +deno task typecheck # TOTP 微信小程序(在 wechat/miniprogram/totp/ 下执行) deno install @@ -106,7 +107,7 @@ deno task typecheck ## NOTES - `application-rs/AGENTS.md` 中已修正:移除不存在的 `application-macro/` 目录;CI 不运行 `cargo test`。 -- `wechat/miniprogram/yansongda/` 当前缺失 `pnpm-lock.yaml`(AGENTS.md 要求提交),请检查是否被 gitignore 或未生成。 +- `wechat/miniprogram/yansongda/` 已迁移到 Deno,锁文件为 `deno.lock`。 - 华为 `build-profile.json5` 包含本地签名证书路径与明文密码,仅用于本地开发,禁止用于生产。 - 后端 `middleware.rs` 与 `application-util/src/http.rs` 当前会记录完整 headers,后续需脱敏 `Authorization` 等敏感头。 - 三个前端均无实际业务测试;Rust 后端仅有少量单元测试,CI 不执行测试。 diff --git a/wechat/miniprogram/totp/AGENTS.md b/wechat/miniprogram/totp/AGENTS.md index 50df24e5..2ace8be4 100644 --- a/wechat/miniprogram/totp/AGENTS.md +++ b/wechat/miniprogram/totp/AGENTS.md @@ -75,4 +75,4 @@ deno task typecheck # TypeScript 类型检查(tsc --noEmit) ## NOTES - 与 `yansongda` 主小程序共享 `utils/error.ts`、`utils/logger.ts`、`utils/string.ts`、`models/error.ts`、`types/http.d.ts` 等代码,但当前无正式共享包,分别独立维护。 -- 当前 CI 仅执行 `deno task biome:check`;`deno task typecheck` 尚未接入 CI,提交前建议本地手动执行。 +- 当前 CI 已接入 `deno task biome:check` 与 `deno task typecheck`。 diff --git a/wechat/miniprogram/totp/tsconfig.json b/wechat/miniprogram/totp/tsconfig.json index 94a40483..d7396aea 100644 --- a/wechat/miniprogram/totp/tsconfig.json +++ b/wechat/miniprogram/totp/tsconfig.json @@ -22,7 +22,10 @@ "baseUrl": ".", "skipLibCheck": true, "paths": { - "tdesign-miniprogram/*": ["src/miniprogram_npm/tdesign-miniprogram/*"], + "tdesign-miniprogram/*": [ + "src/miniprogram_npm/tdesign-miniprogram/*", + "node_modules/tdesign-miniprogram/miniprogram_dist/*" + ], "@api/*": ["src/api/*"], "@utils/*": ["src/utils/*"], "@constant/*": ["src/constant/*"], diff --git a/wechat/miniprogram/yansongda/AGENTS.md b/wechat/miniprogram/yansongda/AGENTS.md index 9e7bdcc8..2679579e 100644 --- a/wechat/miniprogram/yansongda/AGENTS.md +++ b/wechat/miniprogram/yansongda/AGENTS.md @@ -2,7 +2,7 @@ ## 项目概述 -该目录是微信小程序前端,使用 TypeScript 与微信小程序原生目录结构,包管理器固定为 `pnpm`。 +该目录是微信小程序前端,使用 TypeScript 与微信小程序原生目录结构。**包管理器固定为 Deno**(非 pnpm/npm/yarn)。 小程序工程根目录为 `wechat/miniprogram/yansongda/`,其中真正的小程序源码位于 `src/`(由 `project.config.json` 中 `miniprogramRoot: "src/"` 指定)。 @@ -11,8 +11,8 @@ ``` wechat/miniprogram/yansongda/ src/ # 小程序业务代码(miniprogramRoot) - package.json # 前端脚本与依赖 - pnpm-lock.yaml # pnpm 锁文件(必须提交) + package.json # 脚本定义与依赖声明 + deno.lock # Deno 锁文件(必须提交) biome.json # 格式化与 lint 配置 tsconfig.json # TypeScript 配置 project.config.json # 微信开发者工具配置 @@ -43,19 +43,28 @@ wechat/miniprogram/yansongda/ - `@constant/*` → `src/constant/*` - `@models/*` → `src/models/*` - `@components/*`→ `src/components/*` -- `tdesign-miniprogram/*` → `src/miniprogram_npm/tdesign-miniprogram/*` +- `types/*` → `src/types/*` +- `tdesign-miniprogram/*` → `src/miniprogram_npm/tdesign-miniprogram/*`(运行时)或 `node_modules/tdesign-miniprogram/miniprogram_dist/*`(类型检查) 新增源码目录时,如需暴露给业务层 import,请同步更新 `tsconfig.json` 的 `paths`。 +## 包管理与依赖 + +- **包管理器**:Deno(不是 pnpm) +- **锁文件**:`deno.lock`(必须提交) +- **安装依赖**:`deno install` +- **依赖解析**:Deno 通过 `package.json` 的 `dependencies` / `devDependencies` 自动创建 `node_modules/` 并保持 `deno.lock` 同步 + ## 构建 / 检查命令 -所有命令在 `wechat/miniprogram/yansongda/` 目录下执行,必须使用 `pnpm`: +所有命令在 `wechat/miniprogram/yansongda/` 目录下执行,使用 `deno task`: ```bash -pnpm i -pnpm biome:check -pnpm biome:fix -pnpm biome:fix-unsafe +deno install # 安装依赖(首次或依赖变更后) +deno task biome:check # 格式化与 lint 检查 +deno task biome:fix # 自动修复 +deno task biome:fix-unsafe # 自动修复(含不安全修复) +deno task typecheck # TypeScript 类型检查(tsc --noEmit) ``` ## 代码风格规范 @@ -63,7 +72,7 @@ pnpm biome:fix-unsafe - 使用 `biome` 做格式化与 lint,配置文件为 `wechat/miniprogram/yansongda/biome.json` - `biome` 覆盖范围以 `biome.json` 中的 `files.includes` 为准,并排除 `src/miniprogram_npm/**/*` - 默认使用空格缩进,JavaScript/TypeScript 字符串使用双引号 -- 提交前优先运行 `pnpm biome:check`,需要自动修复时运行 `pnpm biome:fix` +- 提交前优先运行 `deno task biome:check`,需要自动修复时运行 `deno task biome:fix` ## 开发约束 @@ -74,9 +83,9 @@ pnpm biome:fix-unsafe ## CI 与提交流程 -- 前端 CI 检查为:`pnpm i && pnpm biome:check` +- 前端 CI 检查为:`deno install && deno task biome:check && deno task typecheck` - 禁止提交:`node_modules/`、`src/miniprogram_npm/`、`project.private.config.json`、`.idea/`、`.vscode/` -- 必须提交:`pnpm-lock.yaml` +- 必须提交:`deno.lock` ## 联动开发说明 @@ -85,5 +94,5 @@ pnpm biome:fix-unsafe ## NOTES -- 当前目录下未见 `pnpm-lock.yaml`,但 AGENTS.md 要求必须提交;请确认是否已生成并纳入版本控制。 - 主小程序与 `totp` 小程序共享大量工具/类型/模型代码,但当前无正式共享包,分别独立维护。 +- 当前 CI 已接入 `deno task biome:check` 与 `deno task typecheck`。 diff --git a/wechat/miniprogram/yansongda/biome.json b/wechat/miniprogram/yansongda/biome.json index 492bdeb9..ef2e5c74 100644 --- a/wechat/miniprogram/yansongda/biome.json +++ b/wechat/miniprogram/yansongda/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.4.15/schema.json", + "$schema": "https://biomejs.dev/schemas/2.5.1/schema.json", "vcs": { "enabled": false, "clientKind": "git", @@ -16,7 +16,7 @@ "linter": { "enabled": true, "rules": { - "recommended": true + "preset": "recommended" } }, "javascript": { @@ -31,5 +31,17 @@ "organizeImports": "on" } } - } + }, + "overrides": [ + { + "includes": ["**/*.scss", "**/*.css"], + "linter": { + "rules": { + "correctness": { + "noUnknownTypeSelector": "off" + } + } + } + } + ] } diff --git a/wechat/miniprogram/yansongda/deno.lock b/wechat/miniprogram/yansongda/deno.lock index 9024d4a9..ddb0e441 100644 --- a/wechat/miniprogram/yansongda/deno.lock +++ b/wechat/miniprogram/yansongda/deno.lock @@ -1,14 +1,14 @@ { "version": "5", "specifiers": { - "npm:@biomejs/biome@2.4.15": "2.4.15", + "npm:@biomejs/biome@^2.5.1": "2.5.1", "npm:miniprogram-api-typings@^5.2.1": "5.2.1", "npm:tdesign-miniprogram@^1.15.1": "1.15.1", "npm:typescript@^6.0.3": "6.0.3" }, "npm": { - "@biomejs/biome@2.4.15": { - "integrity": "sha512-j5VH3a/h/HXTKBM50MDMxRCzkeLv9S2XJcW2WgnZT1+xyisi+0bISrXR82gCX+8S9lvK0skEvHJRN+3Ktr2hlw==", + "@biomejs/biome@2.5.1": { + "integrity": "sha512-IXWLCxKmae+rI7LOHS1B3EbVisQ6GRAWbhN9msa6KjNCyFWrvKZWR4oUdinaNssrV852OrSHuSPa95h1GPJc7Q==", "optionalDependencies": [ "@biomejs/cli-darwin-arm64", "@biomejs/cli-darwin-x64", @@ -21,43 +21,43 @@ ], "bin": true }, - "@biomejs/cli-darwin-arm64@2.4.15": { - "integrity": "sha512-rF3PPqLq1yoST79zaQbDjVJwsuIeci/O+9bgNmC5QpgOqz6aqYuzA4abyAGx+mgyiDXn4A049xAN8gijbuR1Qg==", + "@biomejs/cli-darwin-arm64@2.5.1": { + "integrity": "sha512-npqDzvqv7vFaWRiNN1Te71siRgPaqS9MpqgYCdP/CrUbkJ7ApezaeaKjueKHRN/JH/6lRjJQAHi8acQDCAz22w==", "os": ["darwin"], "cpu": ["arm64"] }, - "@biomejs/cli-darwin-x64@2.4.15": { - "integrity": "sha512-/5KHXYMfSJs1fNXiX30xFtI8JcCFV6zaVVLxOa0M2sfqBKHkpQhRTv94yxQWxeTY2lzo2OuTlNvPC+hDQt2wcQ==", + "@biomejs/cli-darwin-x64@2.5.1": { + "integrity": "sha512-RgwTqPAM8g2tn1j+b5oRjF/DbSBX8a4gwojtuG9XuhfK7GgomvZ9+T+tqjXiVbjLEeGJOoL6VEk8mvRTVeSybw==", "os": ["darwin"], "cpu": ["x64"] }, - "@biomejs/cli-linux-arm64-musl@2.4.15": { - "integrity": "sha512-ZPcxznxm0pogHBLZhYntyR3sR+MrZjqJIKEr7ZqVen0Rl+P/4upVmfYXjftizi9RoqZntg33fv/1fbdhbYXpEQ==", + "@biomejs/cli-linux-arm64-musl@2.5.1": { + "integrity": "sha512-WMcvMLgByyTqVxGlq918NBBYliq9FRR9GAQVETHb+VjGVqXCZFfHlZHC1FX4ibuYY/Hg6TJE3rHU0xVrdJXNRw==", "os": ["linux"], "cpu": ["arm64"] }, - "@biomejs/cli-linux-arm64@2.4.15": { - "integrity": "sha512-owaAMZD/T4LrD0ELNCk0Km3qrRHuM0X6EAyVE1FSqGY0rbLoiDLrO4Us2tllm6cAeB2Ioa9C2C08NZPdr8+0Ug==", + "@biomejs/cli-linux-arm64@2.5.1": { + "integrity": "sha512-yhV35CzZh38VyMvTEXi3JTjxZBs++oCKK9KG8vB6VI5+uvQvZNR3BFWEKKzuOmx9DJJj7sQpZ4LQJcmbGTs3+Q==", "os": ["linux"], "cpu": ["arm64"] }, - "@biomejs/cli-linux-x64-musl@2.4.15": { - "integrity": "sha512-CNq/9W38SYSH023lfcQ4KKU8K0YX8T//FZUhcgtMMRABDojx5XsMV7jlweAvGSl389wJQB29Qo6Zb/a+jdvt+w==", + "@biomejs/cli-linux-x64-musl@2.5.1": { + "integrity": "sha512-ANTowtlLmPYm5yeMckWY8Xzb9Ix+JJP3tgHR/n6xRj1VWyIzzWtfRfih9hv9VmClwadpBvZduISZIbBsIlYG3A==", "os": ["linux"], "cpu": ["x64"] }, - "@biomejs/cli-linux-x64@2.4.15": { - "integrity": "sha512-0jj7THz12GbUOLmMibktK6DZjqz2zV64KFxyBtcFTKPiiOIY0a7vns1elpO1dERvxpsZ5ik0oFfz0oGwFde1+g==", + "@biomejs/cli-linux-x64@2.5.1": { + "integrity": "sha512-J/7uHSX7NfoYDI7HijAkd8lnQIOrRb2W7j3X+tw4R+N5ExvXGsyXFiGdQcfcxfOmNQmZVSQOCDk757fwpzqQcg==", "os": ["linux"], "cpu": ["x64"] }, - "@biomejs/cli-win32-arm64@2.4.15": { - "integrity": "sha512-ouhkYdlhp/1GghEJPdWwD/Vi3gQ1nFxuSpMolWsbq3Lsq3QUR4jl6UdhhscdCugKU5vOEuMiJhvKj66O0OCq+w==", + "@biomejs/cli-win32-arm64@2.5.1": { + "integrity": "sha512-zgXnKNgWPC4iPF7Y1lR3STUeCUuZRpD6IiOrC7TZTlh0Lx6FiVUT05myuMQHQ9D+1cc7uyMldi4forE6lp0ivQ==", "os": ["win32"], "cpu": ["arm64"] }, - "@biomejs/cli-win32-x64@2.4.15": { - "integrity": "sha512-zBrGq5mx5wwpnow4+2BxUvleDM+GNd4sLbPaMapsSLQLD0NGRCquqPBTgN+7XkUteHvj7M+BstuI8tmnV7+HgQ==", + "@biomejs/cli-win32-x64@2.5.1": { + "integrity": "sha512-6uxpR9hvaglANkZemeSiN/FhYgkGasrEGn267eXIWvjrjJ2LhDlk251IhjVJq6MXzkV2/bcXwLwSroLyPtqRZg==", "os": ["win32"], "cpu": ["x64"] }, @@ -75,7 +75,7 @@ "workspace": { "packageJson": { "dependencies": [ - "npm:@biomejs/biome@2.4.15", + "npm:@biomejs/biome@^2.5.1", "npm:miniprogram-api-typings@^5.2.1", "npm:tdesign-miniprogram@^1.15.1", "npm:typescript@^6.0.3" diff --git a/wechat/miniprogram/yansongda/package.json b/wechat/miniprogram/yansongda/package.json index 770f318e..10e58555 100644 --- a/wechat/miniprogram/yansongda/package.json +++ b/wechat/miniprogram/yansongda/package.json @@ -6,7 +6,8 @@ "scripts": { "biome:check": "biome check", "biome:fix": "biome check --fix", - "biome:fix-unsafe": "biome check --fix --unsafe" + "biome:fix-unsafe": "biome check --fix --unsafe", + "typecheck": "tsc --noEmit" }, "keywords": [ "miniprogram", @@ -15,7 +16,7 @@ "author": "me@yansongda.cn", "license": "MIT", "devDependencies": { - "@biomejs/biome": "2.4.15", + "@biomejs/biome": "^2.5.1", "miniprogram-api-typings": "^5.2.1", "typescript": "^6.0.3" }, diff --git a/wechat/miniprogram/yansongda/src/api/totp.ts b/wechat/miniprogram/yansongda/src/api/totp.ts index d46690ea..62a2e351 100644 --- a/wechat/miniprogram/yansongda/src/api/totp.ts +++ b/wechat/miniprogram/yansongda/src/api/totp.ts @@ -4,6 +4,7 @@ import { HttpError } from "@models/error"; import error from "@utils/error"; import http from "@utils/http"; import logger from "@utils/logger"; +import type { RequestData } from "types/http"; import type { CreateRequest, DeleteRequest, @@ -88,7 +89,7 @@ const deleteTotp = async (id: string) => { const sort = async (items: SortRequest["items"]) => { try { - return await http.post("/api/v1/totp/sort", { items } as SortRequest); + return await http.post(PATH.SORT, { items } as RequestData); } catch (e: unknown) { logger.error("排序 TOTP 失败", e); diff --git a/wechat/miniprogram/yansongda/src/components/totp/item.scss b/wechat/miniprogram/yansongda/src/components/totp/item.scss index 7664e8e5..03c19708 100644 --- a/wechat/miniprogram/yansongda/src/components/totp/item.scss +++ b/wechat/miniprogram/yansongda/src/components/totp/item.scss @@ -41,7 +41,7 @@ .item-btn { height: 100%; - + .btn { display: inline-flex; justify-content: center; @@ -50,13 +50,13 @@ height: 100%; color: white; } - + .btn-detail { background-color: #ed7b2f; } - + .btn-delete { background-color: #e34d59; } } -} \ No newline at end of file +} diff --git a/wechat/miniprogram/yansongda/src/constant/totp.ts b/wechat/miniprogram/yansongda/src/constant/totp.ts index e30c17f7..b1062aff 100644 --- a/wechat/miniprogram/yansongda/src/constant/totp.ts +++ b/wechat/miniprogram/yansongda/src/constant/totp.ts @@ -5,6 +5,7 @@ const PATH = { EDIT_ISSUER: "/api/v1/totp/edit/issuer", EDIT_USERNAME: "/api/v1/totp/edit/username", DELETE: "/api/v1/totp/delete", + SORT: "/api/v1/totp/sort", }; export { PATH }; diff --git a/wechat/miniprogram/yansongda/src/pages/home/index.scss b/wechat/miniprogram/yansongda/src/pages/home/index.scss index 8b137891..e69de29b 100644 --- a/wechat/miniprogram/yansongda/src/pages/home/index.scss +++ b/wechat/miniprogram/yansongda/src/pages/home/index.scss @@ -1 +0,0 @@ - diff --git a/wechat/miniprogram/yansongda/src/types/wechat.d.ts b/wechat/miniprogram/yansongda/src/types/wechat.d.ts index 70bc381d..034ffd1e 100644 --- a/wechat/miniprogram/yansongda/src/types/wechat.d.ts +++ b/wechat/miniprogram/yansongda/src/types/wechat.d.ts @@ -60,3 +60,10 @@ export interface WxLoginSuccessCallbackResult { export interface WxGetStorageSuccess { data: T; } + +declare global { + class URLSearchParams { + append(name: string, value: string): void; + toString(): string; + } +} diff --git a/wechat/miniprogram/yansongda/tsconfig.json b/wechat/miniprogram/yansongda/tsconfig.json index 2b752781..c2414f46 100644 --- a/wechat/miniprogram/yansongda/tsconfig.json +++ b/wechat/miniprogram/yansongda/tsconfig.json @@ -18,15 +18,21 @@ "strictPropertyInitialization": true, "lib": ["esnext"], "types": ["miniprogram-api-typings"], + "ignoreDeprecations": "6.0", "baseUrl": ".", + "skipLibCheck": true, "outDir": "build", "paths": { - "tdesign-miniprogram/*": ["src/miniprogram_npm/tdesign-miniprogram/*"], + "tdesign-miniprogram/*": [ + "src/miniprogram_npm/tdesign-miniprogram/*", + "node_modules/tdesign-miniprogram/miniprogram_dist/*" + ], "@api/*": ["src/api/*"], "@utils/*": ["src/utils/*"], "@constant/*": ["src/constant/*"], "@models/*": ["src/models/*"], "@components/*": ["src/components/*"], + "types/*": ["src/types/*"], }, }, "exclude": ["node_modules", "build/**/*"],