用法
import { Settings } from './Settings.jsx'
// Without callbacks every action is simulated after a short wait. Wire them to your account API:
<Settings
locale="en"
profile={{ name, email, role, bio }}
notifications={prefs} // [{ id, label, description, on, locked? }]
sessions={devices} // [{ id, name, place, seen, current?, kind: 'laptop' | 'phone' }]
twoFactor={user.twoFactor}
loading={!user}
onSave={async (draft) => (await saveAccount(draft)).ok} // draft: { profile, notifications: { [id]: boolean } }
onSignOut={(id) => endSession(id)}
onTwoFactor={(on) => setTwoFactor(on)}
onDelete={async () => (await deleteAccount()).ok}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例数据的语言。 |
profile | { name, email, role, bio } | sample member | 已保存的资料;编辑内容和它不同时出现保存条。 |
notifications | Array<{ id, label, description, on, locked? }> | sample switches | 通知开关列表;locked 的开关保持开启并说明原因。 |
sessions / twoFactor | Array<{ id, name, place, seen, current?, kind }> / boolean | sample devices / false | 已登录的设备,以及两步验证是否开启。 |
defaultSection | 'profile' | 'notifications' | 'security' | 'profile' | 初始打开的分区。 |
loading / error | boolean / boolean | string | false | 加载时显示骨架;出错时显示带重试的提示,传字符串可替换说明。 |
onSave | (draft) => Promise<boolean | void> | — | 保存资料和通知的改动。返回 false 显示保存失败并可重试。 |
onSignOut / onTwoFactor / onDelete | (id) => Promise<boolean | void> / (on) => … / () => … | — | 分别用于让设备退出、切换两步验证、注销账号。返回 false 时界面上撤回这次改动。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素 section 上。 |
装进你的项目
把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。
Settings.jsxsettings.csscopy.jskit.jsxkit.cssui/base-button/ui/hold-to-confirm/ui/alert-banner/ui/save-status/ui/elastic-switch/ui/text-input/ui/textarea/ui/skeleton-shimmer/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。