From 9a92984568a3270c2dae6557a4d5e8e10a125838 Mon Sep 17 00:00:00 2001 From: Hsukqi Lee Date: Wed, 11 Nov 2026 06:05:56 +0800 Subject: [PATCH 1/3] refactor: use shared UI in identity forms Use immutable public release artifacts and retain product-specific behavior. Independent review and real release installation recorded in the sharing handoff. --- web/FASTUI.md | 5 +++++ web/package.json | 2 ++ web/pnpm-lock.yaml | 25 +++++++++++++++++++++++++ web/src/Guest.tsx | 11 ++++++----- web/src/main.tsx | 8 ++++++-- web/src/style.css | 21 +++++++++++++++++---- 6 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 web/FASTUI.md diff --git a/web/FASTUI.md b/web/FASTUI.md new file mode 100644 index 0000000..f117793 --- /dev/null +++ b/web/FASTUI.md @@ -0,0 +1,5 @@ +# FastUI console + +`@fastrd/ui-react` 与直接使用的 `@fastrd/ui-foundation` 固定消费 GitHub release `v0.1.0`,锁文件保留制品完整性。安装后 `pnpm run build` 将 CSS/JS 打入本地控制台输出,运行时不访问包下载站点。 + +console 的加载和成功/错误反馈使用真实 `Loading` / `Alert` React 组件,邀请/恢复表单使用 `TextField` / `Button`;安全表单、导航、管理表格保留业务结构,以 foundation token 替换原绿色色板。`fastcas-theme` 默认为 system;切换系统外观不会重挂载 React 树。业务请求、凭证、CSRF 与管理员权限仍由现有组件管理。 diff --git a/web/package.json b/web/package.json index 0728bcd..87c8ef1 100644 --- a/web/package.json +++ b/web/package.json @@ -8,6 +8,8 @@ "dev": "vite --host 127.0.0.1" }, "dependencies": { + "@fastrd/ui-foundation": "https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz", + "@fastrd/ui-react": "https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 119584e..6e65741 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -8,6 +8,12 @@ importers: .: dependencies: + '@fastrd/ui-foundation': + specifier: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz + version: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz + '@fastrd/ui-react': + specifier: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz + version: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz(react-dom@19.2.4(react@19.2.4))(react@19.2.4) react: specifier: 19.2.4 version: 19.2.4 @@ -189,6 +195,17 @@ packages: cpu: [x64] os: [win32] + '@fastrd/ui-foundation@https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz': + resolution: {integrity: sha512-5O4s9BXXHXWk7GbzPfMYX6HjNi0DKryfWLRPYMZINNb4ew3arjCKbJvxFaSvqcCvhHxmrf8OZDg9GPmfvdnRtw==, tarball: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz} + version: 0.1.0 + + '@fastrd/ui-react@https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz': + resolution: {integrity: sha512-zsnN8Afm889TyhPX0ZQQ4hIn5Bj1EsFbEZ857CQXDgmCIOEfY3369bCFn1VEelR/EWjU5Lpyjj6D1E9lVtQ5uw==, tarball: https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz} + version: 0.1.0 + peerDependencies: + react: ^18.3.0 || ^19.0.0 + react-dom: ^18.3.0 || ^19.0.0 + '@napi-rs/lzma-linux-x64-gnu@1.5.1': resolution: {integrity: sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==} engines: {node: ^22.20 || ^24.12 || >=25} @@ -538,6 +555,14 @@ snapshots: '@esbuild/win32-x64@0.25.12': optional: true + '@fastrd/ui-foundation@https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz': {} + + '@fastrd/ui-react@https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-react-0.1.0.tgz(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': + dependencies: + '@fastrd/ui-foundation': https://github.com/FastR-D/FastUI/releases/download/v0.1.0/fastrd-ui-foundation-0.1.0.tgz + react: 19.2.4 + react-dom: 19.2.4(react@19.2.4) + '@napi-rs/lzma-linux-x64-gnu@1.5.1': optional: true diff --git a/web/src/Guest.tsx b/web/src/Guest.tsx index 9e4b786..f1e639a 100644 --- a/web/src/Guest.tsx +++ b/web/src/Guest.tsx @@ -1,4 +1,5 @@ import {useState} from 'react'; +import {Alert,Button,TextField} from '@fastrd/ui-react'; type Flow='invite'|'recovery'|'mfa_reset'; export type InitialCredential={flow:Flow;token:string}|null; @@ -35,10 +36,10 @@ export function Guest({initial}:{initial:InitialCredential}){

{flow==='invite'?'接受邀请':flow==='recovery'?'恢复 FastCAS 密码':'重置 FastCAS 双重验证'}

{complete?<>

{flow==='invite'?'账号已创建':flow==='recovery'?'密码已更新':'双重验证已重置'}。现在可以登录 FastCAS。

前往登录:<>

此操作仅针对 FastCAS 身份。各项目账号和本地登录保持独立。

-
void redeem(e)}> - {flow==='invite'&&} - - {flow!=='mfa_reset'&&} - {error&&

{error}

}
+
void redeem(e)}> + {flow==='invite'&&} + + {flow!=='mfa_reset'&&} + {error&&{error}}
}
} diff --git a/web/src/main.tsx b/web/src/main.tsx index 3f23de5..712573e 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -1,4 +1,7 @@ import React, {useEffect,useState} from 'react'; +import {Alert, Loading} from '@fastrd/ui-react'; +import {initColorMode} from '@fastrd/ui-foundation'; +import '@fastrd/ui-react/styles.css'; import {createRoot} from 'react-dom/client'; import './style.css'; import {Admin} from './Admin'; @@ -6,6 +9,7 @@ import {Delegations} from './Delegations'; import {Integration} from './Integration'; import {Guest,takeInitialCredential} from './Guest'; const initialCredential=takeInitialCredential(); +initColorMode({storageKey:'fastcas-theme'}); type Me={user:{name:string;email:string;role:string};csrf:string;mfa_enabled:boolean;session:{id:string}}; type Link={id:string;client_id:string;local_account_ref:string;state:string;version:number}; type Installation={id:string;client_id:string;client_name:string;installation_id:string;created_at:string;revoked_at:string|null}; @@ -26,8 +30,8 @@ function App(){ async function loadEvents(before=''){const data=await api<{events:Event[];next_cursor:string}>('/admin/outbox'+(before?'?before='+encodeURIComponent(before):''));setEvents(before?old=>[...old,...data.events]:data.events);setCursor(data.next_cursor)} return
FastCAS账号与安全{me&&}

FAST R&D · IDENTITY

{me?`你好,${me.user.name}`:'你的科研账号安全中心'}

管理关联身份与登录安全。各项目的本地账号、内容和权限由项目独立管理。

- {error&&

{error}

}{notice&&

{notice}

} - {loading?

正在读取账号…

:!me?:<> + {error&&{error}}{notice&&{notice}} + {loading?:!me?:<> {page==='security'&&

身份验证

{me.user.email}

双重验证:{me.mfa_enabled?'已启用':'未启用'}

{e.preventDefault();void run(async()=>{await api('/me/reauthenticate',{password,code});setPassword('');setCode('');setNotice('身份已重新验证');await refresh()})}}>

双重验证

使用认证器生成动态验证码。开启后请妥善保存一次性恢复码。

{me.mfa_enabled&&<>

更新恢复码前,请先用上方表单重新验证密码和动态验证码;旧恢复码会立即失效。

}{!me.mfa_enabled&&!uri&&}{uri&&<>

将以下 URI 导入你的认证器。此密钥只应由你保存。