Skip to content

feat(admin): migrate pro admin UI into app admin sidebar - #7609

Draft
xqvvu wants to merge 9 commits into
labring:mainfrom
xqvvu:xqvvu/feat/admin-ui-migrate
Draft

xqvvu wants to merge 9 commits into
labring:mainfrom
xqvvu:xqvvu/feat/admin-ui-migrate

Conversation

@xqvvu

@xqvvu xqvvu commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

背景

把 pro/admin 的 UI 迁移到前台主应用 projects/app,以"管理员侧栏"形式集成,root 用户在 app 内即可完成管理员操作,无需单独部署/访问 admin 应用。设计方案见 .agents/design/admin/pro-admin-ui-migrate.md

改动

  • 路由:新增 25 个 /admin/* 页面(dashboard 5 子页、users/teams/plans/pays/invoice、apps/datasets、config basic/feature/model/thirdParty/user/pay/plugin/modelProvider、templates app/toolkit、inform、log、audit、home);旧 /config/* 路由 302 重定向到 /admin/config/*
  • 导航壳层SecondaryNavigationContainer 扩展两级分组侧栏能力(SideTabs/Group,向后兼容 account 页);root 用户 navbar 新增"管理"入口
  • 组件迁移components/admin/(BoxCard、markdown、Settings 表单系列、PlanComponents)、pageComponents/admin/ 各页面模块
  • 前端 API 封装web/admin/* 通过 /proApi 代理调用 pro/admin 接口;pro 服务未配置时静默降级为空数据,保证开源版页面骨架可渲染
  • License:激活/校验 UI(LicenseInput/LicenseData)+ root 登录后未激活检测,提示激活/购买商业版
  • 依赖@tanstack/react-tablenodemailer@alicloud/*xml2jscanvas 等注册进 pnpm catalog

验证

  • tsc 全量 0 error、eslint 0 error(warning 为迁移代码风格,与 pro/admin 源一致)
  • dev server 实测迁移接口从 404 → 403/200(root 认证拦截/公开接口),路由真实存在;app 首页/登录正常

待办(后续)

  • 迁移接口单测(pro/admin 已有 7 个测试待迁移到 projects/app/test/api/admin/
  • eslint warnings 清理
  • root 登录后完整 UI 流程人工验证

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Admin Preview Image Ready!

ghcr.io/labring/fastgpt-pr:admin_ff5a2e6448e23bf29965df2212a385a5e657ae47

🕒 Time: 2026-09-15 14:30:19 (UTC+8)

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 41.08% 4214 / 10258
🔵 Statements 40.92% 4463 / 10905
🔵 Functions 34.05% 823 / 2417
🔵 Branches 34.84% 2172 / 6234
File CoverageNo changed files found.
Generated in workflow #3374 for commit ff5a2e6 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Build and publish successful - Preview fastgpt Image:

ghcr.io/labring/fastgpt-pr:fastgpt_ff5a2e6448e23bf29965df2212a385a5e657ae47

🕒 Time: 2026-09-15 14:31:07 (UTC+8)

@xqvvu
xqvvu force-pushed the xqvvu/feat/admin-ui-migrate branch from eb68e82 to 715677e Compare September 8, 2026 02:32
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Docs preview deployed

🔗 👀 Click here to visit preview

ghcr.io/labring/fastgpt-docs-pr:ff5a2e6448e23bf29965df2212a385a5e657ae47

🕒 Time: 2026-09-15 14:27:28 (UTC+8)

- Add 25 /admin/* routes (dashboard, users/teams/plans/pays/invoice,
  apps/datasets, config basic/feature/model/thirdParty/user/pay/plugin/
  modelProvider, templates app/toolkit, inform, log, audit, home)
- Extend SecondaryNavigationContainer with two-level grouped sidebar
  (SideTabs/Group, backward compatible with account pages)
- Add admin entry to navbar for root users; redirect old /config/* routes
  to /admin/config/*
- Migrate admin components (BoxCard, markdown, Settings form series,
  PlanComponents) and frontend API wrappers (web/admin/*) calling
  pro/admin APIs via /proApi proxy with silent degrade when pro is absent
- Add license activation UI (LicenseInput/LicenseData) + root license
  detection in Layout; useSystemStore license state
- Register new deps in pnpm catalog (react-table, nodemailer, alicloud,
  xml2js, canvas, xterm)

Design: .agents/design/admin/pro-admin-ui-migrate.md
canvas@3.2.3 was added to the app catalog/package.json during the admin
migration but is never imported by any app code (pro/admin pins its own
^3.0.0 for captcha). Its node-gyp install script requires Python, which
breaks the alpine maindeps Docker build. Keep onlyBuiltDependencies entry
for pro/admin.
- add LICENSE_PUBLIC_KEY(_PATH) env, license schema (schemaVersion 1|2,
  trial|official, functions gate), signature verify + normalize helpers
- system config: instanceId registration, license data surfaced to
  admin license page
- app admin: License Input/Data components wired to new verify API,
  tenant name display, i18n (en/zh/ko/zh-Hant)
- bump pro submodule (license auth + license-server)
Rebase onto upstream main required three integration fixes:

- Model config page: upstream relocated `pageComponents/account/model/*`
  to `pageComponents/model/*`; repoint the migrated admin ModelProvider
  imports to the new path (component signatures unchanged).
- Layout model-config guard: upstream's `/config/model` skip guard is
  dead code here — the branch redirects that legacy route to
  `/admin/config/modelProvider` via next.config, so guard the canonical route.
- System params: drop the deprecated `oneAPI地址/密钥` form fields and the
  matching `oneapiUrl`/`chatApiKey` systemEnv plumbing; upstream V4.17.0
  removed these overrides (they no longer take effect) and pro's config
  form no longer exposes them.
@xqvvu
xqvvu force-pushed the xqvvu/feat/admin-ui-migrate branch from 26aeed0 to 3162881 Compare September 15, 2026 06:13
}
];
},
// 旧 root 配置路由迁移到 /admin 后的重定向(避免历史链接/书签失效)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用重定向吧

Comment thread projects/app/CLAUDE.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除

Comment thread projects/app/AGENTS.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除

# PRO_URL=
# PRO_TOKEN=
# License-server 公钥(与签发服务的 LICENSE_PRIVATE_KEY 配对,二选一)
# LICENSE_PUBLIC_KEY=-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥公钥会在 app 里

'/config/system/migrations'
]
link: '/admin/dashboard',
// 管理员区域路由前缀匹配;旧 /config 路由已重定向,activeLink 保留以兼容重定向生效前的瞬时路径

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

扫描一遍,不用考虑兼容旧的路由

const { setUserDefaultLng, setShareDefaultLng } = useI18nLng();
const checkedModelIdentityRef = useRef<string>();

// root 登录后检测 license 状态(开源版未激活时提示激活/购买商业版)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里直接跳转对应页面好了

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个去掉吧有 icon 了

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该能直接复用通用 md 组件了

"toolkit_runtime_config_pod_timeout_tip": "Pod 閒置超過該時間後會被回收"
"toolkit_runtime_config_pod_timeout_tip": "Pod 閒置超過該時間後會被回收",
"license_admin_home": "管理員首頁",
"license_admin_home_description": "查看目前租戶的 License 授權、資源額度與授權能力",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加一个 admin 的 ns,admin 都放那边吧

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license 相关代码应该写在 admin 吧?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants