2026-06-22 17:45:59 +08:00
2026-06-22 17:45:59 +08:00
2026-05-25 23:40:50 +08:00
2026-05-26 12:14:31 +08:00

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。

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。

S
Description
C端H5项目
Readme
7.6 MiB
0 Stars 1 Watchers 0 Forks
Languages
Vue 58.8%
TypeScript 23.2%
JavaScript 8.2%
HTML 7%
SCSS 2%
Other 0.8%