Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions .github/workflows/coding-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -124,3 +109,6 @@ jobs:
- name: Run biome check
run: |
deno task biome:check
- name: Run type check
run: |
deno task typecheck
13 changes: 7 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 业务代码
Expand Down Expand Up @@ -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 / 配置 / 数据结构时,需说明兼容策略与迁移方式。
Expand All @@ -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。
Expand All @@ -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
Expand All @@ -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 不执行测试。
2 changes: 1 addition & 1 deletion wechat/miniprogram/totp/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`。
5 changes: 4 additions & 1 deletion wechat/miniprogram/totp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"],
Expand Down
35 changes: 22 additions & 13 deletions wechat/miniprogram/yansongda/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 项目概述

该目录是微信小程序前端,使用 TypeScript 与微信小程序原生目录结构包管理器固定为 `pnpm`
该目录是微信小程序前端,使用 TypeScript 与微信小程序原生目录结构。**包管理器固定为 Deno**(非 pnpm/npm/yarn)

小程序工程根目录为 `wechat/miniprogram/yansongda/`,其中真正的小程序源码位于 `src/`(由 `project.config.json` 中 `miniprogramRoot: "src/"` 指定)。

Expand All @@ -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 # 微信开发者工具配置
Expand Down Expand Up @@ -43,27 +43,36 @@ 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)
```

## 代码风格规范

- 使用 `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`

## 开发约束

Expand All @@ -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`

## 联动开发说明

Expand All @@ -85,5 +94,5 @@ pnpm biome:fix-unsafe

## NOTES

- 当前目录下未见 `pnpm-lock.yaml`,但 AGENTS.md 要求必须提交;请确认是否已生成并纳入版本控制。
- 主小程序与 `totp` 小程序共享大量工具/类型/模型代码,但当前无正式共享包,分别独立维护。
- 当前 CI 已接入 `deno task biome:check` 与 `deno task typecheck`。
18 changes: 15 additions & 3 deletions wechat/miniprogram/yansongda/biome.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -16,7 +16,7 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"preset": "recommended"
}
},
"javascript": {
Expand All @@ -31,5 +31,17 @@
"organizeImports": "on"
}
}
}
},
"overrides": [
{
"includes": ["**/*.scss", "**/*.css"],
"linter": {
"rules": {
"correctness": {
"noUnknownTypeSelector": "off"
}
}
}
}
]
}
40 changes: 20 additions & 20 deletions wechat/miniprogram/yansongda/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions wechat/miniprogram/yansongda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
3 changes: 2 additions & 1 deletion wechat/miniprogram/yansongda/src/api/totp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -88,7 +89,7 @@ const deleteTotp = async (id: string) => {

const sort = async (items: SortRequest["items"]) => {
try {
return await http.post<null>("/api/v1/totp/sort", { items } as SortRequest);
return await http.post<null>(PATH.SORT, { items } as RequestData);
} catch (e: unknown) {
logger.error("排序 TOTP 失败", e);

Expand Down
8 changes: 4 additions & 4 deletions wechat/miniprogram/yansongda/src/components/totp/item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

.item-btn {
height: 100%;

.btn {
display: inline-flex;
justify-content: center;
Expand All @@ -50,13 +50,13 @@
height: 100%;
color: white;
}

.btn-detail {
background-color: #ed7b2f;
}

.btn-delete {
background-color: #e34d59;
}
}
}
}
1 change: 1 addition & 0 deletions wechat/miniprogram/yansongda/src/constant/totp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
1 change: 0 additions & 1 deletion wechat/miniprogram/yansongda/src/pages/home/index.scss
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Loading