Files
nianxx-h5/README.md
DEV_DSW e617e303d4 docs: update project docs and add git commit message guidelines
- add .trae/rules/git-commit-message.md with official commit rules
- update AGENTS.md to add Chinese commit message requirement
- overhaul README.md: update tech stack, directory structure, env vars, routing, i18n and request lib docs
2026-06-02 11:42:01 +08:00

98 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# nianxx-h5
基于 Vite 的 H5 Web 项目Vue 3 + TypeScript
## 技术栈
- Vite`package.json`,本仓库使用 ESM`"type": "module"`
- Vue 3 + TypeScript
- vue-router 4
- Pinia
- Vant 4配合 `unplugin-auto-import` / `unplugin-vue-components` 自动导入)
- Tailwind CSS v4通过 `@tailwindcss/vite`
- vue-i18n支持`zh-CN` / `en-US` / `th-TH`
- axios统一请求库`src/utils/request.ts`
- mitt事件总线
## 目录约定
- 入口:`src/main.ts`
- 根组件:`src/App.vue`
- 路由:`src/router/index.ts`
- 页面:`src/pages/`
- 公共组件:`src/components/`
- 首页模块组件:`src/pages/home/components/`
- 国际化:`src/i18n/`
- 状态管理:`src/store/`
- 全局样式:`src/styles/main.css`
- 工具:`src/utils/`
- 共享类型:`src/shared/`
## 本地开发
使用 Yarn。
```bash
yarn
yarn dev
```
常用命令:
- `yarn dev`:启动开发服务器(端口 5174配置见 `vite.config.ts`
- `yarn typecheck``vue-tsc --noEmit`
- `yarn build`:类型检查 + 构建
- `yarn preview`:预览构建产物
- `yarn test`:运行 `src/**/*.test.ts`Node 原生 test runner
需要编译/测试时请手动确认执行。
## 环境变量
本项目使用 Vite 环境变量(`import.meta.env.*`)。
必须配置:
- `VITE_API_BASE_URL`:接口基础地址(请求库会校验,缺失会直接抛错)
常用配置:
- `VITE_CLIENT_ID`:请求 header 注入的 `clientId`
- `VITE_API_TIMEOUT_MS`:请求超时毫秒数(默认 15000
- `VITE_TOKEN`:临时 token当前请求库会在请求前写入上下文属于临时逻辑
## 路由
当前路由配置见 `src/router/index.ts`(按 `src/pages/` 目录落地):
- `/``/home`:首页
- `/login`:登录
- `/booking`:预定
- `/goods`:商品详情
- `/album`:相册
- `/quick`:快速预定
- `/order``/order/detail`:订单列表 / 订单详情
- `/service`:工单列表
## 国际化i18n
- i18n 实例:`src/i18n/index.ts`
- 语言包:`src/i18n/modules/**/{zh-CN,en-US,th-TH}.ts`
- 切换语言:`setLocale(locale)`(同时会同步 Vant 语言与 `document.lang`
## 统一请求库
统一请求库实现:
- `src/utils/request.ts`
- 类型定义:`src/shared/request-types.ts`
- 使用文档:`docs/request.md`
## 特殊说明uni-\* 痕迹)
代码中仍存在部分 `uni.*` API例如 `uni.navigateTo` / `uni.requestSubscribeMessage`)。如果最终运行环境为纯 H5 Web需要确认这些能力的提供方式注入 / 替换 / 降级)。
## 协作规范
仓库协作约定见 `AGENTS.md`