pandax 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/bin/pandax.js +592 -0
- package/package.json +33 -0
- package/skills/pandax-frontend-api-mock/SKILL.md +62 -0
- package/skills/pandax-frontend-architecture/SKILL.md +1239 -0
- package/skills/pandax-frontend-component-review/SKILL.md +114 -0
- package/skills/pandax-frontend-requirement/SKILL.md +142 -0
- package/skills/pandax-frontend-standards/SKILL.md +468 -0
- package/skills/pandax-frontend-use-modal/SKILL.md +621 -0
- package/templates/pandax-monorepo/.editorconfig +16 -0
- package/templates/pandax-monorepo/.husky/commit-msg +2 -0
- package/templates/pandax-monorepo/.husky/pre-commit +2 -0
- package/templates/pandax-monorepo/.prettierrc.json +28 -0
- package/templates/pandax-monorepo/apps/base/env.d.ts +1 -0
- package/templates/pandax-monorepo/apps/base/index.html +13 -0
- package/templates/pandax-monorepo/apps/base/package.json +30 -0
- package/templates/pandax-monorepo/apps/base/src/App.vue +15 -0
- package/templates/pandax-monorepo/apps/base/src/layouts/default-layout/index.vue +23 -0
- package/templates/pandax-monorepo/apps/base/src/main.ts +31 -0
- package/templates/pandax-monorepo/apps/base/src/router/index.ts +22 -0
- package/templates/pandax-monorepo/apps/base/src/stores/index.ts +15 -0
- package/templates/pandax-monorepo/apps/base/src/styles/global.scss +19 -0
- package/templates/pandax-monorepo/apps/base/src/styles/variables.scss +4 -0
- package/templates/pandax-monorepo/apps/base/src/types/wujie.d.ts +16 -0
- package/templates/pandax-monorepo/apps/base/src/views/home/index.vue +21 -0
- package/templates/pandax-monorepo/apps/base/tsconfig.json +25 -0
- package/templates/pandax-monorepo/apps/base/tsconfig.node.json +11 -0
- package/templates/pandax-monorepo/apps/base/vite.config.ts +26 -0
- package/templates/pandax-monorepo/apps/main/env.d.ts +1 -0
- package/templates/pandax-monorepo/apps/main/index.html +13 -0
- package/templates/pandax-monorepo/apps/main/package.json +32 -0
- package/templates/pandax-monorepo/apps/main/src/App.vue +15 -0
- package/templates/pandax-monorepo/apps/main/src/layouts/MicroApp.vue +29 -0
- package/templates/pandax-monorepo/apps/main/src/layouts/default-layout/index.vue +48 -0
- package/templates/pandax-monorepo/apps/main/src/main.ts +27 -0
- package/templates/pandax-monorepo/apps/main/src/router/index.ts +22 -0
- package/templates/pandax-monorepo/apps/main/src/stores/index.ts +23 -0
- package/templates/pandax-monorepo/apps/main/src/styles/global.scss +23 -0
- package/templates/pandax-monorepo/apps/main/src/styles/variables.scss +8 -0
- package/templates/pandax-monorepo/apps/main/src/views/home/index.vue +25 -0
- package/templates/pandax-monorepo/apps/main/tsconfig.json +25 -0
- package/templates/pandax-monorepo/apps/main/tsconfig.node.json +11 -0
- package/templates/pandax-monorepo/apps/main/vite.config.ts +24 -0
- package/templates/pandax-monorepo/commitlint.config.js +38 -0
- package/templates/pandax-monorepo/eslint.config.js +61 -0
- package/templates/pandax-monorepo/package.json +50 -0
- package/templates/pandax-monorepo/packages/components/package.json +20 -0
- package/templates/pandax-monorepo/packages/components/src/PandaButton.vue +15 -0
- package/templates/pandax-monorepo/packages/components/src/PandaCard.vue +16 -0
- package/templates/pandax-monorepo/packages/components/src/index.ts +2 -0
- package/templates/pandax-monorepo/packages/core/package.json +20 -0
- package/templates/pandax-monorepo/packages/core/src/index.ts +2 -0
- package/templates/pandax-monorepo/packages/core/src/request.ts +24 -0
- package/templates/pandax-monorepo/packages/core/src/utils.ts +7 -0
- package/templates/pandax-monorepo/packages/hooks/package.json +19 -0
- package/templates/pandax-monorepo/packages/hooks/src/index.ts +2 -0
- package/templates/pandax-monorepo/packages/hooks/src/useCounter.ts +27 -0
- package/templates/pandax-monorepo/packages/hooks/src/useToggle.ts +19 -0
- package/templates/pandax-monorepo/packages/styles/package.json +19 -0
- package/templates/pandax-monorepo/packages/styles/src/index.ts +1 -0
- package/templates/pandax-monorepo/packages/styles/src/uno.ts +19 -0
- package/templates/pandax-monorepo/packages/styles/src/variables.scss +14 -0
- package/templates/pandax-monorepo/pnpm-workspace.yaml +32 -0
- package/templates/pandax-monorepo/turbo.json +23 -0
- package/templates/vue3/.eslintrc.cjs +16 -0
- package/templates/vue3/.prettierrc +7 -0
- package/templates/vue3/env.d.ts +1 -0
- package/templates/vue3/index.html +13 -0
- package/templates/vue3/package.json +34 -0
- package/templates/vue3/src/App.vue +14 -0
- package/templates/vue3/src/api/index.ts +27 -0
- package/templates/vue3/src/assets/.gitkeep +1 -0
- package/templates/vue3/src/components/.gitkeep +1 -0
- package/templates/vue3/src/composables/.gitkeep +1 -0
- package/templates/vue3/src/constants/.gitkeep +1 -0
- package/templates/vue3/src/directives/.gitkeep +1 -0
- package/templates/vue3/src/layouts/default-layout/index.vue +33 -0
- package/templates/vue3/src/locales/.gitkeep +1 -0
- package/templates/vue3/src/main.ts +17 -0
- package/templates/vue3/src/router/index.ts +17 -0
- package/templates/vue3/src/services/.gitkeep +1 -0
- package/templates/vue3/src/stores/index.ts +12 -0
- package/templates/vue3/src/styles/global.scss +18 -0
- package/templates/vue3/src/styles/variables.scss +17 -0
- package/templates/vue3/src/types/global.d.ts +9 -0
- package/templates/vue3/src/utils/format.ts +11 -0
- package/templates/vue3/src/views/home/index.vue +19 -0
- package/templates/vue3/tsconfig.json +25 -0
- package/templates/vue3/tsconfig.node.json +10 -0
- package/templates/vue3/vite.config.ts +20 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "pandax-frontend-api-mock"
|
|
3
|
+
category: "frontend"
|
|
4
|
+
description: "规范 API 对接与 Mock 数据管理。Invoke when 新增接口请求、对接后端 API、编写 Mock 数据、或调整请求/响应拦截逻辑。"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pandax API 对接与 Mock 规范
|
|
8
|
+
|
|
9
|
+
本 skill 用于规范前端与后端 API 的对接方式,以及本地 Mock 数据的组织管理。
|
|
10
|
+
|
|
11
|
+
## 触发条件
|
|
12
|
+
|
|
13
|
+
- 新增接口请求函数
|
|
14
|
+
- 对接后端 API
|
|
15
|
+
- 编写或修改 Mock 数据
|
|
16
|
+
- 调整 axios/fetch 拦截器
|
|
17
|
+
|
|
18
|
+
## 核心规则
|
|
19
|
+
|
|
20
|
+
### 1. 请求层封装
|
|
21
|
+
|
|
22
|
+
- 所有请求必须通过统一的请求客户端(如 `src/api/request.ts`)
|
|
23
|
+
- 禁止在业务代码中直接使用 `axios.get` / `fetch`
|
|
24
|
+
- 请求函数统一返回 Promise,错误统一由拦截器处理
|
|
25
|
+
|
|
26
|
+
### 2. API 目录组织
|
|
27
|
+
|
|
28
|
+
- 按业务模块划分文件,如 `src/api/user.ts`、`src/api/order.ts`
|
|
29
|
+
- 每个函数名使用 `动词 + 名词`,如 `getUserList`、`createOrder`
|
|
30
|
+
- 函数注释需包含接口路径、方法、主要字段说明
|
|
31
|
+
|
|
32
|
+
### 3. 类型定义
|
|
33
|
+
|
|
34
|
+
- 请求参数与响应数据必须使用 TypeScript 接口定义
|
|
35
|
+
- 接口文件与 API 文件同目录或放在 `src/types/api/` 下
|
|
36
|
+
- 禁止在业务代码中使用 `any` 接收接口返回值
|
|
37
|
+
|
|
38
|
+
### 4. Mock 数据
|
|
39
|
+
|
|
40
|
+
- Mock 服务使用 MSW 或项目统一方案
|
|
41
|
+
- Mock 数据文件按模块放在 `src/mocks/` 或 `mock/` 下
|
|
42
|
+
- Mock 响应结构必须与后端真实响应保持一致
|
|
43
|
+
- 复杂字段需有注释说明业务含义
|
|
44
|
+
|
|
45
|
+
### 5. 错误处理
|
|
46
|
+
|
|
47
|
+
- 网络错误、超时、500 等统一提示"服务繁忙,请稍后再试"
|
|
48
|
+
- 业务错误码(如 4001 参数错误)按后端约定提示具体信息
|
|
49
|
+
- 401/403 统一跳转登录或无权限页面
|
|
50
|
+
|
|
51
|
+
### 6. 加载与空态
|
|
52
|
+
|
|
53
|
+
- 列表请求必须显示加载状态
|
|
54
|
+
- 空数据必须展示空态组件,禁止空白无提示
|
|
55
|
+
|
|
56
|
+
## 输出格式
|
|
57
|
+
|
|
58
|
+
按以下结构给出建议:
|
|
59
|
+
1. 当前实现的问题
|
|
60
|
+
2. 规范的实现方式(附示例代码)
|
|
61
|
+
3. 需要新增或调整的文件
|
|
62
|
+
4. 是否需要补充类型定义或 Mock 数据
|