sync: 同步总仓库 luoguang/monkey-ai weiyuan@bfdfb339 的 web/ 改动
同步基准:总仓库 a2ca13cb(= 本仓库初始导入 d8f3aee2) 范围:a2ca13cb..bfdfb339 中触及 web/ 的提交(不含 web/.claude/settings.local.json) - 8490ac02 feat(aliyun): integrate Wan 3 and Qwen Image models - 2aff08ec perf(analytics): 运营看板概览改读汇总表,首屏从 19s 降到 0.4s - dc69335e feat(experience): 体验中心图像/视频创作升级(能力 schema、估价、新创作台) - b059c657 fix(org): 下线 /org/create 自助加入企业页与 POST /api/org/join - 4fcf47e6 fix(i18n): 修复中/英/韩/繁体多语言错乱,补齐日/越/泰译文 - e4c301d5 fix: merge enterprise task record date filters - c9369b95 feat: expose enterprise image and video task records - a410fee5 feat(claude): 无断点请求自动注入 cache_control 断点(方案 2) - 521b3376 feat(claude): 缓存命中率优化——上游粘性路由 + 缓存时长强制改写 - 73b615dd feat(pricing): 企业成员不论登录身份均按所属企业等级计价与扣费 - f73f55c3 feat(client): 新增 WeyAi 版本说明管理与公开读取接口 - 8cdf1994 fix(topup): reset amount when switching from PayPal - 93a4ac34 feat(baidu): configure Seedance liveness header by channel - cb1818c5 fix(weyai): 按评审修正内容清理竞态、默认适用端与中文退回(M21) - 04214d83 feat(weyai): WeyAi 内容管理与客户端内容接口(M21 第二部分) - e3c4a57c feat(weyai): 设置页新增 WeyAi 页签与内容专用 COS 桶(M21 第一部分) - b5ee8e70 fix(auth): 会话角色/状态以 DB 为准,修复提升管理员后管理接口报权限不足 - e4618fc2 fix: 修复企业看板日志聚合死循环导致 CPU 打满,并降低看板查询开销 - 584aad52 style(web): 个人中心侧边栏按 prettier 换行 - b8d87064 fix: 小程序教程隐藏充值后保留原步骤编号,企业充值判断直接用 isMiniProgramWebView - eee7f5b2 fix: 小程序里企业首页不落到充值页,隐藏钱包入口与教程充值步骤 - 8b254d49 fix: 小程序里隐藏企业充值入口与页面 - a67661b4 fix(web): 小程序里个人中心默认页跳过充值和发票,避免来回跳转 - cff6c543 feat(web): WeyAi 小程序里打开个人中心时不出现充值和开票 - c6c99eb6 feat(billing): Claude 全部缓存写入统一按 1h 倍率计费 - 0699d1bf fix(web): 小程序 web-view 里注册页同样只显示站内方式 - 04853331 feat(web): WeyAi 小程序 web-view 里登录页只显示站内登录方式
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
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, { useState, useCallback, useEffect, useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Building2,
|
||||
AlertTriangle,
|
||||
RefreshCw,
|
||||
HelpCircle,
|
||||
Home,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { UserContext } from '../../context/User';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
|
||||
// 企业中心入口解析:本地没有可用的 current_org_id 时,由企业中心就地渲染本组件(不再跳转独立页面)。
|
||||
// 企业与成员均由管理员创建,不提供用户自助加入。按归属状态区分:
|
||||
// none —— 用户不属于任何企业,引导联系企业管理员开通账号
|
||||
// inactive —— 用户有企业但均非活跃(冻结/欠费/待激活),引导联系管理员
|
||||
// error —— 企业列表加载失败,提供重试
|
||||
const ORG_STATUS_TEXT = {
|
||||
2: '已被冻结',
|
||||
3: '已欠费',
|
||||
4: '待激活',
|
||||
};
|
||||
|
||||
const OrgResolver = ({
|
||||
onResolved,
|
||||
excludeOrgIds = [],
|
||||
hasMarquee = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [userState] = useContext(UserContext);
|
||||
const isOrgOnly = userState?.user?.org_only_mode === true;
|
||||
// 'checking' | 'none' | 'inactive' | 'error'
|
||||
const [mode, setMode] = useState('checking');
|
||||
const [inactiveOrgs, setInactiveOrgs] = useState([]);
|
||||
|
||||
// 有 active(status=1) 企业 → 写入 current_org_id 并交回企业中心(仅认 active,防冻结企业死循环)。
|
||||
// excludeOrgIds 为本次加载失败过的企业:自动解析时一律跳过,避免"选中→失败→再选中"的循环;
|
||||
// 可用企业若全部失败过,按加载失败处理(可能只是网络抖动),由用户手动重试时才再次尝试。
|
||||
const runCheck = useCallback(
|
||||
async (retryExcluded = false) => {
|
||||
setMode('checking');
|
||||
try {
|
||||
const res = await API.get('/api/org/list');
|
||||
if (res.data.success) {
|
||||
const orgs = res.data.data || [];
|
||||
const activeOrgs = orgs.filter((o) => o.status === 1);
|
||||
const candidates = retryExcluded
|
||||
? activeOrgs
|
||||
: activeOrgs.filter((o) => !excludeOrgIds.includes(o.id));
|
||||
if (candidates.length > 0) {
|
||||
const savedOrgId = parseInt(
|
||||
localStorage.getItem('current_org_id') || '0',
|
||||
10,
|
||||
);
|
||||
const savedOrg =
|
||||
savedOrgId > 0
|
||||
? candidates.find((o) => o.id === savedOrgId)
|
||||
: null;
|
||||
const targetOrg = savedOrg || candidates[0];
|
||||
localStorage.setItem('current_org_id', String(targetOrg.id));
|
||||
onResolved(targetOrg.id);
|
||||
return;
|
||||
}
|
||||
if (activeOrgs.length > 0) {
|
||||
setMode('error');
|
||||
return;
|
||||
}
|
||||
if (orgs.length > 0) {
|
||||
setInactiveOrgs(orgs);
|
||||
setMode('inactive');
|
||||
return;
|
||||
}
|
||||
setMode('none');
|
||||
return;
|
||||
}
|
||||
setMode('error');
|
||||
} catch {
|
||||
setMode('error');
|
||||
}
|
||||
},
|
||||
[onResolved, excludeOrgIds],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
runCheck();
|
||||
}, [runCheck]);
|
||||
|
||||
if (mode === 'checking') {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
// 非 org_only 用户提供「返回首页」出口,避免被困在本页;org_only 员工受守卫限制在 /org,不提供。
|
||||
const backHome = !isOrgOnly && (
|
||||
<div className='mt-6 text-center'>
|
||||
<button
|
||||
onClick={() => navigate('/')}
|
||||
className='inline-flex items-center gap-1.5 text-sm text-gray-400 dark:text-gray-500 hover:text-brand-deep transition-colors'
|
||||
>
|
||||
<Home size={14} />
|
||||
{t('返回首页')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
// /org 下 PageLayout 关闭外层滚动、也不插跑马灯占位:顶部让位与滚动都由本页自理(同企业中心主布局)。
|
||||
<div
|
||||
className={`org-center relative h-screen overflow-y-auto bg-[var(--surface-bg-base)] transition-colors duration-300 ${hasMarquee ? 'pt-[96px] sm:pt-[104px]' : 'pt-14 sm:pt-16'}`}
|
||||
>
|
||||
{/* 统一页面背景层 —— 唯一背景来源,走 bg-glow-* 主题变量 */}
|
||||
<PageBackground />
|
||||
|
||||
<div className='relative z-10 min-h-full flex items-center justify-center py-10 px-4'>
|
||||
<div className='w-full max-w-md'>
|
||||
{mode === 'none' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-brand-from via-brand-via to-brand-to mb-5 shadow-lg shadow-brand/25 dark:shadow-brand/15'>
|
||||
<Building2 size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('暂未加入企业')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t(
|
||||
'企业成员账号由企业管理员统一创建,请联系你的企业管理员开通',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<div className='flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'管理员创建账号后,请使用企业账号通过「企业登录」进入企业中心。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck()}
|
||||
className='mt-4'
|
||||
>
|
||||
{t('刷新状态')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'inactive' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-amber-400 to-amber-500 mb-5 shadow-lg shadow-amber-500/25 dark:shadow-amber-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('企业暂不可用')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('你所属的企业当前无法访问,请联系管理员处理')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<div className='space-y-2.5'>
|
||||
{inactiveOrgs.map((org) => (
|
||||
<div
|
||||
key={org.id}
|
||||
className='flex items-center justify-between gap-3 p-3 rounded-xl bg-gray-50 dark:bg-neutral-800/60 border border-gray-100 dark:border-neutral-800'
|
||||
>
|
||||
<div className='flex items-center gap-2.5 min-w-0'>
|
||||
<Building2
|
||||
size={16}
|
||||
className='text-gray-400 flex-shrink-0'
|
||||
/>
|
||||
<span className='text-sm font-medium text-gray-900 dark:text-white truncate'>
|
||||
{org.name || t('企业') + ' #' + org.id}
|
||||
</span>
|
||||
</div>
|
||||
<span className='text-xs font-medium text-amber-600 dark:text-amber-400 flex-shrink-0'>
|
||||
{t(ORG_STATUS_TEXT[org.status] || '不可用')}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className='mt-5 pt-5 border-t border-gray-100 dark:border-neutral-800 flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'企业激活、解冻或续费由平台管理员处理,请联系企业管理员或平台客服。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck()}
|
||||
className='mt-4'
|
||||
>
|
||||
{t('刷新状态')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'error' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-red-400 to-red-500 mb-5 shadow-lg shadow-red-500/25 dark:shadow-red-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('加载失败')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('无法获取你的企业信息,请检查网络后重试')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck(true)}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgResolver;
|
||||
Reference in New Issue
Block a user