|
|
2 주 전 | |
|---|---|---|
| .. | ||
| docs | 3 주 전 | |
| public | 1 개월 전 | |
| scripts | 3 주 전 | |
| src | 3 주 전 | |
| .gitignore | 1 개월 전 | |
| .node-version | 1 개월 전 | |
| .npmrc | 1 개월 전 | |
| .oxfmtrc.json | 1 개월 전 | |
| .oxlintrc.json | 1 개월 전 | |
| AGENTS.md | 1 개월 전 | |
| README.md | 1 개월 전 | |
| components.json | 1 개월 전 | |
| cz.yaml | 1 개월 전 | |
| dist.zip | 3 주 전 | |
| index.html | 1 개월 전 | |
| knip.config.ts | 1 개월 전 | |
| netlify.toml | 1 개월 전 | |
| package.json | 1 개월 전 | |
| rsbuild.config.ts | 2 주 전 | |
| tsconfig.app.json | 1 개월 전 | |
| tsconfig.json | 1 개월 전 | |
| tsconfig.node.json | 1 개월 전 | |
Linwit Token Web 是一个面向 AI Token 平台的前端单页应用,提供门户展示、用户控制台、模型浏览、渠道管理、API Key 管理、钱包充值、个人资料、Playground 调试以及系统设置等能力。
项目基于 React、TypeScript 与 Rsbuild 构建,采用文件路由、服务端状态管理、统一 API 请求封装和功能模块化目录结构,适合作为 AI 网关、模型分发、Token 计费与平台管理类系统的前端入口。
| 分类 | 技术 |
|---|---|
| 基础框架 | React 19、TypeScript |
| 构建工具 | Rsbuild、Rspack |
| 路由 | TanStack Router |
| 服务端状态 | TanStack Query |
| 本地状态 | Zustand |
| 请求库 | Axios |
| UI 与样式 | Tailwind CSS、Base UI、shadcn 风格组件、Hugeicons、Lucide、Sonner |
| 表单与校验 | React Hook Form、Zod、@hookform/resolvers |
| 表格与虚拟列表 | TanStack Table、TanStack Virtual |
| 国际化 | i18next、react-i18next、i18next-browser-languagedetector |
| 图表 | VisActor VChart、React VChart、Recharts |
| Markdown / 代码展示 | marked、shiki、CodeMirror、KaTeX |
| 工程质量 | oxlint、oxfmt、knip |
default
├── public # 静态资源,如 logo、favicon、支付图标等
├── scripts # 工程脚本,如格式化、版权、国际化同步
├── src # 应用源码
│ ├── components # 通用组件、布局组件、UI 基础组件
│ ├── context # 全局 React Context
│ ├── features # 业务功能模块
│ ├── hooks # 通用 Hooks
│ ├── i18n # 国际化配置与语言资源
│ ├── lib # API、工具函数、通用逻辑
│ ├── routes # TanStack Router 文件路由
│ ├── stores # Zustand 状态管理
│ ├── styles # 全局样式
│ ├── main.tsx # 应用入口
│ └── routeTree.gen.ts # 路由树生成文件
├── index.html # HTML 模板
├── package.json # 项目依赖与脚本
├── rsbuild.config.ts # Rsbuild 构建配置
└── tsconfig*.json # TypeScript 配置
src/routes:应用路由入口,包含公开页面、认证页面和受保护后台页面。src/routes/_authenticated:需要登录后访问的后台路由分组。src/features/auth:登录、注册、找回密码等认证相关功能。src/features/dashboard:控制台与概览相关功能。src/features/models:模型展示、模型分组与模型相关页面。src/features/channels:渠道管理相关功能。src/features/keys:API Key 管理相关功能。src/features/pricing:价格展示与计费相关页面。src/features/profile:用户资料、账户设置与个人中心。src/features/playground:模型调用体验与调试页面。src/features/system-settings:系统配置与管理后台相关能力。index.html,通过 #root 挂载 React 应用。src/main.tsx 创建 QueryClient 和 TanStack Router。src/routeTree.gen.ts 中生成的路由树。/setup。/api/user/self 验证当前会话。统一请求封装位于 src/lib/api.ts:
baseURL 为空。withCredentials,用于携带 Cookie / Session。开发环境接口代理在 rsbuild.config.ts 中配置,默认代理路径包括:
/api/mj/pg本地开发后端地址通过 .env 中的 VITE_REACT_APP_SERVER_URL 配置;未配置时默认使用 http://localhost:3000。
项目使用 Bun 作为包管理器。
bun install
启动开发环境:
bun run dev
生产构建:
bun run build
类型检查:
bun run typecheck
代码检查:
bun run lint
格式化:
bun run format
同步国际化资源:
bun run i18n:sync
预览生产构建:
bun run preview
src/routes,具体业务实现放在对应的 src/features/<feature> 中。src/components,业务组件优先放在所属 feature 内。src/lib/api.ts 中的统一 Axios 实例。src/routeTree.gen.ts,它由 TanStack Router 插件生成。src/main.tsxindex.htmlrsbuild.config.tsdistindex.html仓库中已包含 netlify.toml,用于在 Netlify 部署时将所有路径回退到 /index.html。
src/main.tsx:理解应用启动和全局 Provider。src/routes/__root.tsx:理解根路由、初始化检查和全局错误边界。src/routes/_authenticated/route.tsx:理解登录态校验和后台路由保护。src/components/layout/components/authenticated-layout.tsx:理解后台整体布局。src/lib/api.ts:理解接口请求、错误处理和会话逻辑。src/stores/auth-store.ts:理解认证状态在前端如何保存与恢复。rsbuild.config.ts:理解构建入口、路径别名、代理和生产构建配置。