Files
iam-front/README.md
2026-02-10 12:23:47 +08:00

60 lines
1.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.

# iam-front
统一认证前端SSO 登录页),基于 Next.js 16App Router+ TypeScript + Tailwind CSS + shadcn/ui。
## 本地启动
1. 复制环境变量:
```bash
cp .env.example .env
```
2. 安装依赖并启动:
```bash
npm install
npm run dev
```
> 说明:本项目使用 Turbopack 开发模式(`next dev --turbopack`)。遇到 Linux file watch 限制ENOSPC时会自动使用 polling不影响 Fast Refresh但可能略增 CPU
## 组件使用示例
统一登录页默认使用带 Tabs 切换的组件(登录/注册):
- 页面路由:[login/page.tsx](file:///home/shay/project/backend/iam-front/src/app/login/page.tsx)
- 组件入口:[login-form.tsx](file:///home/shay/project/backend/iam-front/src/components/login-form.tsx)
示例(页面内):
```tsx
<LoginFormCard
clientId={searchParams.clientId ?? ""}
tenantId={searchParams.tenantId ?? ""}
callback={searchParams.callback ?? ""}
initialEmail={rememberedEmail}
/>
```
## 常见问题
### 1) ENOSPC: System limit for number of file watchers reached
这是 Linux `inotify` 文件监听数量上限过低导致Next.js/Turbopack 在 dev 模式需要文件监听,超过上限会报错)。
本项目在 `next.config.js` 中做了自动降级:当检测到上限偏低时,会启用 polling watcher 来避免启动失败(可能会略增 CPU 占用)。
你也可以手动启用 polling
```bash
npm run dev:poll
```
如需从根源修复(需要 sudo 权限),可提高系统上限(示例):
```bash
sudo sysctl -w fs.inotify.max_user_watches=524288
sudo sysctl -w fs.inotify.max_user_instances=1024
```