e3b82b981a
来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2
冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
896 lines
29 KiB
React
896 lines
29 KiB
React
/*
|
||
Copyright (C) 2025 QuantumNous
|
||
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU Affero General Public License as
|
||
published by the Free Software Foundation, either version 3 of the
|
||
License, or (at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU Affero General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Affero General Public License
|
||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
For commercial licensing, please contact support@quantumnous.com
|
||
*/
|
||
|
||
import React, { lazy, Suspense, useContext, useMemo } from 'react';
|
||
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
||
import {
|
||
isMiniProgramPaymentPath,
|
||
isMiniProgramWebView,
|
||
} from './helpers/miniProgram';
|
||
import Loading from './components/common/ui/Loading';
|
||
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
|
||
import NotFound from './pages/NotFound';
|
||
import Forbidden from './pages/Forbidden';
|
||
import { StatusContext } from './context/Status';
|
||
import { UserContext } from './context/User';
|
||
import SetupCheck from './components/layout/SetupCheck';
|
||
import { CLOUD_BRAIN_UI_ENABLED } from './config/cloudBrainUi';
|
||
import {
|
||
getHeaderModuleRequireAuth,
|
||
normalizeHeaderNavModules,
|
||
normalizeOrgUserNavModules,
|
||
isHeaderModuleEnabled,
|
||
} from './constants/headerNavModules';
|
||
import {
|
||
hasEnabledOrgCenterModule,
|
||
normalizeSidebarModulesAdmin,
|
||
} from './constants/sidebarModules';
|
||
import { useOrgMembership } from './hooks/common/useOrgMembership';
|
||
|
||
// 懒加载所有页面组件以优化首屏加载速度
|
||
const Home = lazy(() => import('./pages/Home'));
|
||
const About = lazy(() => import('./pages/About'));
|
||
const UserAgreement = lazy(() => import('./pages/UserAgreement'));
|
||
const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
|
||
const ExperienceCenter = lazy(() => import('./pages/ExperienceCenter'));
|
||
const UserCenter = lazy(() => import('./pages/UserCenter'));
|
||
const Recharge = lazy(() => import('./pages/Recharge'));
|
||
const Tutorial = lazy(() => import('./pages/Tutorial'));
|
||
const Docs = lazy(() => import('./pages/Docs'));
|
||
|
||
// 认证相关页面懒加载
|
||
const LoginForm = lazy(() => import('./components/auth/LoginForm'));
|
||
const OrgLogin = lazy(() => import('./pages/OrgLogin'));
|
||
const PartnerPortal = lazy(() => import('./pages/PartnerPortal'));
|
||
const PartnerConsole = lazy(() => import('./pages/PartnerPortal/Console'));
|
||
const MyCommission = lazy(() => import('./pages/MyCommission'));
|
||
const OrgRegister = lazy(() => import('./pages/OrgRegister'));
|
||
const RegisterForm = lazy(() => import('./components/auth/RegisterForm'));
|
||
const PasswordResetForm = lazy(
|
||
() => import('./components/auth/PasswordResetForm'),
|
||
);
|
||
const PasswordResetConfirm = lazy(
|
||
() => import('./components/auth/PasswordResetConfirm'),
|
||
);
|
||
const OAuth2Callback = lazy(() => import('./components/auth/OAuth2Callback'));
|
||
|
||
// 控制台页面懒加载
|
||
const User = lazy(() => import('./pages/User'));
|
||
const Setting = lazy(() => import('./pages/Setting'));
|
||
const WebsiteSettings = lazy(() => import('./pages/WebsiteSettings'));
|
||
const DemoReservations = lazy(() => import('./pages/DemoReservations'));
|
||
const Channel = lazy(() => import('./pages/Channel'));
|
||
const Token = lazy(() => import('./pages/Token'));
|
||
const Redemption = lazy(() => import('./pages/Redemption'));
|
||
const TopUp = lazy(() => import('./pages/TopUp'));
|
||
const Log = lazy(() => import('./pages/Log'));
|
||
const Chat = lazy(() => import('./pages/Chat'));
|
||
const Chat2Link = lazy(() => import('./pages/Chat2Link'));
|
||
const Midjourney = lazy(() => import('./pages/Midjourney'));
|
||
const Pricing = lazy(() => import('./pages/Pricing'));
|
||
const SkillMarket = lazy(() => import('./pages/SkillMarket'));
|
||
const Task = lazy(() => import('./pages/Task'));
|
||
const ModelPage = lazy(() => import('./pages/Model'));
|
||
const Playground = lazy(() => import('./pages/Playground'));
|
||
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
||
const PersonalSetting = lazy(
|
||
() => import('./components/settings/PersonalSetting'),
|
||
);
|
||
const Setup = lazy(() => import('./pages/Setup'));
|
||
const Analytics = lazy(() => import('./pages/Analytics'));
|
||
const Organization = lazy(() => import('./pages/Organization'));
|
||
const AdminOrganizations = lazy(() => import('./pages/AdminOrganizations'));
|
||
const AdminOrder = lazy(() => import('./pages/AdminOrder'));
|
||
const AdminInvoice = lazy(() => import('./pages/AdminInvoice'));
|
||
const Subscription = lazy(() => import('./pages/Subscription'));
|
||
const SkillPlatform = lazy(() => import('./pages/SkillPlatform'));
|
||
const ExpertPlatform = lazy(() => import('./pages/ExpertPlatform'));
|
||
// WeyAi:客户端授权页(自带登录判断,不套 PrivateRoute)与桌面端下载页
|
||
const ClientAuthorize = lazy(() => import('./pages/ClientAuthorize'));
|
||
const WeyAiDownload = lazy(() => import('./pages/WeyAiDownload'));
|
||
|
||
// org_only(仅企业资源)员工被限制在企业空间:仅放行以下前缀,其余 C 端路由统一重定向 /org
|
||
const ORG_ALLOWED_PREFIXES = [
|
||
'/org',
|
||
'/login',
|
||
'/logout',
|
||
'/oauth',
|
||
'/forbidden',
|
||
'/setup',
|
||
'/register',
|
||
// WeyAi 授权页与下载页:企业员工也要能登录 WeyAi 桌面端/网页端
|
||
'/client/authorize',
|
||
'/weyai/download',
|
||
];
|
||
// 企业员工顶栏可配置的 C 端入口 → 对应路由前缀。
|
||
// 管理员在「企业员工顶栏配置」里放开某项时,必须同步放行其目标路由,
|
||
// 否则会出现「按钮显示了、点了却被踢回 /org」的死按钮。
|
||
const ORG_USER_NAV_PATHS = {
|
||
// /pricing 为模型超市旧路径,保留放行以便旧链接经重定向进入 /market 时不被企业封锁踢回
|
||
pricing: ['/market', '/pricing'],
|
||
skillMarket: ['/skill-market'],
|
||
docs: ['/docs'],
|
||
experienceCenter: ['/experience-center'],
|
||
keyManagement: ['/key-management', '/user-center/key-management'],
|
||
userCenter: ['/user-center'],
|
||
};
|
||
const isOrgAllowedPath = (pathname, extraPrefixes = []) =>
|
||
[...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some(
|
||
(p) => pathname === p || pathname.startsWith(p + '/'),
|
||
);
|
||
|
||
// 模型超市旧路径 /pricing → /market。用组件而非静态 <Navigate>,
|
||
// 以保留 query/hash(如资源过期重载的 __wl_reload 参数、外部带参分享链接)
|
||
const PricingLegacyRedirect = () => {
|
||
const location = useLocation();
|
||
return (
|
||
<Navigate
|
||
to={{ pathname: '/market', search: location.search, hash: location.hash }}
|
||
replace
|
||
/>
|
||
);
|
||
};
|
||
|
||
function App() {
|
||
const location = useLocation();
|
||
const [statusState] = useContext(StatusContext);
|
||
const [userState] = useContext(UserContext);
|
||
|
||
// 获取模块权限配置
|
||
const moduleAuthConfig = useMemo(() => {
|
||
const headerNavModulesConfig = statusState?.status?.HeaderNavModules;
|
||
const modules = normalizeHeaderNavModules(headerNavModulesConfig);
|
||
|
||
return {
|
||
experienceCenter: getHeaderModuleRequireAuth(modules, 'experienceCenter'),
|
||
keyManagement: getHeaderModuleRequireAuth(modules, 'keyManagement'),
|
||
userCenter: getHeaderModuleRequireAuth(modules, 'userCenter'),
|
||
pricing: getHeaderModuleRequireAuth(modules, 'pricing'),
|
||
skillMarket: getHeaderModuleRequireAuth(modules, 'skillMarket'),
|
||
docs: getHeaderModuleRequireAuth(modules, 'docs'),
|
||
};
|
||
}, [statusState?.status?.HeaderNavModules]);
|
||
|
||
const sidebarModulesAdmin = useMemo(
|
||
() =>
|
||
normalizeSidebarModulesAdmin(statusState?.status?.SidebarModulesAdmin),
|
||
[statusState?.status?.SidebarModulesAdmin],
|
||
);
|
||
const orgCenterConfig = sidebarModulesAdmin.orgCenter || {};
|
||
const isOrgCenterAvailable = hasEnabledOrgCenterModule(orgCenterConfig);
|
||
// 仅 org_only 用户需要这个判断(其余用户不受 orgConfined 约束);且
|
||
// useHeaderBar 已在每个页面调用同一 hook,API 层的 in-flight GET 去重
|
||
// 会合并这两次 /api/org/list,不产生额外请求。
|
||
const { isOrgAdmin, loaded: orgMembershipLoaded } = useOrgMembership(
|
||
userState?.user?.id,
|
||
userState?.user?.org_only_mode === true,
|
||
);
|
||
|
||
// 企业员工顶栏放开的 C 端入口(模型服务/文档等)需同步放行其目标路由,
|
||
// 使「显示即可进入」,避免点击后被企业封锁重定向。配置源与顶栏一致。
|
||
const orgUserAllowedPrefixes = useMemo(() => {
|
||
const orgUserNav = normalizeOrgUserNavModules(
|
||
statusState?.status?.HeaderNavModulesOrgUser,
|
||
);
|
||
const prefixes = Object.entries(ORG_USER_NAV_PATHS)
|
||
.filter(([key]) => isHeaderModuleEnabled(orgUserNav, key))
|
||
.flatMap(([, paths]) => paths);
|
||
// 顶栏右侧按钮(新手教程/充值)由 rightActions 配置控制,与中部导航同理:
|
||
// 管理员放开按钮必须同步放行其目标路由,否则按钮显示了、点了却被踢回
|
||
// /org(推广按钮打开的是 Modal,不涉及导航,无需放行)。
|
||
if (orgUserNav.rightActions?.tutorial === true) prefixes.push('/tutorial');
|
||
if (orgUserNav.rightActions?.recharge === true) prefixes.push('/recharge');
|
||
// 技能超市对企业管理员不只是"浏览入口",它同时是「为企业启用平台技能」的
|
||
// 唯一落点(企业侧 /org/skill-market 管理页已并入其中)。而企业 owner 与
|
||
// 托管成员账号默认就是 org_only(model/organization.go 的
|
||
// CreateOrganizationWithManagedOwnerTx、controller/organization_account.go),
|
||
// 若运营关掉「企业员工顶栏 → 技能超市」,这些管理员会被 orgConfined 弹回
|
||
// /org,从此无任何路径把平台技能加入企业技能库——技能库与分发页永远为空。
|
||
// 顶栏开关的本意是收敛"员工浏览目录",不应连带阉割企业治理能力,故对
|
||
// 管理员无条件放行该路由(页面内部仍按 skill_manage 决定是否出现启用按钮)。
|
||
if (isOrgAdmin && !prefixes.includes('/skill-market')) {
|
||
prefixes.push('/skill-market');
|
||
}
|
||
return prefixes;
|
||
}, [statusState?.status?.HeaderNavModulesOrgUser, isOrgAdmin]);
|
||
|
||
// 路由级封锁:org_only 员工访问非企业路由一律回到企业空间。
|
||
// 仅在企业中心可用时启用,避免企业中心被全局关闭时与其内部回退跳转形成重定向死循环。
|
||
// 企业列表未到位前不做封锁判定:isOrgAdmin 首帧恒 false,此时若直接重定向,
|
||
// 硬刷新/收藏夹直达 /skill-market 的 org_only 管理员会在放行判据还没算出来时
|
||
// 就被弹回 /org,而重定向不可逆——之后 isOrgAdmin 变 true 也回不去。
|
||
const orgConfined =
|
||
userState?.user?.org_only_mode === true &&
|
||
orgMembershipLoaded &&
|
||
isOrgCenterAvailable &&
|
||
!isOrgAllowedPath(location.pathname, orgUserAllowedPrefixes);
|
||
|
||
if (orgConfined) {
|
||
return (
|
||
<SetupCheck>
|
||
<Navigate to='/org' replace />
|
||
</SetupCheck>
|
||
);
|
||
}
|
||
|
||
// WeyAi 小程序的 web-view 里不出现付费页面(见 helpers/miniProgram.js),直接回到个人中心。
|
||
if (isMiniProgramWebView() && isMiniProgramPaymentPath(location.pathname)) {
|
||
return <Navigate to='/user-center' replace />;
|
||
}
|
||
|
||
return (
|
||
<SetupCheck>
|
||
<Routes>
|
||
<Route
|
||
path='/'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Home />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/home'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Home />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/setup'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Setup />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route path='/forbidden' element={<Forbidden />} />
|
||
<Route
|
||
path='/console/models'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<ModelPage />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/channel'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Channel />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/token'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Token />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/playground'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Playground />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/monitor'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<MonitorCenter />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/analytics'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Analytics />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/my-commission'
|
||
element={
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<MyCommission />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/partner'
|
||
element={
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<PartnerConsole />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/experience-center-audit'
|
||
element={
|
||
<AdminRoute>
|
||
<Navigate to='/console/analytics?tab=audit' replace />
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/organizations'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<AdminOrganizations />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/skill-platform'
|
||
element={
|
||
CLOUD_BRAIN_UI_ENABLED ? (
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<SkillPlatform />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
) : (
|
||
<Navigate to='/console' replace />
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/expert-platform'
|
||
element={
|
||
CLOUD_BRAIN_UI_ENABLED ? (
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<ExpertPlatform />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
) : (
|
||
<Navigate to='/console' replace />
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/order'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<AdminOrder />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/invoice'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<AdminInvoice />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
{/* 旧路由重定向到用户中心内的服务监控 */}
|
||
<Route
|
||
path='/service-dashboard'
|
||
element={<Navigate to='/user-center/service-dashboard' replace />}
|
||
/>
|
||
<Route
|
||
path='/experience-center/cloud-brain'
|
||
element={
|
||
CLOUD_BRAIN_UI_ENABLED ? (
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading />} key={location.pathname}>
|
||
<ExperienceCenter />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Navigate to='/experience-center' replace />
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/experience-center/*'
|
||
element={
|
||
moduleAuthConfig.experienceCenter ? (
|
||
<PrivateRoute>
|
||
<Suspense
|
||
fallback={<Loading></Loading>}
|
||
key={location.pathname}
|
||
>
|
||
<ExperienceCenter />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<ExperienceCenter />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/redemption'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Redemption />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/user'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<User />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/subscription'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Subscription />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/user/reset'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<PasswordResetConfirm />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/login'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<AuthRedirect>
|
||
<LoginForm />
|
||
</AuthRedirect>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/org/login'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OrgLogin />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/partner'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<PartnerPortal />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/org/:slug/login'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OrgLogin />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/org/register'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OrgRegister />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/register'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<AuthRedirect>
|
||
<RegisterForm />
|
||
</AuthRedirect>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/reset'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<PasswordResetForm />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/github'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OAuth2Callback type='github'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/discord'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OAuth2Callback type='discord'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/oidc'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>}>
|
||
<OAuth2Callback type='oidc'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/linuxdo'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OAuth2Callback type='linuxdo'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/wechat-open'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OAuth2Callback type='wechat/open'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/oauth/wechat-mp'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<OAuth2Callback type='wechat/mp'></OAuth2Callback>
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/setting'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Setting />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/website-setting'
|
||
element={
|
||
<AdminRoute permission='website-setting'>
|
||
<Suspense fallback={<Loading />}>
|
||
<WebsiteSettings />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/demo-reservations'
|
||
element={
|
||
<AdminRoute permission='demo-reservations'>
|
||
<Suspense fallback={<Loading />}>
|
||
<DemoReservations />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/personal'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<PersonalSetting />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/topup'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<TopUp />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/log'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading />}>
|
||
<Log />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console'
|
||
element={
|
||
<AdminRoute>
|
||
<Navigate to='/console/analytics' replace />
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/midjourney'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Midjourney />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/task'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Task />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/market'
|
||
element={
|
||
moduleAuthConfig.pricing ? (
|
||
<PrivateRoute>
|
||
<Suspense
|
||
fallback={<Loading></Loading>}
|
||
key={location.pathname}
|
||
>
|
||
<Pricing />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Pricing />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
{/* 模型超市旧路径兼容:外部收藏/文档中的 /pricing 链接重定向到 /market */}
|
||
<Route path='/pricing' element={<PricingLegacyRedirect />} />
|
||
{/* 技能超市:与模型超市同构的平台级目录页,同时是"为企业启用技能"的
|
||
唯一入口——企业侧原 /org/skill-market 管理页已并入这里,按身份渐进
|
||
增强(游客浏览 / 个人收藏 / 员工「我想要」/ 管理员就地为企业启用)。 */}
|
||
<Route
|
||
path='/skill-market'
|
||
element={
|
||
moduleAuthConfig.skillMarket ? (
|
||
<PrivateRoute>
|
||
<Suspense
|
||
fallback={<Loading></Loading>}
|
||
key={location.pathname}
|
||
>
|
||
<SkillMarket />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<SkillMarket />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
{/* 密钥管理归入用户中心路径;旧地址保留为重定向(旧链接、登录回跳、书签) */}
|
||
<Route
|
||
path='/key-management'
|
||
element={<Navigate to='/user-center/key-management' replace />}
|
||
/>
|
||
<Route
|
||
path='/user-center/key-management'
|
||
element={
|
||
moduleAuthConfig.keyManagement ? (
|
||
<PrivateRoute>
|
||
<Suspense
|
||
fallback={<Loading></Loading>}
|
||
key={location.pathname}
|
||
>
|
||
<UserCenter keyManagementMode />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<UserCenter keyManagementMode />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/user-center/*'
|
||
element={
|
||
moduleAuthConfig.userCenter ? (
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading></Loading>}>
|
||
<UserCenter />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>}>
|
||
<UserCenter />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/recharge'
|
||
element={
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Recharge />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/tutorial'
|
||
element={
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Tutorial />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/docs'
|
||
element={
|
||
moduleAuthConfig.docs ? (
|
||
<PrivateRoute>
|
||
<Suspense
|
||
fallback={<Loading></Loading>}
|
||
key={location.pathname}
|
||
>
|
||
<Docs />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
) : (
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Docs />
|
||
</Suspense>
|
||
)
|
||
}
|
||
/>
|
||
<Route
|
||
path='/about'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<About />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/user-agreement'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<UserAgreement />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/privacy-policy'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<PrivacyPolicy />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/console/chat/:id?'
|
||
element={
|
||
<AdminRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Chat />
|
||
</Suspense>
|
||
</AdminRoute>
|
||
}
|
||
/>
|
||
{/* 方便使用chat2link直接跳转聊天... */}
|
||
<Route
|
||
path='/chat2link'
|
||
element={
|
||
<PrivateRoute>
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<Chat2Link />
|
||
</Suspense>
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/org/create'
|
||
element={
|
||
<PrivateRoute>
|
||
{/* 已下线的自助加入企业页:旧链接/书签统一交给企业中心入口解析 */}
|
||
<Navigate to='/org' replace />
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/org/*'
|
||
element={
|
||
<PrivateRoute>
|
||
{isOrgCenterAvailable ? (
|
||
<Suspense fallback={<Loading />}>
|
||
<Organization />
|
||
</Suspense>
|
||
) : (
|
||
<Navigate to='/user-center/dashboard' replace />
|
||
)}
|
||
</PrivateRoute>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/client/authorize'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<ClientAuthorize />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route
|
||
path='/weyai/download'
|
||
element={
|
||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||
<WeyAiDownload />
|
||
</Suspense>
|
||
}
|
||
/>
|
||
<Route path='*' element={<NotFound />} />
|
||
</Routes>
|
||
</SetupCheck>
|
||
);
|
||
}
|
||
|
||
export default App;
|