merge: 合入总仓库 weiyuan(bfdfb339) web/ 新功能,保留 ui-optimization 的 UI 重构
来源: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
This commit is contained in:
@@ -54,7 +54,7 @@ const paymentMethodMap = {
|
||||
};
|
||||
|
||||
const AdminInvoice = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [invoices, setInvoices] = useState([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -226,7 +226,7 @@ const AdminInvoice = () => {
|
||||
|
||||
const formatTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
return new Date(timestamp * 1000).toLocaleString();
|
||||
return new Date(timestamp * 1000).toLocaleString(i18n.language);
|
||||
};
|
||||
|
||||
const columns = [
|
||||
@@ -591,7 +591,7 @@ const AdminInvoice = () => {
|
||||
title: t('方式'),
|
||||
dataIndex: 'payment_method',
|
||||
width: 80,
|
||||
render: (v) => paymentMethodMap[v] || v,
|
||||
render: (v) => t(paymentMethodMap[v] || v),
|
||||
},
|
||||
{
|
||||
title: t('金额'),
|
||||
|
||||
@@ -81,7 +81,7 @@ import {
|
||||
} from '../../components/console/ConsoleModuleFilters';
|
||||
|
||||
const AdminOrder = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [detailOrder, setDetailOrder] = useState(null);
|
||||
const [queryVersion, setQueryVersion] = useState(0);
|
||||
const [orders, setOrders] = useState([]);
|
||||
@@ -229,7 +229,7 @@ const AdminOrder = () => {
|
||||
|
||||
const formatTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
return new Date(timestamp * 1000).toLocaleString();
|
||||
return new Date(timestamp * 1000).toLocaleString(i18n.language);
|
||||
};
|
||||
|
||||
const columns = [
|
||||
@@ -296,7 +296,7 @@ const AdminOrder = () => {
|
||||
title: t('支付方式'),
|
||||
dataIndex: 'payment_method',
|
||||
width: 80,
|
||||
render: (v) => (v ? paymentMethodMap[v] || v : '-'),
|
||||
render: (v) => (v ? t(paymentMethodMap[v] || v) : '-'),
|
||||
},
|
||||
{
|
||||
title: t('PayPal 结算'),
|
||||
|
||||
@@ -1506,27 +1506,6 @@ const AdminOrganizations = () => {
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5'>
|
||||
{t('新成员默认额度上限')}
|
||||
</label>
|
||||
<QuotaInput
|
||||
value={editForm.default_member_quota}
|
||||
onChange={(v) =>
|
||||
setEditForm({ ...editForm, default_member_quota: v ?? 0 })
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
minQuota={0}
|
||||
placeholder={t('请输入金额,0 表示不限制')}
|
||||
/>
|
||||
{!(Number(editForm.default_member_quota) > 0) && (
|
||||
<p className='text-xs text-amber-500 mt-1'>
|
||||
{t(
|
||||
'为 0 时:企业码自助加入的新成员可不受限制地使用企业额度池,存在被盗刷风险',
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5'>
|
||||
{t('企业描述')}
|
||||
|
||||
@@ -156,6 +156,7 @@ const Analytics = () => {
|
||||
const [riskRuleModalVisible, setRiskRuleModalVisible] = useState(false);
|
||||
const {
|
||||
loading,
|
||||
overviewLoading,
|
||||
overview,
|
||||
userTrend,
|
||||
financeTrend,
|
||||
@@ -194,6 +195,8 @@ const Analytics = () => {
|
||||
const curSetDateRange = isOrgTab ? org.setDateRange : setDateRange;
|
||||
const curRefresh = isOrgTab ? org.refreshAll : refreshAll;
|
||||
const curLoading = isOrgTab ? org.loading : loading;
|
||||
// 概览卡片自己带骨架屏,不进全页遮罩;但刷新按钮要等它一起转完才算刷新结束
|
||||
const curOverviewLoading = isOrgTab ? false : overviewLoading;
|
||||
|
||||
const handleTabChange = (key) => {
|
||||
setActiveTab(key);
|
||||
@@ -267,7 +270,7 @@ const Analytics = () => {
|
||||
<Button
|
||||
icon={<IconRefresh />}
|
||||
onClick={() => curRefresh(curPeriod, curDateRange, true)}
|
||||
loading={curLoading}
|
||||
loading={curLoading || curOverviewLoading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
@@ -358,7 +361,11 @@ const Analytics = () => {
|
||||
isAnalyticsTabVisible('operations') && (
|
||||
<>
|
||||
{/* Overview Cards */}
|
||||
<OverviewCards overview={overview} t={t} />
|
||||
<OverviewCards
|
||||
overview={overview}
|
||||
loading={overviewLoading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
{/* Trend Charts */}
|
||||
<div className='grid grid-cols-1 lg:grid-cols-2 gap-4'>
|
||||
|
||||
@@ -109,9 +109,9 @@ const statusMeta = {
|
||||
stopped: { icon: Square, tone: 'grey', label: '已停止' },
|
||||
};
|
||||
|
||||
const safeDate = (timestamp, language) => {
|
||||
const safeDate = (timestamp, locale) => {
|
||||
if (!timestamp) return '—';
|
||||
return new Intl.DateTimeFormat(language === 'en' ? 'en-US' : 'zh-CN', {
|
||||
return new Intl.DateTimeFormat(locale || undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
@@ -1441,7 +1441,7 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
|
||||
expertName ? `${t('专家')}: ${expertName}` : '',
|
||||
`${t('状态')}: ${run.status}`,
|
||||
run.finished_at > 0
|
||||
? `${t('结束时间')}: ${safeDate(run.finished_at, language)}`
|
||||
? `${t('结束时间')}: ${safeDate(run.finished_at, i18n.language)}`
|
||||
: '',
|
||||
run.error_code ? `${t('错误码')}: ${run.error_code}` : '',
|
||||
reason ? `${t('失败原因')}: ${t(reason)}` : '',
|
||||
@@ -1660,12 +1660,12 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
|
||||
id: event.id,
|
||||
label: t(event.event_type),
|
||||
summary: summarizeRunEvent(event, t),
|
||||
time: safeDate(event.created_at, language),
|
||||
time: safeDate(event.created_at, i18n.language),
|
||||
// 同秒相邻事件不挂 "+0s":排队→开始→失败经常落在同一秒,每行都挂只是噪音。
|
||||
gap: gapSeconds > 0 ? formatDurationSeconds(gapSeconds) : '',
|
||||
};
|
||||
});
|
||||
}, [runDetail?.events, t, language]);
|
||||
}, [runDetail?.events, t, i18n.language]);
|
||||
const expertById = useMemo(
|
||||
() => new Map(experts.map((expert) => [expert.id, expert])),
|
||||
[experts],
|
||||
@@ -2251,7 +2251,7 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
|
||||
<StatusPill status={run.status} />
|
||||
</div>
|
||||
<p>{run.input_text}</p>
|
||||
<time>{safeDate(run.created_at, language)}</time>
|
||||
<time>{safeDate(run.created_at, i18n.language)}</time>
|
||||
</button>
|
||||
);
|
||||
})
|
||||
@@ -2285,7 +2285,9 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
|
||||
<h2>{t('专家任务产物')}</h2>
|
||||
<div className='brain-detail-meta'>
|
||||
<StatusPill status={activeRun.status} />
|
||||
<span>{safeDate(activeRun.created_at, language)}</span>
|
||||
<span>
|
||||
{safeDate(activeRun.created_at, i18n.language)}
|
||||
</span>
|
||||
<span>
|
||||
{t('计费状态')}: {t(activeRun.billing_status)}
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 体验中心图像生成表单中 schema 驱动的新增区块(WP A2-3)。
|
||||
* 配色全部从主题 token 派生(frontend-design skill 铁律一),禁止裸色值。
|
||||
*/
|
||||
.image-generation-form {
|
||||
--igf-ink: var(--text-primary);
|
||||
--igf-muted: var(--text-secondary);
|
||||
--igf-line: var(--border-subtle);
|
||||
--igf-accent: var(--ui-color-primary);
|
||||
--igf-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
|
||||
--igf-danger: var(--ui-color-danger);
|
||||
--igf-warning: var(--ui-color-warning);
|
||||
--igf-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
|
||||
}
|
||||
|
||||
.image-generation-form button:focus-visible,
|
||||
.image-generation-form [role='button']:focus-visible {
|
||||
outline: 2px solid var(--igf-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* 历史卡片拖入时的整卡高亮 */
|
||||
.image-generation-form.is-drop-active {
|
||||
outline: 2px dashed
|
||||
color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
|
||||
outline-offset: -6px;
|
||||
}
|
||||
|
||||
.igf-muted {
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.igf-note {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.igf-hint {
|
||||
flex-basis: 100%;
|
||||
color: var(--igf-muted);
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.igf-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.igf-state-title {
|
||||
color: var(--igf-ink);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.igf-state.is-error .igf-state-title {
|
||||
color: var(--igf-danger);
|
||||
}
|
||||
|
||||
.igf-model-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.igf-model-name,
|
||||
.igf-model-id {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.igf-model-id {
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.igf-model-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 16px;
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--igf-fill);
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.igf-model-meta strong {
|
||||
color: var(--igf-ink);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.igf-model-desc {
|
||||
flex-basis: 100%;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.igf-mode-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.igf-slots {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.igf-size .cp-option-group--ratio .cp-option {
|
||||
min-width: 64px;
|
||||
}
|
||||
|
||||
.igf-size-dims {
|
||||
color: var(--igf-muted);
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.igf-size-custom {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.igf-size-custom .ant-input-number {
|
||||
flex: 1 1 110px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.igf-size-x {
|
||||
color: var(--igf-muted);
|
||||
}
|
||||
|
||||
.igf-dock-params {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.igf-generate {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.igf-quote {
|
||||
min-height: 18px;
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.igf-quote.is-warning {
|
||||
color: var(--igf-warning);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
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, { useEffect, useMemo, useState } from 'react';
|
||||
import { InputNumber } from '@/components/ui';
|
||||
import { SlidersHorizontal } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
OptionGroup,
|
||||
RatioShape,
|
||||
} from '../../../../../components/creation/params';
|
||||
import {
|
||||
clampSizeSide,
|
||||
customSizeRangeOf,
|
||||
parseSize,
|
||||
sizePresetsOf,
|
||||
} from '../../../../../hooks/image/imageCreation';
|
||||
|
||||
const CUSTOM = '__custom__';
|
||||
|
||||
/**
|
||||
* 图像尺寸(schema type = 'size'):预设按宽高比图标展示;仅当 schema 下发 custom_size 时
|
||||
* 提供"自定义",宽高输入框失焦 / 回车时按 min / max / step 吸附。
|
||||
*
|
||||
* props: { param, value: "WxH", onChange(value) }
|
||||
*/
|
||||
const ImageSizePicker = ({ param, value, onChange }) => {
|
||||
const { t } = useTranslation();
|
||||
const presets = useMemo(() => sizePresetsOf(param), [param]);
|
||||
const range = useMemo(() => customSizeRangeOf(param), [param]);
|
||||
const matched = presets.find(
|
||||
(p) => p.value.toLowerCase() === String(value || '').toLowerCase(),
|
||||
);
|
||||
// 用户点了"自定义"、或当前取值不是预设时进入自定义态
|
||||
const [customActive, setCustomActive] = useState(Boolean(range && !matched));
|
||||
useEffect(() => {
|
||||
if (!range) setCustomActive(false);
|
||||
else if (value && !matched) setCustomActive(true);
|
||||
}, [range, value, matched]);
|
||||
|
||||
const parsed = parseSize(String(value || '')) ||
|
||||
(presets[0] && { width: presets[0].width, height: presets[0].height }) || {
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
};
|
||||
const [draft, setDraft] = useState(parsed);
|
||||
useEffect(() => {
|
||||
setDraft(parsed);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
||||
const options = useMemo(() => {
|
||||
const list = presets.map((p) => p.value);
|
||||
if (range) list.push(CUSTOM);
|
||||
return list;
|
||||
}, [presets, range]);
|
||||
|
||||
const commit = (next) => {
|
||||
const w = clampSizeSide(next.width, range);
|
||||
const h = clampSizeSide(next.height, range);
|
||||
setDraft({ width: w, height: h });
|
||||
const v = `${w}x${h}`;
|
||||
if (v !== value) onChange && onChange(v);
|
||||
};
|
||||
|
||||
const onSelect = (v) => {
|
||||
if (v === CUSTOM) {
|
||||
setCustomActive(true);
|
||||
commit(draft);
|
||||
return;
|
||||
}
|
||||
setCustomActive(false);
|
||||
onChange && onChange(v);
|
||||
};
|
||||
|
||||
const selected = customActive ? CUSTOM : matched ? matched.value : undefined;
|
||||
|
||||
return (
|
||||
<div className='igf-size'>
|
||||
<OptionGroup
|
||||
variant='ratio'
|
||||
options={options}
|
||||
value={selected}
|
||||
onChange={onSelect}
|
||||
ariaLabel={t('尺寸')}
|
||||
getOptionAriaLabel={(opt) => {
|
||||
if (opt === CUSTOM) return t('自定义尺寸');
|
||||
const p = presets.find((x) => x.value === opt);
|
||||
return p ? `${p.label || ''} ${p.width}×${p.height}`.trim() : opt;
|
||||
}}
|
||||
renderOption={(opt) => {
|
||||
if (opt === CUSTOM) {
|
||||
return (
|
||||
<>
|
||||
<span className='cp-ratio-shape-box' aria-hidden='true'>
|
||||
<SlidersHorizontal size={14} />
|
||||
</span>
|
||||
<span className='cp-option-label'>{t('自定义')}</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
const p = presets.find((x) => x.value === opt);
|
||||
return (
|
||||
<>
|
||||
<RatioShape ratio={`${p.width}:${p.height}`} />
|
||||
<span className='cp-option-label tabular-nums'>
|
||||
{p.label || `${p.width}×${p.height}`}
|
||||
</span>
|
||||
{p.label ? (
|
||||
<span className='igf-size-dims tabular-nums'>
|
||||
{p.width}×{p.height}
|
||||
</span>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{range && customActive ? (
|
||||
<div className='igf-size-custom'>
|
||||
<InputNumber
|
||||
value={draft.width}
|
||||
onChange={(v) => setDraft((d) => ({ ...d, width: v }))}
|
||||
onBlur={() => commit(draft)}
|
||||
onPressEnter={() => commit(draft)}
|
||||
min={range.min}
|
||||
max={range.max}
|
||||
step={range.step}
|
||||
prefix={t('宽')}
|
||||
suffix='px'
|
||||
size='small'
|
||||
aria-label={t('宽度(像素)')}
|
||||
/>
|
||||
<span className='igf-size-x' aria-hidden='true'>
|
||||
×
|
||||
</span>
|
||||
<InputNumber
|
||||
value={draft.height}
|
||||
onChange={(v) => setDraft((d) => ({ ...d, height: v }))}
|
||||
onBlur={() => commit(draft)}
|
||||
onPressEnter={() => commit(draft)}
|
||||
min={range.min}
|
||||
max={range.max}
|
||||
step={range.step}
|
||||
prefix={t('高')}
|
||||
suffix='px'
|
||||
size='small'
|
||||
aria-label={t('高度(像素)')}
|
||||
/>
|
||||
<div className='igf-hint'>
|
||||
{t('宽高范围 {{min}}–{{max}} 像素,按 {{step}} 像素取整', range)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageSizePicker;
|
||||
@@ -33,7 +33,7 @@ const ImageDetailModal = ({
|
||||
onReuseParams,
|
||||
onUseAsReference,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
// 跟随视口宽度,避免 900px 固定值在窄笔记本/平板上溢出
|
||||
const [viewportWidth, setViewportWidth] = useState(
|
||||
@@ -88,7 +88,7 @@ const ImageDetailModal = ({
|
||||
const formatDateTime = (isoString) => {
|
||||
if (!isoString) return '-';
|
||||
const date = new Date(isoString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
return date.toLocaleString(i18n.language, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -116,7 +116,7 @@ const ImageDetailModal = ({
|
||||
{ label: t('质量'), value: task.quality, color: 'grey' },
|
||||
{
|
||||
label: t('数量'),
|
||||
value: task.n && task.n > 1 ? `${task.n} ${t('张')}` : null,
|
||||
value: task.n && task.n > 1 ? t('{{n}} 张', { n: task.n }) : null,
|
||||
color: 'grey',
|
||||
},
|
||||
].filter((p) => p.value);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useImageTaskManagement } from '../../../../hooks/image/useImageTaskManagement';
|
||||
import { useImageCreation } from '../../../../hooks/image/useImageCreation';
|
||||
import ImageGenerationForm from './ImageGenerationForm';
|
||||
import ImageTaskList from './ImageTaskList';
|
||||
import ImageDetailModal from './ImageDetailModal';
|
||||
@@ -26,66 +27,41 @@ import ImageDetailModal from './ImageDetailModal';
|
||||
const ImageGenerationTab = () => {
|
||||
const {
|
||||
tasks,
|
||||
loading,
|
||||
addTask,
|
||||
fetchTaskDetail,
|
||||
deleteTask,
|
||||
retryTask,
|
||||
refreshTasks,
|
||||
refreshTaskUrl,
|
||||
} = useImageTaskManagement();
|
||||
|
||||
// 创作表单:模型 / 参数来自 GET /api/creation/models?kind=image(WP A2-3)
|
||||
const creation = useImageCreation({ tasks, addTask, fetchTaskDetail });
|
||||
|
||||
const [selectedTask, setSelectedTask] = useState(null);
|
||||
const [detailModalVisible, setDetailModalVisible] = useState(false);
|
||||
|
||||
// 历史卡片"复用参数":把任务参数回填到表单,但不立刻生成
|
||||
// 用对象引用变化触发 form 的 useEffect
|
||||
const [prefillSignal, setPrefillSignal] = useState(null);
|
||||
|
||||
// 处理生成提交
|
||||
const handleSubmit = (formData) => {
|
||||
addTask(formData);
|
||||
// 重新生成 / 重试:按原任务参数快照直接再提交一次
|
||||
const handleRegenerate = (task) => {
|
||||
creation.regenerateTask(task);
|
||||
};
|
||||
const handleRetry = (taskId) => {
|
||||
creation.regenerateTask(tasks.find((task) => task.id === taskId));
|
||||
};
|
||||
|
||||
// 处理重新生成(直接再跑一次)
|
||||
const handleRegenerate = (taskData) => {
|
||||
addTask(taskData);
|
||||
};
|
||||
|
||||
// 处理"复用参数"(仅回填,等用户确认后再生成)
|
||||
// "复用参数":回填表单(优先使用服务端参数快照),等用户确认后再生成
|
||||
const handleReuseParams = (task) => {
|
||||
setPrefillSignal({
|
||||
mode: task.mode,
|
||||
prompt: task.prompt,
|
||||
width: task.width,
|
||||
height: task.height,
|
||||
model: task.model,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.negativePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.prefillFromTask(task);
|
||||
};
|
||||
|
||||
// 处理"用作参考图"(生成结果 -> 切到图生图模式 + 自动回填参考图)
|
||||
// 不带 prompt:保留用户当前已输入的提示词,避免被空串覆盖。
|
||||
// 想要旧 prompt 一并回填的,请走"复用参数"。
|
||||
// "用作参考图":结果可复用时以 task:// 引用放入参考图槽,并切到图生图。
|
||||
// 不带 prompt:保留用户当前已输入的提示词;想要旧 prompt 一并回填的,请走"复用参数"。
|
||||
const handleUseAsReference = (task) => {
|
||||
if (!task?.imageUrl) return;
|
||||
setPrefillSignal({
|
||||
mode: 'image-to-image',
|
||||
referenceImageUrl: task.imageUrl,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.applyAsReference(task);
|
||||
};
|
||||
|
||||
// 空状态:用户点示例 prompt 卡片,直接填回 form
|
||||
const handleSamplePrompt = (samplePrompt) => {
|
||||
if (!samplePrompt) return;
|
||||
setPrefillSignal({
|
||||
mode: 'text-to-image',
|
||||
prompt: samplePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.applySamplePrompt(samplePrompt);
|
||||
};
|
||||
|
||||
// 查看详情
|
||||
@@ -109,11 +85,7 @@ const ImageGenerationTab = () => {
|
||||
<div className='h-full min-h-0 flex flex-col md:flex-row gap-4 p-3 sm:p-4 overflow-y-auto md:overflow-hidden'>
|
||||
{/* 左侧:生成参数表单 */}
|
||||
<div className='w-full md:w-[22rem] xl:w-[24rem] md:flex-shrink-0 md:h-full'>
|
||||
<ImageGenerationForm
|
||||
onSubmit={handleSubmit}
|
||||
loading={loading}
|
||||
prefillSignal={prefillSignal}
|
||||
/>
|
||||
<ImageGenerationForm creation={creation} />
|
||||
</div>
|
||||
|
||||
{/* 右侧:任务列表 —— flex-1 只在桌面端生效,移动端按内容高度展开 */}
|
||||
@@ -124,7 +96,7 @@ const ImageGenerationTab = () => {
|
||||
onRefreshUrl={refreshTaskUrl}
|
||||
onViewDetail={handleViewDetail}
|
||||
onDelete={deleteTask}
|
||||
onRetry={retryTask}
|
||||
onRetry={handleRetry}
|
||||
onRegenerate={handleRegenerate}
|
||||
onReuseParams={handleReuseParams}
|
||||
onUseAsReference={handleUseAsReference}
|
||||
|
||||
@@ -54,7 +54,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { IllustrationNoContent } from '../../../../components/common/illustrations';
|
||||
import { showSuccess, showError } from '../../../../helpers';
|
||||
import { showSuccess, showError, renderQuota } from '../../../../helpers';
|
||||
import './ImageTaskList.css';
|
||||
import ImageCompareModal from './ImageCompareModal';
|
||||
|
||||
@@ -87,7 +87,7 @@ const ImageTaskList = ({
|
||||
onUseAsReference,
|
||||
onSamplePrompt,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
// ---------- 用户偏好(持久化)----------
|
||||
const [prefs, setPrefs] = useState(() => {
|
||||
@@ -378,9 +378,11 @@ const ImageTaskList = ({
|
||||
const now = new Date();
|
||||
const diff = now - date;
|
||||
if (diff < 60000) return t('刚刚');
|
||||
if (diff < 3600000) return `${Math.floor(diff / 60000)} ${t('分钟前')}`;
|
||||
if (diff < 86400000) return `${Math.floor(diff / 3600000)} ${t('小时前')}`;
|
||||
return date.toLocaleString('zh-CN', {
|
||||
if (diff < 3600000)
|
||||
return t('{{n}} 分钟前', { n: Math.floor(diff / 60000) });
|
||||
if (diff < 86400000)
|
||||
return t('{{n}} 小时前', { n: Math.floor(diff / 3600000) });
|
||||
return date.toLocaleString(i18n.language, {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
@@ -469,19 +471,8 @@ const ImageTaskList = ({
|
||||
showError(t('无法重新生成:缺少提示词'));
|
||||
return;
|
||||
}
|
||||
if (onRegenerate) {
|
||||
onRegenerate({
|
||||
prompt: task.prompt,
|
||||
width: task.width || 1024,
|
||||
height: task.height || 1024,
|
||||
model: task.model,
|
||||
mode: task.mode,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.negativePrompt,
|
||||
});
|
||||
showSuccess(t('已创建新的生成任务'));
|
||||
}
|
||||
// 按原任务参数快照再提交一次(结果提示由提交流程给出)
|
||||
if (onRegenerate) onRegenerate(task);
|
||||
};
|
||||
|
||||
// 选择 —— 用 updater 保证状态新鲜(快速连点不丢),
|
||||
@@ -530,6 +521,8 @@ const ImageTaskList = ({
|
||||
JSON.stringify({
|
||||
id: task.id,
|
||||
imageUrl: task.imageUrl,
|
||||
// 结果可按 task:// 引用复用时,表单不再下载图片
|
||||
reusableAsInput: task.reusableAsInput === true,
|
||||
prompt: task.prompt || '',
|
||||
}),
|
||||
);
|
||||
@@ -1285,6 +1278,15 @@ const ImageTaskList = ({
|
||||
</Popover>
|
||||
)}
|
||||
|
||||
{/* 失败退款:按任务实际退还额度展示(不写死"不扣费") */}
|
||||
{isFailed && task.refundedQuota > 0 && (
|
||||
<div className='text-[10px] text-gray-500 dark:text-gray-400 leading-snug mb-1.5 tabular-nums'>
|
||||
{t('已退还 {{amount}}', {
|
||||
amount: renderQuota(task.refundedQuota),
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 操作按钮 */}
|
||||
{density !== 'grid' && (
|
||||
<div className='flex gap-1 mt-auto pt-1 border-t border-gray-100 dark:border-neutral-800'>
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 体验中心视频页输入面板(WP A1-12)。
|
||||
* 配色全部从主题 token 派生(frontend-design skill 铁律一),禁止裸色值。
|
||||
*/
|
||||
.video-input-panel {
|
||||
--vip-ink: var(--text-primary);
|
||||
--vip-muted: var(--text-secondary);
|
||||
--vip-line: var(--border-subtle);
|
||||
--vip-surface: var(--surface-card);
|
||||
--vip-accent: var(--ui-color-primary);
|
||||
--vip-tint: color-mix(in srgb, var(--ui-color-primary) 10%, transparent);
|
||||
--vip-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
|
||||
--vip-danger: var(--ui-color-danger);
|
||||
--vip-warning: var(--ui-color-warning);
|
||||
--vip-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
|
||||
|
||||
position: relative;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.video-input-panel button:focus-visible,
|
||||
.video-input-panel [role='button']:focus-visible {
|
||||
outline: 2px solid var(--vip-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.vip-collapse-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.vip-collapse-btn {
|
||||
color: var(--vip-accent) !important;
|
||||
}
|
||||
|
||||
.vip-expand-fab {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.vip-expand-fab .ant-btn {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
color: var(--ui-color-primary);
|
||||
}
|
||||
|
||||
.vip-card {
|
||||
margin-bottom: 12px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--vip-line);
|
||||
border-radius: 12px;
|
||||
background: var(--vip-surface);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.vip-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--vip-ink);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.vip-card-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-tint);
|
||||
color: var(--vip-accent);
|
||||
}
|
||||
|
||||
.vip-card-extra {
|
||||
margin-left: auto;
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.vip-muted {
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.vip-model-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.vip-model-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vip-model-id {
|
||||
overflow: hidden;
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vip-model-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 16px;
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-fill);
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.vip-model-meta strong {
|
||||
color: var(--vip-ink);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.vip-model-desc {
|
||||
flex-basis: 100%;
|
||||
color: var(--vip-muted);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.vip-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.vip-state-title {
|
||||
color: var(--vip-ink);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.vip-state.is-error .vip-state-title {
|
||||
color: var(--vip-danger);
|
||||
}
|
||||
|
||||
.vip-mode-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.vip-slots {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.vip-slot-note {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.vip-portrait-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.vip-template-preview {
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-fill);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.vip-counter {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.vip-advanced {
|
||||
border: 1px solid var(--vip-line);
|
||||
border-radius: 12px;
|
||||
background: var(--vip-surface);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.vip-advanced .ant-collapse-header {
|
||||
margin: 0;
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.vip-advanced .ant-collapse-content-box {
|
||||
padding: 4px 16px 16px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,9 +39,12 @@ import {
|
||||
HelpCircle,
|
||||
X,
|
||||
Loader2,
|
||||
Wallet,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { showError, showSuccess } from '../../../../../helpers';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { formatQuoteAmount } from '../../../../../hooks/creation/useCreationQuote';
|
||||
import {
|
||||
canCancelVideoTask,
|
||||
canRegenerateVideoTask,
|
||||
@@ -52,6 +55,21 @@ import './VideoPreviewPanel.css';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
|
||||
// 估价 budget_source → 预算层级名(i18n key);org_budget 实际值为 org_budget:<subject_type>
|
||||
const BUDGET_SOURCE_LABELS = {
|
||||
org_budget: '部门 / 项目预算',
|
||||
token: '令牌额度',
|
||||
org_member: '成员额度',
|
||||
org_gift: '企业赠送额度',
|
||||
org: '企业额度',
|
||||
membership: '会员额度',
|
||||
gift: '赠送余额',
|
||||
user: '账户余额',
|
||||
};
|
||||
|
||||
const budgetSourceLabel = (source) =>
|
||||
BUDGET_SOURCE_LABELS[String(source || '').split(':')[0]] || '';
|
||||
|
||||
const VideoPreviewPanel = ({
|
||||
formData,
|
||||
generating,
|
||||
@@ -62,8 +80,15 @@ const VideoPreviewPanel = ({
|
||||
selectedTaskForPlay, // 新增:从任务列表选择的任务
|
||||
onRegenerate, // 新增:再生成回调
|
||||
onClearSelectedTask, // 新增:清除选中任务的回调(关闭视频播放)
|
||||
submitBlock = '', // 不能提交的原因(为空表示可提交)
|
||||
submitting = false,
|
||||
quote = null,
|
||||
quoteLoading = false,
|
||||
quoteFailed = false,
|
||||
estSeconds = 0,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
|
||||
// 监听窗口大小变化
|
||||
@@ -201,12 +226,35 @@ const VideoPreviewPanel = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 判断按钮是否禁用
|
||||
const isButtonDisabled =
|
||||
(!formData.prompt && !formData.selectedTemplate) ||
|
||||
!selectedModel ||
|
||||
(typeof selectedModel === 'object' && selectedModel.level_locked) ||
|
||||
(formData.mode === 'image2video' && !formData.image);
|
||||
// 判断按钮是否禁用(原因由 useVideoGeneration 按 schema 计算)
|
||||
const isButtonDisabled = Boolean(submitBlock);
|
||||
// 余额 / 预算不足:按钮变为"去充值"(估价失败时不阻止提交)
|
||||
const needTopUp = !isButtonDisabled && quote?.balance_enough === false;
|
||||
|
||||
// 估价文案:"预计 ¥x · 约 N 秒 · 失败自动退还"
|
||||
const renderQuoteText = () => {
|
||||
const parts = [];
|
||||
const item = quote?.items?.[0];
|
||||
const amount =
|
||||
item && !item.error
|
||||
? formatQuoteAmount(item.display_amount, item.currency)
|
||||
: '';
|
||||
if (quoteFailed || (quote && !amount)) {
|
||||
parts.push(t('价格以实际扣费为准'));
|
||||
} else if (amount) {
|
||||
parts.push(
|
||||
item.approximate
|
||||
? t('预计约 {{amount}}', { amount })
|
||||
: t('预计 {{amount}}', { amount }),
|
||||
);
|
||||
} else if (quoteLoading) {
|
||||
parts.push(t('正在估价...'));
|
||||
}
|
||||
if (estSeconds > 0) parts.push(t('约 {{n}} 秒', { n: estSeconds }));
|
||||
if (parts.length === 0) return null;
|
||||
parts.push(t('失败自动退还'));
|
||||
return parts.join(' · ');
|
||||
};
|
||||
|
||||
// 渲染顶部操作栏(始终显示)
|
||||
const renderTopBar = () => {
|
||||
@@ -234,52 +282,68 @@ const VideoPreviewPanel = ({
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Play size={16} fill='currentColor' />}
|
||||
onClick={isButtonDisabled ? undefined : handleGenerate}
|
||||
disabled={isButtonDisabled || generating}
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
background:
|
||||
isButtonDisabled || generating
|
||||
? undefined
|
||||
: 'linear-gradient(135deg, #1890ff 0%, #0050b3 100%)',
|
||||
border: 'none',
|
||||
}}
|
||||
>
|
||||
{generating
|
||||
? t('生成中...')
|
||||
: windowWidth > 768
|
||||
? t('开始生成')
|
||||
: t('生成')}
|
||||
</Button>
|
||||
{needTopUp ? (
|
||||
<Button
|
||||
type='warning'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Wallet size={16} />}
|
||||
onClick={() => navigate('/console/topup')}
|
||||
style={{ fontWeight: 600 }}
|
||||
>
|
||||
{t('去充值')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Play size={16} fill='currentColor' />}
|
||||
onClick={isButtonDisabled ? undefined : handleGenerate}
|
||||
disabled={isButtonDisabled || submitting}
|
||||
loading={submitting}
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
background:
|
||||
isButtonDisabled || submitting
|
||||
? undefined
|
||||
: 'linear-gradient(135deg, var(--ui-color-primary) 0%, var(--ui-color-primary-active, var(--ui-color-primary)) 100%)',
|
||||
border: 'none',
|
||||
}}
|
||||
>
|
||||
{submitting
|
||||
? t('提交中...')
|
||||
: windowWidth > 768
|
||||
? t('开始生成')
|
||||
: t('生成')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 估价 / 余额不足说明 */}
|
||||
{!isButtonDisabled && (
|
||||
<Text
|
||||
type={needTopUp ? 'warning' : 'tertiary'}
|
||||
style={{
|
||||
fontSize: '12px',
|
||||
fontVariantNumeric: 'tabular-nums',
|
||||
minWidth: 0,
|
||||
}}
|
||||
aria-live='polite'
|
||||
>
|
||||
{needTopUp
|
||||
? budgetSourceLabel(quote?.budget_source)
|
||||
? t('{{source}}不足,请充值后再生成', {
|
||||
source: t(budgetSourceLabel(quote.budget_source)),
|
||||
})
|
||||
: t('余额或预算不足,请充值后再生成')
|
||||
: renderQuoteText()}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{/* 禁用提示 */}
|
||||
{isButtonDisabled && !generating && (
|
||||
<Text type='tertiary' style={{ fontSize: '12px' }}>
|
||||
{!selectedModel && t('请选择模型')}
|
||||
{selectedModel &&
|
||||
typeof selectedModel === 'object' &&
|
||||
selectedModel.level_locked &&
|
||||
t('当前等级无权调用此模型')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
!formData.prompt &&
|
||||
!formData.selectedTemplate &&
|
||||
t('请输入提示词或选择模板')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
(formData.prompt || formData.selectedTemplate) &&
|
||||
formData.mode === 'image2video' &&
|
||||
!formData.image &&
|
||||
t('请上传图片')}
|
||||
{isButtonDisabled && !submitting && (
|
||||
<Text type='tertiary' style={{ fontSize: '12px' }} role='note'>
|
||||
{submitBlock}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
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, useEffect } from 'react';
|
||||
import {
|
||||
Modal,
|
||||
Form,
|
||||
Select,
|
||||
Input,
|
||||
InputNumber,
|
||||
Switch,
|
||||
Space,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
import ModelSelector from '../../../../../components/common/ModelSelector';
|
||||
import { MODEL_CATEGORY } from '../../../../../constants';
|
||||
import { buildVideoRegenerateRequest } from '../../../../../helpers/videoTask';
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Text } = Typography;
|
||||
|
||||
const VideoRegenerateModal = ({ visible, onCancel, onConfirm, task }) => {
|
||||
const isNarrow = useIsMobile();
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState({
|
||||
mode: 'text2video',
|
||||
prompt: '',
|
||||
negative_prompt: '',
|
||||
resolution: '1080P',
|
||||
duration: 5,
|
||||
fps: 30,
|
||||
ratio: '16:9',
|
||||
audio: false,
|
||||
seed: -1,
|
||||
prompt_extend: false,
|
||||
watermark: false,
|
||||
image: '',
|
||||
});
|
||||
const [selectedModel, setSelectedModel] = useState('');
|
||||
|
||||
// 从任务数据中提取参数
|
||||
useEffect(() => {
|
||||
if (task && visible) {
|
||||
const taskData = task.request || {};
|
||||
const mode = taskData.mode || 'text2video';
|
||||
const prompt = taskData.prompt || '';
|
||||
const negativePrompt = taskData.negative_prompt || '';
|
||||
const resolution = taskData.resolution || '1080P';
|
||||
const duration = taskData.duration || 5;
|
||||
const fps = taskData.fps || 30;
|
||||
const ratio = taskData.ratio || '16:9';
|
||||
const audio = taskData.audio === true;
|
||||
const seed = taskData.seed ?? -1;
|
||||
const promptExtend = taskData.prompt_extend === true;
|
||||
const watermark = taskData.watermark === true;
|
||||
const image = taskData.image || '';
|
||||
const model = taskData.model || '';
|
||||
|
||||
setFormData({
|
||||
mode,
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
resolution,
|
||||
duration,
|
||||
fps,
|
||||
ratio,
|
||||
audio,
|
||||
seed,
|
||||
prompt_extend: promptExtend,
|
||||
watermark,
|
||||
image,
|
||||
});
|
||||
|
||||
setSelectedModel(model);
|
||||
}
|
||||
}, [task, visible]);
|
||||
|
||||
// 处理表单提交
|
||||
const handleSubmit = () => {
|
||||
if (!selectedModel || typeof selectedModel !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建请求数据
|
||||
onConfirm(buildVideoRegenerateRequest(formData, selectedModel));
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('再生成视频')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
okText={t('确认生成')}
|
||||
cancelText={t('取消')}
|
||||
width={700}
|
||||
bodyStyle={{
|
||||
maxHeight: '70vh',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
// 窄屏改为标签在上:labelWidth=120 在 ~294px 的弹窗体里要吃掉 41%,
|
||||
// 剩给控件的宽度放不下 seed 输入框和它的说明文案
|
||||
labelPosition={isNarrow ? 'top' : 'left'}
|
||||
labelAlign='right'
|
||||
labelWidth={isNarrow ? undefined : 120}
|
||||
>
|
||||
{/* 生成模式 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('生成模式')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.mode}
|
||||
onChange={(value) => {
|
||||
setFormData({ ...formData, mode: value });
|
||||
setSelectedModel('');
|
||||
}}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='text2video'>{t('文生视频')}</Select.Option>
|
||||
<Select.Option value='image2video'>{t('图生视频')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 模型选择 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('选择模型')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<ModelSelector
|
||||
key={formData.mode}
|
||||
category={
|
||||
formData.mode === 'text2video'
|
||||
? MODEL_CATEGORY.TEXT_TO_VIDEO
|
||||
: MODEL_CATEGORY.IMAGE_TO_VIDEO
|
||||
}
|
||||
value={
|
||||
selectedModel?.id || selectedModel?.model_name || selectedModel
|
||||
}
|
||||
onChange={setSelectedModel}
|
||||
placeholder={t('请选择模型')}
|
||||
autoSelectFirst={false}
|
||||
onModelsLoaded={(models) => {
|
||||
if (typeof selectedModel !== 'string' || !selectedModel) return;
|
||||
const match = models.find(
|
||||
(model) => model.model_name === selectedModel,
|
||||
);
|
||||
setSelectedModel(match || '');
|
||||
}}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 提示词 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.prompt}
|
||||
onChange={(value) => setFormData({ ...formData, prompt: value })}
|
||||
placeholder={t('描述你想生成的视频内容')}
|
||||
rows={3}
|
||||
maxLength={2000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 反向提示词 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('反向提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.negative_prompt}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, negative_prompt: value })
|
||||
}
|
||||
placeholder={t('描述不想出现的内容')}
|
||||
rows={2}
|
||||
maxLength={1000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 分辨率 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('分辨率')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.resolution}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, resolution: value })
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='480P'>480P (832*480)</Select.Option>
|
||||
<Select.Option value='720P'>720P (1280*720)</Select.Option>
|
||||
<Select.Option value='1080P'>1080P (1920*1080)</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 时长 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('视频时长')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<InputNumber
|
||||
value={formData.duration}
|
||||
onChange={(value) => setFormData({ ...formData, duration: value })}
|
||||
min={3}
|
||||
max={10}
|
||||
suffix={t('秒')}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 宽高比 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('宽高比')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.ratio}
|
||||
onChange={(value) => setFormData({ ...formData, ratio: value })}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='16:9'>{t('16:9 (横屏)')}</Select.Option>
|
||||
<Select.Option value='9:16'>{t('9:16 (竖屏)')}</Select.Option>
|
||||
<Select.Option value='1:1'>{t('1:1 (方形)')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 高级选项 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('高级选项')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Space vertical align='start' style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.audio}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, audio: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('生成音频')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.prompt_extend}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, prompt_extend: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('提示词扩展')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<InputNumber
|
||||
value={formData.seed}
|
||||
onChange={(value) => setFormData({ ...formData, seed: value })}
|
||||
placeholder={t('随机种子(可选)')}
|
||||
min={0}
|
||||
style={{ width: '100%', maxWidth: 200 }}
|
||||
/>
|
||||
<Text type='tertiary'>{t('固定种子可复现结果')}</Text>
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Input>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoRegenerateModal;
|
||||
@@ -17,20 +17,23 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import VideoInputPanel from './Video/VideoInputPanel';
|
||||
import VideoPreviewPanel from './Video/VideoPreviewPanel';
|
||||
import VideoTaskQueue from './Video/VideoTaskQueue';
|
||||
import VideoRegenerateModal from './Video/VideoRegenerateModal';
|
||||
import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration';
|
||||
import { showInfo } from '../../../../helpers';
|
||||
|
||||
const VideoGenerationTab = () => {
|
||||
const { t } = useTranslation();
|
||||
const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(false);
|
||||
const [taskQueueVisible, setTaskQueueVisible] = useState(false);
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
const [selectedTaskForPlay, setSelectedTaskForPlay] = useState(null);
|
||||
const [regenerateModalVisible, setRegenerateModalVisible] = useState(false);
|
||||
const [taskToRegenerate, setTaskToRegenerate] = useState(null);
|
||||
// 输入面板容器:再生成回填后滚动到面板顶部
|
||||
const inputPanelRef = useRef(null);
|
||||
const inputScrollRef = useRef(null);
|
||||
|
||||
// 监听窗口大小变化
|
||||
useEffect(() => {
|
||||
@@ -42,28 +45,32 @@ const VideoGenerationTab = () => {
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
const creation = useVideoGeneration();
|
||||
const {
|
||||
// 表单数据
|
||||
formData,
|
||||
setFormData,
|
||||
// 模型相关
|
||||
selectedModel,
|
||||
setSelectedModel,
|
||||
modelInfo,
|
||||
// 生成相关
|
||||
generating,
|
||||
currentTask,
|
||||
handleGenerate,
|
||||
submitVideo,
|
||||
handleCancel,
|
||||
submitBlock,
|
||||
submitting,
|
||||
quote,
|
||||
quoteLoading,
|
||||
quoteFailed,
|
||||
estSeconds,
|
||||
// 任务列表
|
||||
tasks,
|
||||
refreshTasks,
|
||||
deleteTask,
|
||||
getRegenerationTask,
|
||||
prefillFromTask,
|
||||
downloadTask,
|
||||
getTaskVideoUrl,
|
||||
} = useVideoGeneration();
|
||||
} = creation;
|
||||
|
||||
// 处理任务列表的播放按钮
|
||||
const handlePlayTask = async (task) => {
|
||||
@@ -98,20 +105,21 @@ const VideoGenerationTab = () => {
|
||||
setSelectedTaskForPlay(null);
|
||||
};
|
||||
|
||||
// 处理再生成按钮
|
||||
// 处理再生成按钮:用原任务参数回填输入面板,由用户确认后再点击生成
|
||||
const handleRegenerate = async (task) => {
|
||||
const detail = await getRegenerationTask(task.task_id);
|
||||
if (!detail) return;
|
||||
setTaskToRegenerate(detail);
|
||||
setRegenerateModalVisible(true);
|
||||
};
|
||||
|
||||
// 确认再生成
|
||||
const handleRegenerateConfirm = async (requestData) => {
|
||||
const submitted = await submitVideo(requestData, requestData.model);
|
||||
if (submitted) {
|
||||
setRegenerateModalVisible(false);
|
||||
}
|
||||
if (!detail || !prefillFromTask(detail)) return;
|
||||
setLeftPanelCollapsed(false);
|
||||
setTaskQueueVisible(false);
|
||||
showInfo(t('已回填原参数,确认后点击生成'));
|
||||
// 等面板展开渲染后再滚动
|
||||
requestAnimationFrame(() => {
|
||||
inputScrollRef.current?.scrollTo?.({ top: 0, behavior: 'smooth' });
|
||||
inputPanelRef.current?.scrollIntoView?.({
|
||||
behavior: 'smooth',
|
||||
block: 'start',
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 响应式布局配置 - 两列布局(左侧配置区 + 右侧预览区)
|
||||
@@ -191,6 +199,7 @@ const VideoGenerationTab = () => {
|
||||
>
|
||||
{/* 左侧:输入区域(区域1) */}
|
||||
<div
|
||||
ref={inputPanelRef}
|
||||
style={{
|
||||
width:
|
||||
layoutConfig.direction === 'row'
|
||||
@@ -219,6 +228,7 @@ const VideoGenerationTab = () => {
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={inputScrollRef}
|
||||
className='app-scrollbar'
|
||||
style={{
|
||||
height: '100%',
|
||||
@@ -227,14 +237,10 @@ const VideoGenerationTab = () => {
|
||||
}}
|
||||
>
|
||||
<VideoInputPanel
|
||||
formData={formData}
|
||||
setFormData={setFormData}
|
||||
creation={creation}
|
||||
onCollapse={() => setLeftPanelCollapsed(!leftPanelCollapsed)}
|
||||
collapsed={leftPanelCollapsed}
|
||||
collapsible={layoutConfig.direction === 'row'}
|
||||
selectedModel={selectedModel}
|
||||
setSelectedModel={setSelectedModel}
|
||||
modelInfo={modelInfo}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -264,6 +270,12 @@ const VideoGenerationTab = () => {
|
||||
onGenerate={handleGenerate}
|
||||
onCancel={handleCancel}
|
||||
selectedModel={selectedModel}
|
||||
submitBlock={submitBlock}
|
||||
submitting={submitting}
|
||||
quote={quote}
|
||||
quoteLoading={quoteLoading}
|
||||
quoteFailed={quoteFailed}
|
||||
estSeconds={estSeconds}
|
||||
selectedTaskForPlay={selectedTaskForPlay}
|
||||
onRegenerate={handleRegenerate}
|
||||
onClearSelectedTask={handleClearSelectedTask}
|
||||
@@ -293,14 +305,6 @@ const VideoGenerationTab = () => {
|
||||
onRegenerate={handleRegenerate}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 再生成弹窗 */}
|
||||
<VideoRegenerateModal
|
||||
visible={regenerateModalVisible}
|
||||
onCancel={() => setRegenerateModalVisible(false)}
|
||||
onConfirm={handleRegenerateConfirm}
|
||||
task={taskToRegenerate}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,8 +30,13 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../../hooks/common/useSidebarCollapsed';
|
||||
import { useExperienceModules } from '../useExperienceModules';
|
||||
import { badgeText } from '../../../hooks/creation/creationWatch';
|
||||
|
||||
const ExperienceSidebar = () => {
|
||||
/**
|
||||
* @param {{ unread?: { image: number, video: number } }} props
|
||||
* unread:新创作台中用户不在该页时完成的作品数(WP C-4 未读角标)
|
||||
*/
|
||||
const ExperienceSidebar = ({ unread }) => {
|
||||
const { t } = useTranslation();
|
||||
const [collapsed, toggleCollapsed] = useSidebarCollapsed();
|
||||
const [selectedKeys, setSelectedKeys] = useState([]);
|
||||
@@ -55,6 +60,7 @@ const ExperienceSidebar = () => {
|
||||
configKey: 'imageGeneration',
|
||||
to: '/experience-center/image-generation',
|
||||
icon: Image,
|
||||
unreadKey: 'image',
|
||||
},
|
||||
{
|
||||
text: t('视频生成'),
|
||||
@@ -62,6 +68,7 @@ const ExperienceSidebar = () => {
|
||||
configKey: 'videoGeneration',
|
||||
to: '/experience-center/video-generation',
|
||||
icon: Video,
|
||||
unreadKey: 'video',
|
||||
},
|
||||
],
|
||||
[t],
|
||||
@@ -121,11 +128,19 @@ const ExperienceSidebar = () => {
|
||||
{navItems.map((item) => {
|
||||
const isSelected = selectedKeys.includes(item.itemKey);
|
||||
const IconComponent = item.icon;
|
||||
const unreadCount =
|
||||
item.unreadKey && !isSelected ? unread?.[item.unreadKey] || 0 : 0;
|
||||
const unreadLabel = unreadCount
|
||||
? t('{{n}} 个新作品', { n: unreadCount })
|
||||
: '';
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={item.to}
|
||||
aria-label={
|
||||
unreadLabel ? `${item.text}(${unreadLabel})` : undefined
|
||||
}
|
||||
onClick={() => setSelectedKeys([item.itemKey])}
|
||||
className={`
|
||||
group relative flex items-center gap-3 rounded-xl transition-all duration-200
|
||||
@@ -162,6 +177,14 @@ const ExperienceSidebar = () => {
|
||||
: 'text-gray-500 dark:text-gray-400 group-hover:text-brand-deep dark:group-hover:text-brand-from transition-colors'
|
||||
}
|
||||
/>
|
||||
{unreadCount > 0 && collapsed ? (
|
||||
<span
|
||||
className='exp-unread-badge absolute -top-1.5 -right-1.5'
|
||||
aria-hidden='true'
|
||||
>
|
||||
{badgeText(unreadCount)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* 文字 */}
|
||||
@@ -184,6 +207,11 @@ const ExperienceSidebar = () => {
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
{unreadCount > 0 ? (
|
||||
<span className='exp-unread-badge' aria-hidden='true'>
|
||||
{badgeText(unreadCount)}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
)}
|
||||
|
||||
|
||||
@@ -17,10 +17,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import ImageGenerationTab from './AICreation/ImageGenerationTab';
|
||||
import CreationStudio from '../../../components/creation/CreationStudio';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
import { isCreationStudioEnabled } from '../../../helpers/creationStudio';
|
||||
|
||||
const ImageGeneration = () => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
// 灰度开关开启时使用新创作台,关闭时保持旧页面不变
|
||||
if (isCreationStudioEnabled(statusState?.status)) {
|
||||
return <CreationStudio key='image' kind='image' />;
|
||||
}
|
||||
return (
|
||||
<div className='h-full min-h-0'>
|
||||
<ImageGenerationTab />
|
||||
|
||||
@@ -17,13 +17,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Video, Sparkles, Clapperboard, Film, Play } from 'lucide-react';
|
||||
import VideoGenerationTab from './AICreation/VideoGenerationTab';
|
||||
import CreationStudio from '../../../components/creation/CreationStudio';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
import { isCreationStudioEnabled } from '../../../helpers/creationStudio';
|
||||
|
||||
const VideoGeneration = () => {
|
||||
const { t } = useTranslation();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
|
||||
// 灰度开关开启时使用新创作台,关闭时保持旧页面不变
|
||||
if (isCreationStudioEnabled(statusState?.status)) {
|
||||
return <CreationStudio key='video' kind='video' />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='h-full flex flex-col p-6 relative overflow-hidden'>
|
||||
|
||||
@@ -17,10 +17,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import { Navigate, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { BrainCircuit, Image, Video } from 'lucide-react';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { useMarquee } from '../../hooks/common/useMarquee';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import TextModel from './components/TextModel';
|
||||
@@ -32,13 +33,19 @@ import CloudBrain from '../CloudBrain';
|
||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import { DEFAULT_LOGIN_REDIRECT } from '../../helpers/data';
|
||||
import { isCreationStudioEnabled } from '../../helpers/creationStudio';
|
||||
import { badgeText } from '../../hooks/creation/creationWatch';
|
||||
import {
|
||||
useCreationUnread,
|
||||
useCreationWatchPoller,
|
||||
} from '../../hooks/creation/useCreationWatch';
|
||||
import {
|
||||
EXPERIENCE_MODULES,
|
||||
useExperienceModules,
|
||||
} from './useExperienceModules';
|
||||
|
||||
// 移动端底部导航组件
|
||||
const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
// 移动端底部导航组件(exp-mobile-bottom-nav:新创作台展开态期间由 creation-dock.css 隐藏)
|
||||
const MobileBottomNav = ({ currentPath, navigate, isAvailable, unread }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 与桌面侧边栏共用 useExperienceModules 判定,运营关闭的子页两端一致隐藏
|
||||
@@ -59,6 +66,7 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
label: t('图片'),
|
||||
path: '/experience-center/image-generation',
|
||||
gradient: 'from-pink-500 to-rose-600',
|
||||
unread: unread?.image || 0,
|
||||
},
|
||||
{
|
||||
key: 'video',
|
||||
@@ -67,11 +75,12 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
label: t('视频'),
|
||||
path: '/experience-center/video-generation',
|
||||
gradient: 'from-cyan-500 to-blue-600',
|
||||
unread: unread?.video || 0,
|
||||
},
|
||||
].filter((item) => isAvailable(item.configKey));
|
||||
|
||||
return (
|
||||
<div className='md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
|
||||
<div className='exp-mobile-bottom-nav md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
|
||||
<div className='flex items-center justify-around h-14'>
|
||||
{navItems.map((item) => {
|
||||
const isActive = currentPath.includes(item.key);
|
||||
@@ -109,6 +118,14 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
{item.unread > 0 && !isActive ? (
|
||||
<span
|
||||
className='exp-unread-badge absolute top-1 right-[22%]'
|
||||
aria-label={t('{{n}} 个新作品', { n: item.unread })}
|
||||
>
|
||||
{badgeText(item.unread)}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
@@ -120,10 +137,15 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
const ExperienceCenter = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const { ready, orgOnly, isAvailable, defaultPath } = useExperienceModules();
|
||||
|
||||
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
||||
const { visible: hasMarquee } = useMarquee();
|
||||
// 新创作台:用户在体验中心其他页面时轻量轮询已提交的任务,完成后显示未读角标(WP C-4)
|
||||
const creationStudioEnabled = isCreationStudioEnabled(statusState?.status);
|
||||
useCreationWatchPoller(creationStudioEnabled);
|
||||
const unread = useCreationUnread(creationStudioEnabled);
|
||||
|
||||
// 默认落地:进第一个对当前用户可用的子页;一个都没有时,org_only 用户回企业
|
||||
// 空间,其余用户去默认登录落地页。兜底目标都不在体验中心内,不会重定向循环。
|
||||
@@ -162,13 +184,17 @@ const ExperienceCenter = () => {
|
||||
return <Navigate to='/experience-center' replace />;
|
||||
}
|
||||
|
||||
// 新创作台:视口高度用 dvh,微信 H5 / 移动端键盘弹起时底部创作台与生成按钮保持可见
|
||||
const dynamicViewport =
|
||||
(isVideoGeneration || isImageGeneration) && creationStudioEnabled;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col md:flex-row h-screen bg-[var(--surface-bg-base)] overflow-hidden ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
|
||||
className={`flex flex-col md:flex-row ${dynamicViewport ? 'h-screen supports-[height:100dvh]:h-dvh' : 'h-screen'} bg-[var(--surface-bg-base)] overflow-hidden ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
|
||||
>
|
||||
{/* Sidebar - 桌面端 */}
|
||||
<div className='hidden md:block'>
|
||||
<ExperienceSidebar />
|
||||
<ExperienceSidebar unread={unread} />
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
@@ -210,6 +236,7 @@ const ExperienceCenter = () => {
|
||||
currentPath={location.pathname}
|
||||
navigate={navigate}
|
||||
isAvailable={isAvailable}
|
||||
unread={unread}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -256,7 +256,8 @@ export const ExperienceCenterAuditPanel = () => {
|
||||
content: [
|
||||
{
|
||||
key: (d) => d?.type,
|
||||
value: (d) => `${(d?.value || 0).toLocaleString()} ${t('次')}`,
|
||||
value: (d) =>
|
||||
t('{{n}} 次', { n: (d?.value || 0).toLocaleString(), count: d?.value || 0 }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -283,7 +284,7 @@ export const ExperienceCenterAuditPanel = () => {
|
||||
title: t('用户'),
|
||||
dataIndex: 'username',
|
||||
width: 160,
|
||||
render: (v, row) => v || `(${t('用户')} ${row.user_id})`,
|
||||
render: (v, row) => v || `(${t('用户 {{id}}', { id: row.user_id })})`,
|
||||
},
|
||||
{
|
||||
title: t('事件'),
|
||||
@@ -334,7 +335,7 @@ export const ExperienceCenterAuditPanel = () => {
|
||||
const filename = `experience_center_upload_audit_${new Date().toISOString().slice(0, 10)}.csv`;
|
||||
exportToCsv(cols, recent.items, filename);
|
||||
Toast.success({
|
||||
content: t('已导出 {{n}} 条', { n: recent.items.length }),
|
||||
content: t('已导出 {{n}} 条', { n: recent.items.length, count: recent.items.length }),
|
||||
duration: 2,
|
||||
});
|
||||
}, [recent.items, t]);
|
||||
@@ -345,7 +346,7 @@ export const ExperienceCenterAuditPanel = () => {
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'username',
|
||||
render: (v, row) => v || `(${t('用户')} ${row.user_id})`,
|
||||
render: (v, row) => v || `(${t('用户 {{id}}', { id: row.user_id })})`,
|
||||
},
|
||||
{
|
||||
title: t('失败次数'),
|
||||
|
||||
@@ -127,13 +127,13 @@ const Home = () => {
|
||||
}
|
||||
} else {
|
||||
showError(message);
|
||||
setHomePageContent('加载首页内容失败...');
|
||||
setHomePageContent(t('加载首页内容失败...'));
|
||||
setIframeLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load home page content:', error);
|
||||
showError(t('加载首页内容失败'));
|
||||
setHomePageContent('加载首页内容失败...');
|
||||
setHomePageContent(t('加载首页内容失败...'));
|
||||
setIframeLoading(false);
|
||||
} finally {
|
||||
setHomePageContentLoaded(true);
|
||||
|
||||
@@ -18,7 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../helpers/clipboard';
|
||||
import React, { useState, useCallback, useEffect } from 'react';
|
||||
import React, { useState, useCallback, useEffect, useContext } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Card,
|
||||
@@ -58,6 +59,8 @@ import {
|
||||
buildImageRequestBody,
|
||||
} from '../../constants/imageModelCapabilities';
|
||||
import { API, showError, showSuccess } from '../../helpers';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { isCreationStudioEnabled } from '../../helpers/creationStudio';
|
||||
|
||||
// 定义图片尺寸选项
|
||||
const IMAGE_SIZES = [
|
||||
@@ -549,7 +552,10 @@ const ImageGeneration = () => {
|
||||
<Select
|
||||
value={quality}
|
||||
onChange={setQuality}
|
||||
options={IMAGE_QUALITY}
|
||||
options={IMAGE_QUALITY.map((o) => ({
|
||||
...o,
|
||||
label: t(o.label),
|
||||
}))}
|
||||
disabled={
|
||||
!currentCapability ||
|
||||
!currentCapability.sendQuality
|
||||
@@ -738,7 +744,7 @@ const ImageGeneration = () => {
|
||||
width: 100,
|
||||
render: (status) => (
|
||||
<Tag color={TASK_STATUS_COLORS[status] || 'grey'}>
|
||||
{TASK_STATUS_NAMES[status] || status}
|
||||
{t(TASK_STATUS_NAMES[status] || status)}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
@@ -846,8 +852,10 @@ const ImageGeneration = () => {
|
||||
TASK_STATUS_COLORS[selectedTask.status] || 'grey'
|
||||
}
|
||||
>
|
||||
{TASK_STATUS_NAMES[selectedTask.status] ||
|
||||
selectedTask.status}
|
||||
{t(
|
||||
TASK_STATUS_NAMES[selectedTask.status] ||
|
||||
selectedTask.status,
|
||||
)}
|
||||
</Tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1022,4 +1030,14 @@ const ImageGeneration = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageGeneration;
|
||||
// 新版创作台开启时独立图像页迁移到体验中心(WP D-1);关闭时保持旧页面。
|
||||
// 注:本页目前未在 App.jsx 注册路由,若重新挂载也不会绕过新创作台。
|
||||
const ImageGenerationPage = () => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
if (isCreationStudioEnabled(statusState?.status)) {
|
||||
return <Navigate to='/experience-center/image-generation' replace />;
|
||||
}
|
||||
return <ImageGeneration />;
|
||||
};
|
||||
|
||||
export default ImageGenerationPage;
|
||||
|
||||
@@ -54,7 +54,7 @@ import {
|
||||
showSuccess,
|
||||
getModelCategories,
|
||||
} from '../../helpers';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import UserCenterPageHeader from '../../components/common/UserCenterPageHeader';
|
||||
import TableColumnSettings from '../../components/common/table/ColumnSettings';
|
||||
@@ -62,6 +62,10 @@ import { CUSTOMER_SERVICE_OPEN_EVENT } from '../../components/customer-service';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { UserContext } from '../../context/User';
|
||||
import { isHeaderActionButtonVisible } from '../../helpers/navigationVisibility';
|
||||
import {
|
||||
flushCreationEvents,
|
||||
trackCreationEvent,
|
||||
} from '../../helpers/creationEvents';
|
||||
import './key-management.css';
|
||||
|
||||
const KEY_MASK = '••••••••••••••••';
|
||||
@@ -473,6 +477,17 @@ const ModelsDrawer = ({ visible, onClose, token, t }) => {
|
||||
|
||||
const KeyManagement = ({ embedded = false }) => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
// 从新创作台"获取 API 代码 → 创建密钥"进入(WP C-1):创建成功记 key_created_from_studio(每次进入一次)
|
||||
const fromStudioRef = useRef(
|
||||
new URLSearchParams(location.search).get('from') === 'creation_studio',
|
||||
);
|
||||
const handleTokenCreated = (count) => {
|
||||
if (!fromStudioRef.current) return;
|
||||
fromStudioRef.current = false;
|
||||
trackCreationEvent('key_created_from_studio', { count });
|
||||
flushCreationEvents();
|
||||
};
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const [userState] = useContext(UserContext);
|
||||
const openFluentNotificationRef = useRef(null);
|
||||
@@ -673,9 +688,10 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
const handleToggle = (token) => {
|
||||
const action = token.status === 1 ? 'disable' : 'enable';
|
||||
Modal.confirm({
|
||||
title: t(
|
||||
action === 'disable' ? '确定要禁用此密钥吗?' : '确定要启用此密钥吗?',
|
||||
),
|
||||
title:
|
||||
action === 'disable'
|
||||
? t('确定要禁用此密钥吗?')
|
||||
: t('确定要启用此密钥吗?'),
|
||||
onOk: () => manageToken(token.id, action, token),
|
||||
});
|
||||
};
|
||||
@@ -799,11 +815,11 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
},
|
||||
}}
|
||||
locale={{
|
||||
back: '上一步',
|
||||
close: '关闭',
|
||||
last: '开始使用 🚀',
|
||||
next: '下一步 →',
|
||||
skip: '跳过',
|
||||
back: t('上一步'),
|
||||
close: t('关闭'),
|
||||
last: `${t('开始使用')} 🚀`,
|
||||
next: `${t('下一步')} →`,
|
||||
skip: t('跳过'),
|
||||
}}
|
||||
floaterProps={{
|
||||
disableAnimation: false,
|
||||
@@ -959,6 +975,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
handleClose={closeEdit}
|
||||
labelReplace='密钥'
|
||||
presentation='drawer'
|
||||
onCreated={handleTokenCreated}
|
||||
/>
|
||||
|
||||
{/* 可用模型列表抽屉 */}
|
||||
|
||||
@@ -20,10 +20,12 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React from 'react';
|
||||
import WeeLogo from '../components/common/logo/WeeLogo';
|
||||
import { Card, Typography } from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
const LogoShowcase = () => {
|
||||
const { t } = useTranslation();
|
||||
const logoStyles = [
|
||||
{
|
||||
name: 'minimalist',
|
||||
@@ -60,10 +62,10 @@ const LogoShowcase = () => {
|
||||
<div className='max-w-6xl mx-auto'>
|
||||
<div className='text-center mb-12'>
|
||||
<Title heading={1} className='!text-4xl !font-bold !mb-4'>
|
||||
WeeLogo 风格展示
|
||||
{t('WeeLogo 风格展示')}
|
||||
</Title>
|
||||
<Text className='text-lg text-gray-600 dark:text-gray-300'>
|
||||
选择最适合你的 Logo 风格
|
||||
{t('选择最适合你的 Logo 风格')}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
@@ -85,10 +87,10 @@ const LogoShowcase = () => {
|
||||
</div>
|
||||
<div className='p-6 bg-white dark:bg-zinc-800'>
|
||||
<Title heading={3} className='!text-xl !font-semibold !mb-2'>
|
||||
{style.title}
|
||||
{t(style.title)}
|
||||
</Title>
|
||||
<Text className='text-gray-600 dark:text-gray-300'>
|
||||
{style.description}
|
||||
{t(style.description)}
|
||||
</Text>
|
||||
<div className='mt-4 p-3 bg-slate-100 dark:bg-zinc-700 rounded font-mono text-sm'>
|
||||
{'<WeeLogo style="' + style.name + '" size={64} />'}
|
||||
@@ -100,13 +102,13 @@ const LogoShowcase = () => {
|
||||
|
||||
<Card className='p-8 bg-white dark:bg-zinc-800 shadow-lg'>
|
||||
<Title heading={2} className='!text-2xl !font-bold !mb-6'>
|
||||
使用方法
|
||||
{t('使用方法')}
|
||||
</Title>
|
||||
|
||||
<div className='space-y-6'>
|
||||
<div>
|
||||
<Title heading={4} className='!text-lg !font-semibold !mb-3'>
|
||||
1. 导入组件
|
||||
1. {t('导入组件')}
|
||||
</Title>
|
||||
<div className='p-4 bg-slate-100 dark:bg-zinc-700 rounded font-mono text-sm overflow-x-auto'>
|
||||
{"import WeeLogo from './components/common/logo/WeeLogo';"}
|
||||
@@ -115,7 +117,7 @@ const LogoShowcase = () => {
|
||||
|
||||
<div>
|
||||
<Title heading={4} className='!text-lg !font-semibold !mb-3'>
|
||||
2. 在 HeaderLogo 中使用
|
||||
2. {t('在 HeaderLogo 中使用')}
|
||||
</Title>
|
||||
<div className='p-4 bg-slate-100 dark:bg-zinc-700 rounded font-mono text-sm overflow-x-auto whitespace-pre'>
|
||||
{`<HeaderLogo
|
||||
@@ -128,7 +130,7 @@ const LogoShowcase = () => {
|
||||
|
||||
<div>
|
||||
<Title heading={4} className='!text-lg !font-semibold !mb-3'>
|
||||
3. 直接使用
|
||||
3. {t('直接使用')}
|
||||
</Title>
|
||||
<div className='p-4 bg-slate-100 dark:bg-zinc-700 rounded font-mono text-sm overflow-x-auto'>
|
||||
{'<WeeLogo style="tech" size={48} />'}
|
||||
@@ -138,7 +140,7 @@ const LogoShowcase = () => {
|
||||
|
||||
<div className='mt-8 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded'>
|
||||
<Text className='text-blue-800 dark:text-blue-200'>
|
||||
💡 提示: 更多详细信息请查看{' '}
|
||||
💡 {t('提示:更多详细信息请查看')}{' '}
|
||||
<code className='px-2 py-1 bg-blue-100 dark:bg-blue-900 rounded'>
|
||||
web/src/components/common/logo/README.md
|
||||
</code>
|
||||
@@ -148,7 +150,7 @@ const LogoShowcase = () => {
|
||||
|
||||
<div className='mt-8 text-center'>
|
||||
<Text className='text-gray-500 dark:text-gray-400'>
|
||||
所有 Logo 风格都支持平滑的动画效果和响应式设计
|
||||
{t('所有 Logo 风格都支持平滑的动画效果和响应式设计')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -488,7 +488,7 @@ const AdminMonitor = () => {
|
||||
}}
|
||||
>
|
||||
<span style={{ color: 'var(--ui-color-text-1)' }}>
|
||||
{item.type}
|
||||
{t(item.type)}
|
||||
</span>
|
||||
<span
|
||||
style={{ fontWeight: 600, color: 'var(--ui-color-text-0)' }}
|
||||
|
||||
@@ -20,11 +20,13 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Tabs, Card } from '@/components/ui';
|
||||
import { Activity, Shield } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ChannelMonitor from './ChannelMonitor';
|
||||
import AdminMonitor from './AdminMonitor';
|
||||
import './monitor-center.css';
|
||||
|
||||
const MonitorCenter = () => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState('channel');
|
||||
const [userRole, setUserRole] = useState(0);
|
||||
|
||||
@@ -59,7 +61,7 @@ const MonitorCenter = () => {
|
||||
tab={
|
||||
<span className='flex items-center gap-2'>
|
||||
<Activity className='w-4 h-4' />
|
||||
渠道监控
|
||||
{t('渠道监控')}
|
||||
</span>
|
||||
}
|
||||
itemKey='channel'
|
||||
@@ -72,7 +74,7 @@ const MonitorCenter = () => {
|
||||
tab={
|
||||
<span className='flex items-center gap-2'>
|
||||
<Shield className='w-4 h-4' />
|
||||
管理监控
|
||||
{t('管理监控')}
|
||||
</span>
|
||||
}
|
||||
itemKey='admin'
|
||||
|
||||
@@ -59,11 +59,11 @@ const Monitoring = () => {
|
||||
if (res.data.success) {
|
||||
setChannelStatus(res.data.data || []);
|
||||
} else {
|
||||
Toast.error(res.data.message || '获取渠道状态失败');
|
||||
Toast.error(res.data.message || t('获取渠道状态失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch channel status:', error);
|
||||
Toast.error('获取渠道状态失败');
|
||||
Toast.error(t('获取渠道状态失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,11 @@ export default function MyCommission() {
|
||||
empty={<TableEmpty />}
|
||||
/>
|
||||
<Modal
|
||||
title={detail ? `${detail.bill.month} ${t('月提成明细')}` : ''}
|
||||
title={
|
||||
detail
|
||||
? t('{{month}} 月提成明细', { month: detail.bill.month })
|
||||
: ''
|
||||
}
|
||||
visible={!!detail}
|
||||
onCancel={() => setDetail(null)}
|
||||
width={760}
|
||||
|
||||
@@ -201,14 +201,14 @@ function formatRelativeTime(timestamp, t) {
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (seconds < 60) return t('刚刚');
|
||||
if (minutes < 60) return minutes + t('分钟前');
|
||||
if (hours < 24) return hours + t('小时前');
|
||||
if (days < 30) return days + t('天前');
|
||||
if (minutes < 60) return t('{{n}} 分钟前', { n: minutes });
|
||||
if (hours < 24) return t('{{n}} 小时前', { n: hours });
|
||||
if (days < 30) return t('{{n}} 天前', { n: days });
|
||||
return new Date(timestamp * 1000).toLocaleDateString();
|
||||
}
|
||||
|
||||
const OrgAudit = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { logs, total, loading, fetch } = useOrgAuditLogs(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -372,7 +372,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
width: 150,
|
||||
render: (v) =>
|
||||
v ? (
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString('zh-CN')}>
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString(i18n.language)}>
|
||||
<time
|
||||
className='oc-audit-time'
|
||||
dateTime={new Date(v * 1000).toISOString()}
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
/*
|
||||
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,
|
||||
KeyRound,
|
||||
ArrowRight,
|
||||
HelpCircle,
|
||||
Home,
|
||||
AlertTriangle,
|
||||
RefreshCw,
|
||||
} from 'lucide-react';
|
||||
import { Input, Button, Toast } from '@/components/ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import { UserContext } from '../../context/User';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
|
||||
// 企业创建已收归系统管理员手动创建(/api/admin/organizations/)。
|
||||
// 此页面是「无企业归属」用户的落地引导页,按意图区分三态:
|
||||
// join —— 用户不属于任何企业,展示企业代码加入入口
|
||||
// inactive —— 用户有企业但均非活跃(冻结/欠费/待激活),引导联系管理员,避免误导其"加入"
|
||||
// error —— 企业列表加载失败,提供重试
|
||||
const ORG_STATUS_TEXT = {
|
||||
2: '已被冻结',
|
||||
3: '已欠费',
|
||||
4: '待激活',
|
||||
};
|
||||
|
||||
const OrgCreate = () => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [userState] = useContext(UserContext);
|
||||
const isOrgOnly = userState?.user?.org_only_mode === true;
|
||||
const [joinLoading, setJoinLoading] = useState(false);
|
||||
const [orgCode, setOrgCode] = useState('');
|
||||
// 'checking' | 'join' | 'inactive' | 'error'
|
||||
const [mode, setMode] = useState('checking');
|
||||
const [inactiveOrgs, setInactiveOrgs] = useState([]);
|
||||
|
||||
// 检查用户企业归属并决定落地状态。
|
||||
// 有 active(status=1) 企业 → 写入 current_org_id 并跳转控制台(仅认 active,防冻结企业死循环)。
|
||||
const runCheck = useCallback(async () => {
|
||||
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);
|
||||
if (activeOrgs.length > 0) {
|
||||
const savedOrgId = parseInt(
|
||||
localStorage.getItem('current_org_id') || '0',
|
||||
10,
|
||||
);
|
||||
const savedOrg =
|
||||
savedOrgId > 0 ? activeOrgs.find((o) => o.id === savedOrgId) : null;
|
||||
const targetOrg = savedOrg || activeOrgs[0];
|
||||
localStorage.setItem('current_org_id', String(targetOrg.id));
|
||||
navigate('/org/dashboard', { replace: true });
|
||||
return;
|
||||
}
|
||||
if (orgs.length > 0) {
|
||||
setInactiveOrgs(orgs);
|
||||
setMode('inactive');
|
||||
return;
|
||||
}
|
||||
setMode('join');
|
||||
return;
|
||||
}
|
||||
setMode('error');
|
||||
} catch {
|
||||
setMode('error');
|
||||
}
|
||||
}, [navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
runCheck();
|
||||
}, [runCheck]);
|
||||
|
||||
const handleJoin = useCallback(async () => {
|
||||
if (!orgCode.trim()) {
|
||||
Toast.warning(t('请输入企业代码'));
|
||||
return;
|
||||
}
|
||||
setJoinLoading(true);
|
||||
try {
|
||||
const res = await API.post('/api/org/join', { code: orgCode.trim() });
|
||||
if (res.data.success) {
|
||||
Toast.success(t('成功加入企业'));
|
||||
const data = res.data.data;
|
||||
if (data && data.organization && data.organization.id) {
|
||||
localStorage.setItem('current_org_id', String(data.organization.id));
|
||||
}
|
||||
navigate('/org/dashboard');
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
setJoinLoading(false);
|
||||
}
|
||||
}, [orgCode, t, navigate]);
|
||||
|
||||
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 (
|
||||
<div className='org-center relative min-h-screen flex items-center justify-center bg-[var(--surface-bg-base)] py-16 px-4 transition-colors duration-300'>
|
||||
{/* 统一页面背景层 —— 唯一背景来源,走 bg-glow-* 主题变量 */}
|
||||
<PageBackground />
|
||||
|
||||
<div className='w-full max-w-md relative z-10'>
|
||||
{mode === 'join' && (
|
||||
<>
|
||||
<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'>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
{t('企业代码')}
|
||||
</label>
|
||||
<Input
|
||||
value={orgCode}
|
||||
onChange={(v) => setOrgCode(v)}
|
||||
placeholder={t('请输入 8 位企业代码')}
|
||||
size='large'
|
||||
prefix={<KeyRound size={18} className='text-gray-400 ml-1' />}
|
||||
onEnterPress={handleJoin}
|
||||
className='tracking-wide'
|
||||
/>
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
loading={joinLoading}
|
||||
onClick={handleJoin}
|
||||
icon={<ArrowRight size={18} />}
|
||||
iconPosition='right'
|
||||
className='mt-4'
|
||||
>
|
||||
{t('加入企业')}
|
||||
</Button>
|
||||
|
||||
<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>
|
||||
</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}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgCreate;
|
||||
@@ -25,6 +25,7 @@ import React, {
|
||||
useRef,
|
||||
} from 'react';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
@@ -690,7 +691,7 @@ const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{isAdmin && (
|
||||
{isAdmin && !isMiniProgramWebView() && (
|
||||
<Button
|
||||
icon={<Wallet size={16} />}
|
||||
theme='solid'
|
||||
|
||||
@@ -318,7 +318,10 @@ const OrgDepartments = ({ orgId }) => {
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={`${t('所选上级部门已有')} ${parentMemberCount} ${t('名直属成员,新增下级后建议将这些成员迁移到末级部门')}`}
|
||||
description={t(
|
||||
'所选上级部门已有 {{n}} 名直属成员,新增下级后建议将这些成员迁移到末级部门',
|
||||
{ n: parentMemberCount },
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<Form
|
||||
|
||||
@@ -355,7 +355,10 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
<PageGuideTrigger guide={guide} />
|
||||
<Select
|
||||
value={dimension}
|
||||
optionList={dimensions}
|
||||
optionList={dimensions.map((d) => ({
|
||||
...d,
|
||||
label: t(d.label),
|
||||
}))}
|
||||
onChange={setDimension}
|
||||
/>
|
||||
{dimension !== 'organization' && (
|
||||
|
||||
@@ -532,7 +532,7 @@ const OrgExperts = ({ orgId }) => {
|
||||
value={form.default_language}
|
||||
onChange={(v) => update('default_language', v)}
|
||||
optionList={[
|
||||
{ value: 'zh', label: '中文' },
|
||||
{ value: 'zh', label: t('中文') },
|
||||
{ value: 'en', label: 'English' },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -1918,7 +1918,7 @@ const OrgKnowledge = ({ orgId, canAuditContent = false }) => {
|
||||
{searchSummary && !searching && (
|
||||
<div className='knowledge-hit-summary'>
|
||||
<span>
|
||||
{t('命中')} {searchHits.length} {t('条片段')}
|
||||
{t('命中 {{n}} 条片段', { n: searchHits.length, count: searchHits.length })}
|
||||
</span>
|
||||
<Tag
|
||||
color={searchSummary.full ? 'amber' : 'grey'}
|
||||
|
||||
@@ -70,7 +70,7 @@ const formatImportError = (t, row) => {
|
||||
case 'login_name_reserved':
|
||||
return t('该登录名为系统保留名称,请换一个登录名');
|
||||
case 'email_exists':
|
||||
return t('该邮箱已是平台用户,请使用企业代码加入企业');
|
||||
return t('该邮箱已被平台用户使用,请更换邮箱或留空');
|
||||
case 'member_limit_reached':
|
||||
return t('企业成员数量已达到上限 {{max}}', params);
|
||||
case 'password_generation_failed':
|
||||
@@ -329,9 +329,7 @@ const OrgMemberAccounts = ({
|
||||
<div className='flex items-center gap-2'>
|
||||
<span>{r.display_name || r.username || `#${r.user_id}`}</span>
|
||||
{r.created_by_org_id !== r.organization_id && (
|
||||
<Tooltip
|
||||
content={t('通过企业代码加入的个人平台账号,非本企业托管')}
|
||||
>
|
||||
<Tooltip content={t('个人平台账号(非本企业托管)')}>
|
||||
<Tag size='small' color='blue'>
|
||||
{t('个人账号')}
|
||||
</Tag>
|
||||
@@ -542,7 +540,7 @@ const OrgMemberAccounts = ({
|
||||
<Form.Input
|
||||
field='email'
|
||||
label={t('邮箱(可选)')}
|
||||
placeholder={t('已是平台用户的邮箱请改用企业代码加入')}
|
||||
placeholder={t('已被平台用户使用的邮箱不可填写,可留空')}
|
||||
rules={[
|
||||
{
|
||||
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
||||
@@ -684,7 +682,14 @@ const OrgMemberAccounts = ({
|
||||
type={importResult.failed > 0 ? 'warning' : 'success'}
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={`${t('成功')} ${importResult.success} · ${t('失败')} ${importResult.failed} / ${t('共')} ${importResult.total}`}
|
||||
description={t(
|
||||
'成功 {{success}} · 失败 {{failed}} / 共 {{total}}',
|
||||
{
|
||||
success: importResult.success,
|
||||
failed: importResult.failed,
|
||||
total: importResult.total,
|
||||
},
|
||||
)}
|
||||
/>
|
||||
<Table
|
||||
size='small'
|
||||
|
||||
@@ -49,7 +49,7 @@ const OrgMembers = ({
|
||||
showAccounts = true,
|
||||
featureFlags = null,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const {
|
||||
members,
|
||||
total,
|
||||
@@ -322,7 +322,7 @@ const OrgMembers = ({
|
||||
// 格式化加入时间:原型显示绝对日期 YYYY/MM/DD(同一时间戳,仅格式化方式变化)
|
||||
const formatJoinTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
return new Date(timestamp * 1000).toLocaleDateString('zh-CN', {
|
||||
return new Date(timestamp * 1000).toLocaleDateString(i18n.language, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -486,7 +486,9 @@ const OrgMembers = ({
|
||||
width: 110,
|
||||
render: (enabled, record) =>
|
||||
enabled ? (
|
||||
`${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
t('{{count}} 个模型', {
|
||||
count: record.model_limits.split(',').filter(Boolean).length,
|
||||
})
|
||||
) : (
|
||||
<span className='oc-muted'>{t('不限')}</span>
|
||||
),
|
||||
@@ -553,7 +555,9 @@ const OrgMembers = ({
|
||||
dataIndex: 'joined_at',
|
||||
width: 125,
|
||||
render: (v) => (
|
||||
<Tooltip content={v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}>
|
||||
<Tooltip
|
||||
content={v ? new Date(v * 1000).toLocaleString(i18n.language) : '-'}
|
||||
>
|
||||
<span className='oc-number'>{formatJoinTime(v)}</span>
|
||||
</Tooltip>
|
||||
),
|
||||
@@ -709,7 +713,7 @@ const OrgMembers = ({
|
||||
type='info'
|
||||
showIcon
|
||||
message={t(
|
||||
'当前企业仅有您一位成员。成员可使用企业代码自助加入,或由系统管理员创建成员账号后即可在此管理成员角色、额度上限和访问权限。',
|
||||
'当前企业仅有您一位成员。为员工创建成员账号后,即可在此管理成员角色、额度上限和访问权限。',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18next from 'i18next';
|
||||
import {
|
||||
Copy,
|
||||
Database,
|
||||
@@ -51,14 +52,13 @@ const emptyFilters = {
|
||||
endTimestamp: 0,
|
||||
};
|
||||
|
||||
const tokenNumberFormatter = new Intl.NumberFormat('zh-CN');
|
||||
const formatTokenCount = (value) =>
|
||||
tokenNumberFormatter.format(Number(value) || 0);
|
||||
new Intl.NumberFormat(i18next.language).format(Number(value) || 0);
|
||||
|
||||
// 下钻明细:一条提示词记录 → 该次用户输入的全部接口调用行(首调 + agent 中间调用)。
|
||||
// 数据来自平台消费日志(logs.prompt_group_key 索引等值查询),展开行时按需拉取。
|
||||
const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const [calls, setCalls] = useState(null); // null = 加载中
|
||||
const [error, setError] = useState('');
|
||||
@@ -141,7 +141,9 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
className='border-t border-gray-100 dark:border-white/[0.06]'
|
||||
>
|
||||
<td className='py-1 pr-3'>
|
||||
{new Date(log.created_at * 1000).toLocaleString('zh-CN')}
|
||||
{new Date(log.created_at * 1000).toLocaleString(
|
||||
i18n.language,
|
||||
)}
|
||||
</td>
|
||||
<td className='py-1 pr-3'>{log.model_name}</td>
|
||||
<td className='py-1 pr-3'>
|
||||
@@ -166,7 +168,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
// 提示词记录审计表(方案 §35 一期):数据来自企业自行配置的数据库,
|
||||
// 一行 = 一次「用户输入 → 最终 AI 返回」,agent 中间过程调用只累计次数与花费。
|
||||
const OrgPromptRecords = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { records, total, loading, error, fetch } = useOrgPromptRecords(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -400,11 +402,13 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
width: 230,
|
||||
render: (v, record) => (
|
||||
<Tooltip
|
||||
content={
|
||||
t('输入 / 输出 tokens(全过程累计)') +
|
||||
`,${t('缓存命中')} ${record.cache_hit_tokens || 0}` +
|
||||
`,${t('缓存创建')} ${record.cache_creation_tokens || 0}`
|
||||
}
|
||||
content={t(
|
||||
'输入 / 输出 tokens(全过程累计),缓存命中 {{hit}},缓存创建 {{created}}',
|
||||
{
|
||||
hit: record.cache_hit_tokens || 0,
|
||||
created: record.cache_creation_tokens || 0,
|
||||
},
|
||||
)}
|
||||
position='top'
|
||||
>
|
||||
<div className='grid cursor-default grid-cols-2 gap-x-4 gap-y-1 whitespace-nowrap text-xs'>
|
||||
@@ -442,18 +446,15 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
width: 175,
|
||||
render: (v, record) => (
|
||||
<Tooltip
|
||||
content={
|
||||
t('首次') +
|
||||
': ' +
|
||||
new Date(record.first_at * 1000).toLocaleString('zh-CN') +
|
||||
',' +
|
||||
t('最后') +
|
||||
': ' +
|
||||
new Date(v * 1000).toLocaleString('zh-CN')
|
||||
}
|
||||
content={t('首次: {{first}},最后: {{last}}', {
|
||||
first: new Date(record.first_at * 1000).toLocaleString(
|
||||
i18n.language,
|
||||
),
|
||||
last: new Date(v * 1000).toLocaleString(i18n.language),
|
||||
})}
|
||||
>
|
||||
<span className='cursor-default whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-gray-400'>
|
||||
{v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}
|
||||
{v ? new Date(v * 1000).toLocaleString(i18n.language) : '-'}
|
||||
</span>
|
||||
</Tooltip>
|
||||
),
|
||||
|
||||
@@ -662,7 +662,9 @@ const OrgRecharge = ({ orgId }) => {
|
||||
role={customInvalid ? 'alert' : undefined}
|
||||
>
|
||||
{customInvalid
|
||||
? `${t('当前 ¥')}${customEffectiveAmount.toLocaleString()}${t(',未达到最低 ¥1,000')}`
|
||||
? t('当前 ¥{{amount}},未达到最低 ¥1,000', {
|
||||
amount: customEffectiveAmount.toLocaleString(),
|
||||
})
|
||||
: `${t('最少 1000 元,必须为 1000 元的整倍数')};${t('原价到账,不参与折扣')}`}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
@@ -58,7 +58,6 @@ import {
|
||||
getQuotaPerUnit,
|
||||
collectPagedItems,
|
||||
} from '../../helpers';
|
||||
import QuotaInput from '../../components/common/ui/QuotaInput';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgModal from './components/OrgModal';
|
||||
@@ -634,44 +633,6 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
</div>
|
||||
);
|
||||
|
||||
const quotaPanel = (
|
||||
<div className='oc-cs-panel'>
|
||||
<SectionHeader
|
||||
title={t('额度策略')}
|
||||
description={t('设置自助加入成员的默认额度')}
|
||||
extra={headingExtra(handleSave, loading)}
|
||||
/>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item
|
||||
label={t('新成员默认额度上限')}
|
||||
extra={
|
||||
<>
|
||||
{t(
|
||||
'新成员通过企业代码自助加入时的默认个人额度上限。设置为大于 0 的值可避免企业代码泄露后被盗刷企业额度池;设置为 0 表示不限制(新成员可直接使用企业统一额度池,存在风险)。',
|
||||
)}
|
||||
{!(Number(orgInfo.default_member_quota) > 0) && (
|
||||
<span className='oc-cs-warning'>
|
||||
{t('当前为 0:新成员将不受限制地使用企业额度池')}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<QuotaInput
|
||||
value={orgInfo.default_member_quota}
|
||||
onChange={(v) =>
|
||||
setOrgInfo({ ...orgInfo, default_member_quota: v })
|
||||
}
|
||||
minQuota={0}
|
||||
style={{ width: 360, maxWidth: '100%' }}
|
||||
placeholder={t('请输入金额,0 表示不限制')}
|
||||
disabled={isSuperAdmin}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</div>
|
||||
);
|
||||
|
||||
const alertsPanel = (
|
||||
<div className='oc-cs-panel'>
|
||||
<SectionHeader
|
||||
@@ -686,10 +647,9 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
label={t('预警阈值')}
|
||||
extra={
|
||||
Number(alertYuan) >= 0.005 ? (
|
||||
<>
|
||||
{t('当企业剩余额度低于')} {getCurrencySymbol()}
|
||||
{Number(alertYuan).toFixed(2)} {t('时触发预警')}
|
||||
</>
|
||||
t('当企业剩余额度低于 {{amount}} 时触发预警', {
|
||||
amount: `${getCurrencySymbol()}${Number(alertYuan).toFixed(2)}`,
|
||||
})
|
||||
) : (
|
||||
t('当前为 0:已关闭余额预警')
|
||||
)
|
||||
@@ -968,11 +928,6 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
label: t('基本信息'),
|
||||
children: basicPanel,
|
||||
},
|
||||
(isOwner || isSuperAdmin) && {
|
||||
key: 'quota',
|
||||
label: t('额度与成员'),
|
||||
children: quotaPanel,
|
||||
},
|
||||
(isOwner || isSuperAdmin) && {
|
||||
key: 'alerts',
|
||||
label: t('通知预警'),
|
||||
|
||||
@@ -50,6 +50,10 @@ import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import { canAccessOrgSettings } from './orgFeatureFlags';
|
||||
import {
|
||||
isMiniProgramPaymentPath,
|
||||
isMiniProgramWebView,
|
||||
} from '../../helpers/miniProgram';
|
||||
import {
|
||||
CLOUD_BRAIN_UI_ENABLED,
|
||||
isCloudBrainOrgPath,
|
||||
@@ -356,6 +360,9 @@ const OrgSidebar = ({
|
||||
return false;
|
||||
}
|
||||
if (item.adminOnly && !isAdmin) return false;
|
||||
// WeyAi 小程序里不出现付费入口(helpers/miniProgram.js)。
|
||||
if (isMiniProgramWebView() && isMiniProgramPaymentPath(item.itemKey))
|
||||
return false;
|
||||
// 平台超管(无成员身份)访问成员型入口必被 member_actor_required 拒绝。
|
||||
if (!isMemberActor && item.itemKey === '/org/my-capabilities')
|
||||
return false;
|
||||
|
||||
@@ -292,7 +292,9 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
onClick={() => handleViewModels(record)}
|
||||
>
|
||||
{record.model_limits_enabled && record.model_limits
|
||||
? `${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
? t('{{count}} 个模型', {
|
||||
count: record.model_limits.split(',').filter(Boolean).length,
|
||||
})
|
||||
: t('全部模型')}
|
||||
</AntButton>
|
||||
),
|
||||
|
||||
@@ -175,8 +175,10 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
if (!orgId) return;
|
||||
if (!silent) setLoading(true);
|
||||
try {
|
||||
// include_usage=1:只有工作台展示个人用量,后端仅在此时查询日志聚合
|
||||
const res = await API.get('/api/org/me/summary', {
|
||||
headers: getOrgHeaders(orgId),
|
||||
params: { include_usage: 1 },
|
||||
});
|
||||
if (res.data.success) {
|
||||
setSummary(res.data.data);
|
||||
|
||||
@@ -182,7 +182,7 @@ const DeptNode = memo(({ data, selected }) => {
|
||||
<Tooltip
|
||||
content={
|
||||
collapsed
|
||||
? `${t('展开')}(${t('已收起')} ${hiddenCount} ${t('个下级')})`
|
||||
? t('展开(已收起 {{n}} 个下级)', { n: hiddenCount })
|
||||
: t('收起下级部门')
|
||||
}
|
||||
>
|
||||
|
||||
@@ -194,7 +194,7 @@ const OrgScopedLimitButtons = ({
|
||||
|
||||
{/* 模型限制 Modal */}
|
||||
<OrgModal
|
||||
title={`${t(scopeLabel)}${t('模型限制')}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
title={`${t('{{scope}}模型限制', { scope: t(scopeLabel) })}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
visible={modelModalVisible}
|
||||
onOk={handleModelSave}
|
||||
onCancel={() => setModelModalVisible(false)}
|
||||
@@ -236,7 +236,7 @@ const OrgScopedLimitButtons = ({
|
||||
|
||||
{/* 可调用分组 Modal */}
|
||||
<OrgModal
|
||||
title={`${t(scopeLabel)}${t('可调用分组')}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
title={`${t('{{scope}}可调用分组', { scope: t(scopeLabel) })}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
visible={groupsModalVisible}
|
||||
onOk={handleGroupsSave}
|
||||
onCancel={() => setGroupsModalVisible(false)}
|
||||
|
||||
@@ -17,6 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import i18next from 'i18next';
|
||||
|
||||
// 部门树构建工具:/api/org/dept 返回按 sort asc, id asc 排序的扁平列表,
|
||||
// 这里按 parent_id 组装成 Semi Tree/TreeSelect 的 treeData。
|
||||
|
||||
@@ -34,7 +36,7 @@ export function buildDeptTreeData(depts, options = {}) {
|
||||
const {
|
||||
disableNonLeaf = true,
|
||||
excludeSubtreeOf = null,
|
||||
disabledLabel = '已停用',
|
||||
disabledLabel = i18next.t('已停用'),
|
||||
} = options;
|
||||
const excluded = (d) =>
|
||||
excludeSubtreeOf &&
|
||||
|
||||
@@ -34,8 +34,10 @@ import { useMarquee } from '../../hooks/common/useMarquee';
|
||||
import { UserContext } from '../../context/User';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import OrgResolver from './OrgResolver';
|
||||
import OrgSidebar from './OrgSidebar';
|
||||
import OrgWorkbench from './OrgWorkbench';
|
||||
import OrgDashboard from './OrgDashboard';
|
||||
@@ -231,7 +233,9 @@ const Organization = () => {
|
||||
if (isOrgModuleVisible('tokens')) routes.push('tokens');
|
||||
if (isOrgModuleVisible('logs')) routes.push('logs');
|
||||
if (isAdmin && isOrgModuleVisible('audit')) routes.push('audit');
|
||||
if (isAdmin && isOrgModuleVisible('recharge')) routes.push('recharge');
|
||||
// WeyAi 小程序里充值页会被送回 /user-center → /org,不能作落点,否则来回跳转。
|
||||
if (isAdmin && isOrgModuleVisible('recharge') && !isMiniProgramWebView())
|
||||
routes.push('recharge');
|
||||
if (canManageSettings && isOrgModuleVisible('settings'))
|
||||
routes.push('settings');
|
||||
return routes;
|
||||
@@ -265,6 +269,17 @@ const Organization = () => {
|
||||
|
||||
// 从 localStorage 获取当前企业ID
|
||||
const orgId = parseInt(localStorage.getItem('current_org_id') || '0', 10);
|
||||
// localStorage 不会触发重渲染:解析器写入/清除 current_org_id 后靠它刷新。
|
||||
// failedOrgIds 累计本次挂载内加载失败过的企业,交给解析器跳过:只记最近一个会在
|
||||
// 两个都失败的企业之间 A→B→A 来回自动切换(每轮都发请求并弹错误提示)。
|
||||
const [failedOrgIds, setFailedOrgIds] = useState([]);
|
||||
const [, setOrgResolveTick] = useState(0);
|
||||
const handleOrgResolved = useCallback(() => {
|
||||
// 同次挂载内 loading 已是 false、角色仍为空:不先置回 loading,
|
||||
// 切到新 orgId 的首帧就会按"非管理员"渲染路由守卫,把管理员从 /org/dashboard 弹走。
|
||||
setLoading(true);
|
||||
setOrgResolveTick((n) => n + 1);
|
||||
}, []);
|
||||
|
||||
const fetchOrgInfo = useCallback(async () => {
|
||||
if (!orgId) {
|
||||
@@ -301,11 +316,11 @@ const Organization = () => {
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
localStorage.removeItem('current_org_id');
|
||||
navigateRef.current('/org/create', { replace: true });
|
||||
setFailedOrgIds((ids) => (ids.includes(orgId) ? ids : [...ids, orgId]));
|
||||
}
|
||||
} catch {
|
||||
localStorage.removeItem('current_org_id');
|
||||
navigateRef.current('/org/create', { replace: true });
|
||||
setFailedOrgIds((ids) => (ids.includes(orgId) ? ids : [...ids, orgId]));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -388,7 +403,13 @@ const Organization = () => {
|
||||
}
|
||||
|
||||
if (!orgId) {
|
||||
return <Navigate to='/org/create' replace />;
|
||||
return (
|
||||
<OrgResolver
|
||||
onResolved={handleOrgResolved}
|
||||
excludeOrgIds={failedOrgIds}
|
||||
hasMarquee={hasMarquee}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
|
||||
@@ -344,8 +344,9 @@ function Overview({ dashboard, t, onGoto }) {
|
||||
>
|
||||
<span className='flex items-center gap-2 text-sm text-orange-700 dark:text-orange-300'>
|
||||
<ReceiptText size={15} className='flex-shrink-0' />
|
||||
{t('您有')} {pendingBills}{' '}
|
||||
{t('张账单待确认,请尽快核对——确认后才会进入打款流程')}
|
||||
{t('您有 {{n}} 张账单待确认,请尽快核对——确认后才会进入打款流程', {
|
||||
n: pendingBills,
|
||||
})}
|
||||
</span>
|
||||
<span className='flex items-center gap-0.5 text-sm font-medium text-orange-700 dark:text-orange-300 flex-shrink-0'>
|
||||
{t('去确认')}
|
||||
@@ -932,7 +933,9 @@ function Bills({ t, readOnly }) {
|
||||
pagination={false}
|
||||
/>
|
||||
<Modal
|
||||
title={detail ? `${detail.bill.month} ${t('月账单明细')}` : ''}
|
||||
title={
|
||||
detail ? t('{{month}} 月账单明细', { month: detail.bill.month }) : ''
|
||||
}
|
||||
visible={!!detail}
|
||||
onCancel={() => setDetail(null)}
|
||||
width={860}
|
||||
@@ -1292,7 +1295,7 @@ function Referrals({ t, partnerCode }) {
|
||||
{
|
||||
title: t('二层计提剩余'),
|
||||
dataIndex: 'l2_remaining_months',
|
||||
render: (v) => (v > 0 ? `${v} ${t('个月')}` : t('已到期')),
|
||||
render: (v) => (v > 0 ? t('{{n}} 个月', { n: v }) : t('已到期')),
|
||||
},
|
||||
{
|
||||
title: t('累计二层返佣(元)'),
|
||||
|
||||
@@ -803,7 +803,7 @@ const Playground = ({ isExperienceMode = false }) => {
|
||||
customPayload = JSON.parse(customRequestBody);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse custom request body', error);
|
||||
Toast.error(ERROR_MESSAGES.JSON_PARSE_ERROR);
|
||||
Toast.error(t(ERROR_MESSAGES.JSON_PARSE_ERROR));
|
||||
return;
|
||||
}
|
||||
if (isExperienceMode) {
|
||||
|
||||
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React from 'react';
|
||||
import { getCurrencyConfig } from '../../helpers/render';
|
||||
import { renderQuota } from '../../helpers';
|
||||
import { calculatePresetPayableAmount } from '../../helpers/rechargeAmount';
|
||||
import { Check } from 'lucide-react';
|
||||
|
||||
// 折扣角标:0.99 → 99折,0.9 → 9折(与原型一致的中文折扣写法)
|
||||
@@ -37,16 +38,18 @@ const AmountCard = ({
|
||||
t,
|
||||
}) => {
|
||||
const discount =
|
||||
preset.discount || topupInfo?.discount?.[preset.value] || 1.0;
|
||||
preset.discount ?? topupInfo?.discount?.[preset.value] ?? 1.0;
|
||||
const hasDiscount = discount < 1.0;
|
||||
|
||||
// 计算实付金额(人民币)
|
||||
// 新版档位(有 id 字段):amount 已经是人民币金额,直接乘以折扣
|
||||
// 旧版档位或自定义金额:需要乘以汇率
|
||||
const isNewVersion = preset.id !== undefined;
|
||||
const discountedPrice = isNewVersion
|
||||
? preset.value * discount // 新版:人民币金额 * 折扣
|
||||
: preset.value * priceRatio * discount; // 旧版:额度 * 汇率 * 折扣
|
||||
const discountedPrice = calculatePresetPayableAmount(
|
||||
preset,
|
||||
priceRatio,
|
||||
topupInfo,
|
||||
);
|
||||
|
||||
// 获取货币显示配置(仅用于显示充值额度的货币符号)
|
||||
const { symbol } = getCurrencyConfig();
|
||||
|
||||
@@ -44,7 +44,7 @@ const planTypeConfig = {
|
||||
};
|
||||
|
||||
const MembershipPanel = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [, userDispatch] = useContext(UserContext);
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -227,7 +227,7 @@ const MembershipPanel = () => {
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(message || '升级成功!');
|
||||
showSuccess(message || t('升级成功!'));
|
||||
setUpgradeModalVisible(false);
|
||||
setSelectedPlan(null);
|
||||
setUpgradeInfo(null);
|
||||
@@ -286,7 +286,7 @@ const MembershipPanel = () => {
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (timestamp) => {
|
||||
return new Date(timestamp * 1000).toLocaleDateString('zh-CN');
|
||||
return new Date(timestamp * 1000).toLocaleDateString(i18n.language);
|
||||
};
|
||||
|
||||
// 原型展示固定的周卡/月卡/季卡三个时长,没有方案的时长显示“待补充”空态
|
||||
@@ -345,7 +345,10 @@ const MembershipPanel = () => {
|
||||
{t('到期日')}: {formatDate(membershipInfo.end_date)}
|
||||
</span>
|
||||
<span>
|
||||
{t('剩余')} {membershipInfo.remaining_days} {t('天')}
|
||||
{t('剩余 {{n}} 天', {
|
||||
n: membershipInfo.remaining_days,
|
||||
count: membershipInfo.remaining_days,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
{/* 已续费提示 */}
|
||||
@@ -353,17 +356,11 @@ const MembershipPanel = () => {
|
||||
<Banner
|
||||
type='success'
|
||||
closeIcon={null}
|
||||
description={
|
||||
t('已续费') +
|
||||
':' +
|
||||
membershipInfo.future_plan_name +
|
||||
',' +
|
||||
formatDate(membershipInfo.future_start_date) +
|
||||
' ~ ' +
|
||||
formatDate(membershipInfo.future_end_date) +
|
||||
' ' +
|
||||
t('生效')
|
||||
}
|
||||
description={t('已续费:{{plan}},{{start}} ~ {{end}} 生效', {
|
||||
plan: membershipInfo.future_plan_name,
|
||||
start: formatDate(membershipInfo.future_start_date),
|
||||
end: formatDate(membershipInfo.future_end_date),
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -458,7 +455,7 @@ const MembershipPanel = () => {
|
||||
{Number(plan.price).toLocaleString('en-US')}
|
||||
</strong>
|
||||
<span>
|
||||
/ {plan.duration_days} {t('天')}
|
||||
/ {t('{{days}} 天', { days: plan.duration_days })}
|
||||
</span>
|
||||
</span>
|
||||
<span className='rc-plan-quota'>
|
||||
@@ -534,8 +531,7 @@ const MembershipPanel = () => {
|
||||
{selectedPlan.name}
|
||||
</Text>
|
||||
<Tag color='blue' size='small'>
|
||||
{selectedPlan.duration_days}
|
||||
{t('天')}
|
||||
{t('{{days}} 天', { days: selectedPlan.duration_days })}
|
||||
</Tag>
|
||||
</div>
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
@@ -590,17 +586,14 @@ const MembershipPanel = () => {
|
||||
{isRenewal && (
|
||||
<Banner
|
||||
type='success'
|
||||
description={
|
||||
t('续费提示') +
|
||||
':' +
|
||||
t('您将续费当前「') +
|
||||
membershipInfo.plan_name +
|
||||
t('」,新的 ') +
|
||||
selectedPlan.duration_days +
|
||||
t(' 天会员将在当前会员到期后(') +
|
||||
formatDate(membershipInfo.end_date) +
|
||||
t(')自动生效,届时每日额度保持不变。')
|
||||
}
|
||||
description={t(
|
||||
'续费提示:您将续费当前「{{plan}}」,新的 {{days}} 天会员将在当前会员到期后({{date}})自动生效,届时每日额度保持不变。',
|
||||
{
|
||||
plan: membershipInfo.plan_name,
|
||||
days: selectedPlan.duration_days,
|
||||
date: formatDate(membershipInfo.end_date),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -609,15 +602,14 @@ const MembershipPanel = () => {
|
||||
{!isRenewal && !isDowngrade && (
|
||||
<Banner
|
||||
type='info'
|
||||
description={
|
||||
t('您当前有「') +
|
||||
membershipInfo.plan_name +
|
||||
t('」会员(到期日:') +
|
||||
formatDate(membershipInfo.end_date) +
|
||||
t(')。新购买的「') +
|
||||
selectedPlan.name +
|
||||
t('」将在当前会员到期后开始生效。')
|
||||
}
|
||||
description={t(
|
||||
'您当前有「{{plan}}」会员(到期日:{{date}})。新购买的「{{newPlan}}」将在当前会员到期后开始生效。',
|
||||
{
|
||||
plan: membershipInfo.plan_name,
|
||||
date: formatDate(membershipInfo.end_date),
|
||||
newPlan: selectedPlan.name,
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -626,15 +618,13 @@ const MembershipPanel = () => {
|
||||
{isDowngrade && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={
|
||||
t('注意:此方案的每日额度(') +
|
||||
renderQuota(selectedPlan.daily_quota) +
|
||||
t(')低于您当前方案(') +
|
||||
renderQuota(membershipInfo.daily_quota) +
|
||||
t(
|
||||
')。新会员将在当前会员到期后生效,届时每日额度将降低。如需立即提升额度,建议使用「升级」功能。',
|
||||
)
|
||||
}
|
||||
description={t(
|
||||
'注意:此方案的每日额度({{newQuota}})低于您当前方案({{currentQuota}})。新会员将在当前会员到期后生效,届时每日额度将降低。如需立即提升额度,建议使用「升级」功能。',
|
||||
{
|
||||
newQuota: renderQuota(selectedPlan.daily_quota),
|
||||
currentQuota: renderQuota(membershipInfo.daily_quota),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -656,15 +646,13 @@ const MembershipPanel = () => {
|
||||
{membershipInfo.has_future_membership && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={
|
||||
t('您已有一个待生效的续费会员「') +
|
||||
membershipInfo.future_plan_name +
|
||||
t('」(') +
|
||||
formatDate(membershipInfo.future_start_date) +
|
||||
t(
|
||||
' 生效)。再次购买将在其到期后生效,请确认是否需要继续。',
|
||||
)
|
||||
}
|
||||
description={t(
|
||||
'您已有一个待生效的续费会员「{{plan}}」({{date}} 生效)。再次购买将在其到期后生效,请确认是否需要继续。',
|
||||
{
|
||||
plan: membershipInfo.future_plan_name,
|
||||
date: formatDate(membershipInfo.future_start_date),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -745,7 +733,7 @@ const MembershipPanel = () => {
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-gray-500'>{t('剩余会员天数')}</Text>
|
||||
<Text strong>
|
||||
{upgradeInfo.remaining_days} {t('天')}
|
||||
{t('{{days}} 天', { days: upgradeInfo.remaining_days })}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
requestPayPalOrder,
|
||||
removePayPalReturnState,
|
||||
} from '../../helpers/paypalPayment';
|
||||
import { calculatePresetPayableAmount } from '../../helpers/rechargeAmount';
|
||||
|
||||
const Recharge = ({ embedded = false }) => {
|
||||
const consolePage = useConsolePage();
|
||||
@@ -213,6 +214,20 @@ const Recharge = ({ embedded = false }) => {
|
||||
}
|
||||
|
||||
setPayWay(payment);
|
||||
if (payment !== 'paypal') {
|
||||
// A PayPal quote stores the USD amount in the shared `amount` state.
|
||||
// Restore the selected tier's CNY amount before showing another method.
|
||||
setPayPalQuote(null);
|
||||
if (selectedPresetObj) {
|
||||
setAmount(
|
||||
calculatePresetPayableAmount(
|
||||
selectedPresetObj,
|
||||
priceRatio,
|
||||
topupInfo,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
setPaymentLoading(true);
|
||||
try {
|
||||
// 如果选择了预设档位,已经在 selectPresetAmount 中计算好了金额(包含折扣和汇率),不需要重新获取
|
||||
@@ -229,7 +244,7 @@ const Recharge = ({ embedded = false }) => {
|
||||
|
||||
const selectedMinimum = payment === 'paypal' ? payPalMinTopUp : minTopUp;
|
||||
if (topUpCount < selectedMinimum) {
|
||||
showError(t('充值数量不能小于') + selectedMinimum);
|
||||
showError(t('充值数量不能小于 {{n}}', { n: selectedMinimum }));
|
||||
return;
|
||||
}
|
||||
setOpen(true);
|
||||
@@ -259,7 +274,7 @@ const Recharge = ({ embedded = false }) => {
|
||||
|
||||
const selectedMinimum = payWay === 'paypal' ? payPalMinTopUp : minTopUp;
|
||||
if (topUpCount < selectedMinimum) {
|
||||
showError('充值数量不能小于' + selectedMinimum);
|
||||
showError(t('充值数量不能小于 {{n}}', { n: selectedMinimum }));
|
||||
return;
|
||||
}
|
||||
setConfirmLoading(true);
|
||||
@@ -613,7 +628,10 @@ const Recharge = ({ embedded = false }) => {
|
||||
setAmount(parseFloat(data));
|
||||
} else {
|
||||
setAmount(0);
|
||||
Toast.error({ content: '错误:' + data, id: 'getAmount' });
|
||||
Toast.error({
|
||||
content: t('错误:{{msg}}', { msg: data }),
|
||||
id: 'getAmount',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
showError(res);
|
||||
@@ -640,7 +658,10 @@ const Recharge = ({ embedded = false }) => {
|
||||
setAmount(parseFloat(data));
|
||||
} else {
|
||||
setAmount(0);
|
||||
Toast.error({ content: '错误:' + data, id: 'getAmount' });
|
||||
Toast.error({
|
||||
content: t('错误:{{msg}}', { msg: data }),
|
||||
id: 'getAmount',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
showError(res);
|
||||
@@ -657,17 +678,8 @@ const Recharge = ({ embedded = false }) => {
|
||||
setTopUpCount(preset.value);
|
||||
setSelectedPreset(preset.value);
|
||||
setSelectedPresetObj(preset); // 保存完整的预设对象
|
||||
const discount = preset.discount || topupInfo.discount[preset.value] || 1.0;
|
||||
|
||||
// 计算实付金额(人民币)
|
||||
// 新版档位(有 id 字段):amount 已经是人民币金额,直接乘以折扣
|
||||
// 旧版档位或自定义金额:需要乘以汇率
|
||||
const isNewVersion = preset.id !== undefined;
|
||||
const discountedAmount = isNewVersion
|
||||
? preset.value * discount // 新版:人民币金额 * 折扣
|
||||
: preset.value * priceRatio * discount; // 旧版:额度 * 汇率 * 折扣
|
||||
|
||||
setAmount(discountedAmount);
|
||||
setPayPalQuote(null);
|
||||
setAmount(calculatePresetPayableAmount(preset, priceRatio, topupInfo));
|
||||
};
|
||||
|
||||
// 生成预设充值额度
|
||||
|
||||
@@ -47,7 +47,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { API, showError } from '../../helpers';
|
||||
|
||||
const GroupMonitorAdmin = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [groups, setGroups] = useState([]);
|
||||
const [overview, setOverview] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -151,7 +151,7 @@ const GroupMonitorAdmin = () => {
|
||||
const formatTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
const date = new Date(timestamp * 1000);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
return date.toLocaleString(i18n.language, {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
@@ -166,9 +166,9 @@ const GroupMonitorAdmin = () => {
|
||||
const diff = now - timestamp;
|
||||
|
||||
if (diff < 60) return t('刚刚');
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)} ${t('分钟前')}`;
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)} ${t('小时前')}`;
|
||||
return `${Math.floor(diff / 86400)} ${t('天前')}`;
|
||||
if (diff < 3600) return t('{{n}} 分钟前', { n: Math.floor(diff / 60) });
|
||||
if (diff < 86400) return t('{{n}} 小时前', { n: Math.floor(diff / 3600) });
|
||||
return t('{{n}} 天前', { n: Math.floor(diff / 86400) });
|
||||
};
|
||||
|
||||
// 获取健康度颜色
|
||||
|
||||
@@ -421,6 +421,7 @@ export default function SettingsChats(props) {
|
||||
total,
|
||||
start: range[0],
|
||||
end: range[1],
|
||||
count: total,
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -178,11 +178,11 @@ const SettingsAPIInfo = ({ options, refresh }) => {
|
||||
setShowApiModal(false);
|
||||
showSuccess(
|
||||
editingApi
|
||||
? 'API信息已更新,请及时点击“保存设置”进行保存'
|
||||
: 'API信息已添加,请及时点击“保存设置”进行保存',
|
||||
? t('API信息已更新,请及时点击“保存设置”进行保存')
|
||||
: t('API信息已添加,请及时点击“保存设置”进行保存'),
|
||||
);
|
||||
} catch (error) {
|
||||
showError('操作失败: ' + error.message);
|
||||
showError(t('操作失败') + ': ' + error.message);
|
||||
} finally {
|
||||
setModalLoading(false);
|
||||
}
|
||||
@@ -309,7 +309,10 @@ const SettingsAPIInfo = ({ options, refresh }) => {
|
||||
setApiInfoList(newList);
|
||||
setSelectedRowKeys([]);
|
||||
setHasChanges(true);
|
||||
showSuccess(`已删除 ${selectedRowKeys.length} 个API信息,请及时点击“保存设置”进行保存`,
|
||||
showSuccess(
|
||||
t('已删除 {{n}} 个API信息,请及时点击“保存设置”进行保存', {
|
||||
n: selectedRowKeys.length,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -302,11 +302,11 @@ const SettingsAnnouncements = ({ options, refresh }) => {
|
||||
setShowAnnouncementModal(false);
|
||||
showSuccess(
|
||||
editingAnnouncement
|
||||
? '公告已更新,请及时点击“保存设置”进行保存'
|
||||
: '公告已添加,请及时点击“保存设置”进行保存',
|
||||
? t('公告已更新,请及时点击“保存设置”进行保存')
|
||||
: t('公告已添加,请及时点击“保存设置”进行保存'),
|
||||
);
|
||||
} catch (error) {
|
||||
showError('操作失败: ' + error.message);
|
||||
showError(t('操作失败') + ': ' + error.message);
|
||||
} finally {
|
||||
setModalLoading(false);
|
||||
}
|
||||
@@ -381,7 +381,10 @@ const SettingsAnnouncements = ({ options, refresh }) => {
|
||||
setAnnouncementsList(newList);
|
||||
setSelectedRowKeys([]);
|
||||
setHasChanges(true);
|
||||
showSuccess(`已删除 ${selectedRowKeys.length} 个系统公告,请及时点击“保存设置”进行保存`,
|
||||
showSuccess(
|
||||
t('已删除 {{n}} 个系统公告,请及时点击“保存设置”进行保存', {
|
||||
n: selectedRowKeys.length,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -223,11 +223,11 @@ const SettingsFAQ = ({ options, refresh }) => {
|
||||
setShowFaqModal(false);
|
||||
showSuccess(
|
||||
editingFaq
|
||||
? '问答已更新,请及时点击“保存设置”进行保存'
|
||||
: '问答已添加,请及时点击“保存设置”进行保存',
|
||||
? t('问答已更新,请及时点击“保存设置”进行保存')
|
||||
: t('问答已添加,请及时点击“保存设置”进行保存'),
|
||||
);
|
||||
} catch (error) {
|
||||
showError('操作失败: ' + error.message);
|
||||
showError(t('操作失败') + ': ' + error.message);
|
||||
} finally {
|
||||
setModalLoading(false);
|
||||
}
|
||||
@@ -300,7 +300,10 @@ const SettingsFAQ = ({ options, refresh }) => {
|
||||
setFaqList(newList);
|
||||
setSelectedRowKeys([]);
|
||||
setHasChanges(true);
|
||||
showSuccess(`已删除 ${selectedRowKeys.length} 个常见问答,请及时点击“保存设置”进行保存`,
|
||||
showSuccess(
|
||||
t('已删除 {{n}} 个常见问答,请及时点击“保存设置”进行保存', {
|
||||
n: selectedRowKeys.length,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -245,11 +245,11 @@ const SettingsUptimeKuma = ({ options, refresh }) => {
|
||||
setShowUptimeModal(false);
|
||||
showSuccess(
|
||||
editingGroup
|
||||
? '分类已更新,请及时点击“保存设置”进行保存'
|
||||
: '分类已添加,请及时点击“保存设置”进行保存',
|
||||
? t('分类已更新,请及时点击“保存设置”进行保存')
|
||||
: t('分类已添加,请及时点击“保存设置”进行保存'),
|
||||
);
|
||||
} catch (error) {
|
||||
showError('操作失败: ' + error.message);
|
||||
showError(t('操作失败') + ': ' + error.message);
|
||||
} finally {
|
||||
setModalLoading(false);
|
||||
}
|
||||
@@ -322,7 +322,11 @@ const SettingsUptimeKuma = ({ options, refresh }) => {
|
||||
setUptimeGroupsList(newList);
|
||||
setSelectedRowKeys([]);
|
||||
setHasChanges(true);
|
||||
showSuccess(`已删除 ${selectedRowKeys.length} 个分类,请及时点击“保存设置”进行保存`,
|
||||
showSuccess(
|
||||
t('已删除 {{n}} 个分类,请及时点击“保存设置”进行保存', {
|
||||
n: selectedRowKeys.length,
|
||||
count: selectedRowKeys.length,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ export default function SettingClaudeModel(props) {
|
||||
'claude.thinking_adapter_budget_tokens_percentage': 0.8,
|
||||
'claude.cache_creation_5m_ratio': 1.25,
|
||||
'claude.cache_creation_1h_ratio': 2,
|
||||
'claude.cache_ttl_override': 'off',
|
||||
});
|
||||
const refForm = useRef();
|
||||
const [inputsRow, setInputsRow] = useState(inputs);
|
||||
@@ -229,7 +230,7 @@ export default function SettingClaudeModel(props) {
|
||||
field={'claude.cache_creation_5m_ratio'}
|
||||
initValue={''}
|
||||
extraText={t(
|
||||
'仅作用于 Claude 模型,相对输入价格的倍率;未区分时长的缓存创建也按此倍率计费',
|
||||
'当前未生效:Claude 模型的全部缓存创建均按 1 小时缓存创建倍率计费',
|
||||
)}
|
||||
min={0}
|
||||
step={0.05}
|
||||
@@ -246,7 +247,9 @@ export default function SettingClaudeModel(props) {
|
||||
label={t('1小时缓存创建倍率')}
|
||||
field={'claude.cache_creation_1h_ratio'}
|
||||
initValue={''}
|
||||
extraText={t('仅作用于 Claude 模型,相对输入价格的倍率')}
|
||||
extraText={t(
|
||||
'仅作用于 Claude 模型,相对输入价格的倍率;5 分钟及未区分时长的缓存创建也统一按此倍率计费',
|
||||
)}
|
||||
min={0}
|
||||
step={0.05}
|
||||
onChange={(value) =>
|
||||
@@ -257,6 +260,27 @@ export default function SettingClaudeModel(props) {
|
||||
}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} sm={12} md={8} lg={8} xl={8}>
|
||||
<Form.Select
|
||||
label={t('缓存时长强制改写')}
|
||||
field={'claude.cache_ttl_override'}
|
||||
style={{ width: '100%' }}
|
||||
optionList={[
|
||||
{ label: t('不改写(跟随客户端)'), value: 'off' },
|
||||
{ label: t('强制 1 小时'), value: '1h' },
|
||||
{ label: t('强制 5 分钟'), value: '5m' },
|
||||
]}
|
||||
extraText={t(
|
||||
'改的是出境请求体,不是计费:会把请求里所有 cache_control 断点的 ttl 统一改写,包括客户端自己写死的值。透传模式(全局透传 / 渠道透传 / 仅 Claude Code 客户端)下不生效。',
|
||||
)}
|
||||
onChange={(value) =>
|
||||
setInputs({
|
||||
...inputs,
|
||||
'claude.cache_ttl_override': value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
|
||||
@@ -224,9 +224,7 @@ export default function SettingGeminiModel(props) {
|
||||
<Col span={16}>
|
||||
<Text>
|
||||
{t(
|
||||
'和Claude不同,默认情况下Gemini的思考模型会自动决定要不要思考,就算不开启适配模型也可以正常使用,' +
|
||||
'如果您需要计费,推荐设置无后缀模型价格按思考价格设置。' +
|
||||
'支持使用 gemini-2.5-pro-preview-06-05-thinking-128 格式来精确传递思考预算。',
|
||||
'和Claude不同,默认情况下Gemini的思考模型会自动决定要不要思考,就算不开启适配模型也可以正常使用,如果您需要计费,推荐设置无后缀模型价格按思考价格设置。支持使用 gemini-2.5-pro-preview-06-05-thinking-128 格式来精确传递思考预算。',
|
||||
)}
|
||||
</Text>
|
||||
</Col>
|
||||
|
||||
@@ -328,7 +328,10 @@ export default function SettingImagePricing({ options, refresh }) {
|
||||
<Space wrap>
|
||||
{(tiers || []).map((tier) => (
|
||||
<Tag key={tier.key} color='blue'>
|
||||
{`${tier.label || tier.key}: $${tier.price_per_image}/张`}
|
||||
{t('{{label}}: ${{price}}/张', {
|
||||
label: tier.label || tier.key,
|
||||
price: tier.price_per_image,
|
||||
})}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
@@ -455,7 +458,7 @@ export default function SettingImagePricing({ options, refresh }) {
|
||||
>
|
||||
{RESOLUTION_RULE_OPTIONS.map((option) => (
|
||||
<Form.Select.Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
{t(option.label)}
|
||||
</Form.Select.Option>
|
||||
))}
|
||||
</Form.Select>
|
||||
|
||||
@@ -330,7 +330,7 @@ export default function SettingVideoModel(props) {
|
||||
key: 'tier_param',
|
||||
render: (text) => {
|
||||
const opt = TIER_PARAM_OPTIONS.find((o) => o.value === text);
|
||||
return opt ? opt.label : text || 'resolution';
|
||||
return opt ? t(opt.label) : text || 'resolution';
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -401,7 +401,7 @@ export default function SettingVideoModel(props) {
|
||||
key: 'provider',
|
||||
render: (text) => {
|
||||
const provider = PROVIDER_OPTIONS.find((p) => p.value === text);
|
||||
return provider ? provider.label : text;
|
||||
return provider ? t(provider.label) : text;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -410,7 +410,7 @@ export default function SettingVideoModel(props) {
|
||||
key: 'channel_type',
|
||||
render: (text) => {
|
||||
const channel = VIDEO_CHANNEL_TYPES.find((c) => c.value === text);
|
||||
return channel ? channel.label : text;
|
||||
return channel ? t(channel.label) : text;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -697,7 +697,7 @@ export default function SettingVideoModel(props) {
|
||||
>
|
||||
{PROVIDER_OPTIONS.map((option) => (
|
||||
<Form.Select.Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
{t(option.label)}
|
||||
</Form.Select.Option>
|
||||
))}
|
||||
</Form.Select>
|
||||
@@ -710,7 +710,7 @@ export default function SettingVideoModel(props) {
|
||||
>
|
||||
{VIDEO_CHANNEL_TYPES.map((option) => (
|
||||
<Form.Select.Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
{t(option.label)}
|
||||
</Form.Select.Option>
|
||||
))}
|
||||
</Form.Select>
|
||||
@@ -768,7 +768,7 @@ export default function SettingVideoModel(props) {
|
||||
>
|
||||
{TIER_PARAM_OPTIONS.map((option) => (
|
||||
<Form.Select.Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
{t(option.label)}
|
||||
</Form.Select.Option>
|
||||
))}
|
||||
</Form.Select>
|
||||
|
||||
@@ -44,8 +44,9 @@ import {
|
||||
Archive,
|
||||
Database,
|
||||
HardDrive,
|
||||
Clapperboard,
|
||||
} from 'lucide-react';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
import { API, renderQuota, showError, showSuccess } from '../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
@@ -116,6 +117,12 @@ export default function SettingsExperienceCenter({ options, refresh }) {
|
||||
const [enableImageGen, setEnableImageGen] = useState(false);
|
||||
const [imageGenModels, setImageGenModels] = useState('dall-e-3,gpt-image-1');
|
||||
const [defaultImageSize, setDefaultImageSize] = useState('1024x1024');
|
||||
// 新创作台(图像 / 视频生成)灰度开关与单用户进行中任务上限(<=0 不限制)
|
||||
const [creationV2Enabled, setCreationV2Enabled] = useState(false);
|
||||
const [maxRunningImageTasks, setMaxRunningImageTasks] = useState(4);
|
||||
const [maxRunningVideoTasks, setMaxRunningVideoTasks] = useState(3);
|
||||
// 多张 / 对比生成合计额度超过该值时二次确认(quota,<=0 不确认;默认 ≈ ¥2)
|
||||
const [batchConfirmThreshold, setBatchConfirmThreshold] = useState(136986);
|
||||
|
||||
// 存储治理:归档 / 分区 / 列表缓存(默认全部关闭,灰度上线)
|
||||
const [archiveEnabled, setArchiveEnabled] = useState(false);
|
||||
@@ -188,6 +195,20 @@ export default function SettingsExperienceCenter({ options, refresh }) {
|
||||
setDefaultImageSize(
|
||||
options.ExperienceCenterDefaultImageSize || '1024x1024',
|
||||
);
|
||||
setCreationV2Enabled(options.ExperienceCreationV2Enabled === 'true');
|
||||
const parseLimit = (raw, fallback) => {
|
||||
const n = parseInt(raw, 10);
|
||||
return Number.isFinite(n) ? n : fallback;
|
||||
};
|
||||
setMaxRunningImageTasks(
|
||||
parseLimit(options.ExperienceCenterMaxRunningImageTasks, 4),
|
||||
);
|
||||
setMaxRunningVideoTasks(
|
||||
parseLimit(options.ExperienceCenterMaxRunningVideoTasks, 3),
|
||||
);
|
||||
setBatchConfirmThreshold(
|
||||
parseLimit(options.ExperienceCenterBatchConfirmThreshold, 136986),
|
||||
);
|
||||
|
||||
setArchiveEnabled(options.ExperienceCenterArchiveEnabled === 'true');
|
||||
setArchiveAfterDays(
|
||||
@@ -312,6 +333,23 @@ export default function SettingsExperienceCenter({ options, refresh }) {
|
||||
},
|
||||
{ key: 'ExperienceCenterImageGenModels', value: imageGenModels },
|
||||
{ key: 'ExperienceCenterDefaultImageSize', value: defaultImageSize },
|
||||
// 新创作台
|
||||
{
|
||||
key: 'ExperienceCreationV2Enabled',
|
||||
value: String(creationV2Enabled),
|
||||
},
|
||||
{
|
||||
key: 'ExperienceCenterMaxRunningImageTasks',
|
||||
value: String(Math.trunc(Number(maxRunningImageTasks) || 0)),
|
||||
},
|
||||
{
|
||||
key: 'ExperienceCenterMaxRunningVideoTasks',
|
||||
value: String(Math.trunc(Number(maxRunningVideoTasks) || 0)),
|
||||
},
|
||||
{
|
||||
key: 'ExperienceCenterBatchConfirmThreshold',
|
||||
value: String(Math.trunc(Number(batchConfirmThreshold) || 0)),
|
||||
},
|
||||
// 存储治理
|
||||
{
|
||||
key: 'ExperienceCenterArchiveEnabled',
|
||||
@@ -653,7 +691,10 @@ export default function SettingsExperienceCenter({ options, refresh }) {
|
||||
const known = new Set(allGroups.map((g) => g.value));
|
||||
const extras = selectedAllowedGroups
|
||||
.filter((v) => !known.has(v))
|
||||
.map((v) => ({ value: v, label: `${v} (${t('已不存在')})` }));
|
||||
.map((v) => ({
|
||||
value: v,
|
||||
label: t('{{value}} (已不存在)', { value: v }),
|
||||
}));
|
||||
return [...allGroups, ...extras];
|
||||
})()}
|
||||
maxTagCount={20}
|
||||
@@ -878,6 +919,73 @@ export default function SettingsExperienceCenter({ options, refresh }) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SwitchRow
|
||||
icon={<Clapperboard size={16} className='text-brand' />}
|
||||
title={t('启用新版创作台(图像 / 视频生成)')}
|
||||
description={t(
|
||||
'开启后体验中心的图像生成、视频生成使用新版创作台;关闭时保持旧页面',
|
||||
)}
|
||||
checked={creationV2Enabled}
|
||||
onChange={setCreationV2Enabled}
|
||||
/>
|
||||
<div className='ml-11 mb-3 p-3 bg-gray-50 dark:bg-neutral-800 rounded-lg space-y-3'>
|
||||
<div>
|
||||
<Text strong size='small' className='block mb-1'>
|
||||
{t('单用户进行中图像任务上限')}
|
||||
</Text>
|
||||
<InputNumber
|
||||
value={maxRunningImageTasks}
|
||||
onChange={(v) => setMaxRunningImageTasks(v ?? 0)}
|
||||
min={0}
|
||||
max={100}
|
||||
precision={0}
|
||||
style={{ width: 120 }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Text strong size='small' className='block mb-1'>
|
||||
{t('单用户进行中视频任务上限')}
|
||||
</Text>
|
||||
<InputNumber
|
||||
value={maxRunningVideoTasks}
|
||||
onChange={(v) => setMaxRunningVideoTasks(v ?? 0)}
|
||||
min={0}
|
||||
max={100}
|
||||
precision={0}
|
||||
style={{ width: 120 }}
|
||||
/>
|
||||
</div>
|
||||
<Text type='tertiary' size='small' className='block'>
|
||||
{t('0 表示不限制;达到上限后新的生成请求会被拒绝,直到有任务完成')}
|
||||
</Text>
|
||||
<div>
|
||||
<Text strong size='small' className='block mb-1'>
|
||||
{t('多张 / 对比生成二次确认阈值(额度)')}
|
||||
</Text>
|
||||
<div className='flex flex-wrap items-center gap-2'>
|
||||
<InputNumber
|
||||
value={batchConfirmThreshold}
|
||||
onChange={(v) => setBatchConfirmThreshold(v ?? 0)}
|
||||
min={0}
|
||||
precision={0}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
{Number(batchConfirmThreshold) > 0 ? (
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('约 {{amount}}', {
|
||||
amount: renderQuota(Number(batchConfirmThreshold)),
|
||||
})}
|
||||
</Text>
|
||||
) : null}
|
||||
</div>
|
||||
<Text type='tertiary' size='small' className='block mt-1'>
|
||||
{t(
|
||||
'新版创作台一次生成多张或对比生成时,合计估价超过该额度需用户二次确认;0 表示不确认',
|
||||
)}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* 存储治理:归档 / 分区 / 列表缓存 */}
|
||||
|
||||
@@ -179,12 +179,14 @@ export default function GeneralSettings(props) {
|
||||
try {
|
||||
const res = await API.post('/api/option/test_cos');
|
||||
if (res.data.success) {
|
||||
showSuccess(res.data.message || 'COS连接测试成功');
|
||||
showSuccess(res.data.message || t('COS连接测试成功'));
|
||||
} else {
|
||||
showError(res.data.message || 'COS连接测试失败');
|
||||
showError(res.data.message || t('COS连接测试失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
showError('COS连接测试失败: ' + (error.message || '未知错误'));
|
||||
showError(
|
||||
t('COS连接测试失败') + ': ' + (error.message || t('未知错误')),
|
||||
);
|
||||
} finally {
|
||||
setTestingCos(false);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export default function SettingsLog(props) {
|
||||
{daysDiff > 0 && (
|
||||
<Text type='tertiary'>
|
||||
{' '}
|
||||
({t('约')} {daysDiff} {t('天前')})
|
||||
({t('约 {{n}} 天前', { n: daysDiff, count: daysDiff })})
|
||||
</Text>
|
||||
)}
|
||||
</p>
|
||||
@@ -141,7 +141,7 @@ export default function SettingsLog(props) {
|
||||
{daysDiff > 0 && (
|
||||
<Text style={{ color: '#8c8c8c' }}>
|
||||
{' '}
|
||||
({t('约')} {daysDiff} {t('天前')})
|
||||
({t('约 {{n}} 天前', { n: daysDiff, count: daysDiff })})
|
||||
</Text>
|
||||
)}
|
||||
<Text style={{ color: '#333' }}> {t('之前的所有日志')}</Text>
|
||||
@@ -164,7 +164,7 @@ export default function SettingsLog(props) {
|
||||
);
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
showSuccess(`${data} ${t('条日志已清理!')}`);
|
||||
showSuccess(t('{{n}} 条日志已清理!', { n: data, count: data }));
|
||||
return;
|
||||
} else {
|
||||
throw new Error(t('日志清理失败:') + message);
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18next from 'i18next';
|
||||
import { colord } from 'colord';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
@@ -1317,7 +1318,7 @@ function TokenRow({ label, desc, value, isCustom, onChange, onReset }) {
|
||||
|
||||
/** 透明度 tooltip 文案(避免在子组件再取 t,用纯函数生成) */
|
||||
function t_alpha(pct) {
|
||||
return `透明度 ${pct}%`;
|
||||
return i18next.t('透明度 {{value}}%', { value: pct });
|
||||
}
|
||||
|
||||
/* ============= 迷你预览 =============
|
||||
|
||||
@@ -139,7 +139,7 @@ export default function SettingsMembership() {
|
||||
}
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(plan.id ? '更新成功' : '创建成功');
|
||||
showSuccess(plan.id ? t('更新成功') : t('创建成功'));
|
||||
setEditModalVisible(false);
|
||||
setEditingPlan(null);
|
||||
fetchPlans();
|
||||
@@ -192,7 +192,7 @@ export default function SettingsMembership() {
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
title: '方案名称',
|
||||
title: t('方案名称'),
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: (text, record) => (
|
||||
@@ -208,57 +208,57 @@ export default function SettingsMembership() {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
title: t('类型'),
|
||||
dataIndex: 'plan_type',
|
||||
key: 'plan_type',
|
||||
render: (v) => {
|
||||
const map = { weekly: '周卡', monthly: '月卡', quarterly: '季卡' };
|
||||
return <Tag>{map[v] || v}</Tag>;
|
||||
return <Tag>{map[v] ? t(map[v]) : v}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '档位',
|
||||
title: t('档位'),
|
||||
dataIndex: 'tier',
|
||||
key: 'tier',
|
||||
render: (v) => {
|
||||
const map = { lite: '轻度', pro: '重度' };
|
||||
const color = v === 'pro' ? 'red' : 'blue';
|
||||
return <Tag color={color}>{map[v] || v}</Tag>;
|
||||
return <Tag color={color}>{map[v] ? t(map[v]) : v}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '天数',
|
||||
title: t('天数'),
|
||||
dataIndex: 'duration_days',
|
||||
key: 'duration_days',
|
||||
render: (v) => `${v} 天`,
|
||||
render: (v) => t('{{days}} 天', { days: v }),
|
||||
},
|
||||
{
|
||||
title: '价格',
|
||||
title: t('价格'),
|
||||
dataIndex: 'price',
|
||||
key: 'price',
|
||||
render: (v) => <Text strong>¥{v}</Text>,
|
||||
},
|
||||
{
|
||||
title: '每日额度',
|
||||
title: t('每日额度'),
|
||||
dataIndex: 'daily_quota',
|
||||
key: 'daily_quota',
|
||||
render: (v) => <Text type='success'>{renderQuota(v)}</Text>,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: t('状态'),
|
||||
dataIndex: 'is_enabled',
|
||||
key: 'is_enabled',
|
||||
render: (v) => (
|
||||
<Tag color={v ? 'green' : 'grey'}>{v ? '启用' : '禁用'}</Tag>
|
||||
<Tag color={v ? 'green' : 'grey'}>{v ? t('启用') : t('禁用')}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
title: t('排序'),
|
||||
dataIndex: 'sort',
|
||||
key: 'sort',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('操作'),
|
||||
key: 'action',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
@@ -455,7 +455,10 @@ export default function SettingsMembership() {
|
||||
onChange={(v) =>
|
||||
setEditingPlan({ ...editingPlan, plan_type: v })
|
||||
}
|
||||
optionList={planTypeOptions}
|
||||
optionList={planTypeOptions.map((o) => ({
|
||||
...o,
|
||||
label: t(o.label),
|
||||
}))}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
@@ -467,7 +470,10 @@ export default function SettingsMembership() {
|
||||
<Select
|
||||
value={editingPlan.tier}
|
||||
onChange={(v) => setEditingPlan({ ...editingPlan, tier: v })}
|
||||
optionList={tierOptions}
|
||||
optionList={tierOptions.map((o) => ({
|
||||
...o,
|
||||
label: t(o.label),
|
||||
}))}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -83,7 +83,12 @@ const SettingsPaymentAlipay = ({ options, refresh }) => {
|
||||
for (const config of configs) {
|
||||
const res = await API.put('/api/option/', config);
|
||||
if (!res.data.success) {
|
||||
throw new Error(`保存 ${config.key} 失败: ${res.data.message}`);
|
||||
throw new Error(
|
||||
t('保存 {{key}} 失败:{{message}}', {
|
||||
key: config.key,
|
||||
message: res.data.message,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,12 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
if (!response.data.success)
|
||||
throw new Error(response.data.message || t('查询失败'));
|
||||
const data = response.data.data;
|
||||
showSuccess(`${tradeNo}:PayPal 状态 ${data.remote_status}`);
|
||||
showSuccess(
|
||||
t('{{tradeNo}}:PayPal 状态 {{status}}', {
|
||||
tradeNo,
|
||||
status: data.remote_status,
|
||||
}),
|
||||
);
|
||||
setSelectedOperationOrderKeys((keys) =>
|
||||
keys.filter((key) => key !== String(tradeNo)),
|
||||
);
|
||||
@@ -366,7 +371,12 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
(item) => !item.success,
|
||||
);
|
||||
showSuccess(
|
||||
`批量${operation === 'inspect' ? '查询' : '对账'}完成:成功 ${data.succeeded || 0} 笔,失败 ${data.failed || 0} 笔`,
|
||||
t(
|
||||
operation === 'inspect'
|
||||
? t('批量查询完成:成功 {{succeeded}} 笔,失败 {{failed}} 笔')
|
||||
: '批量对账完成:成功 {{succeeded}} 笔,失败 {{failed}} 笔',
|
||||
{ succeeded: data.succeeded || 0, failed: data.failed || 0 },
|
||||
),
|
||||
);
|
||||
if (failedResults.length > 0) {
|
||||
showError(
|
||||
@@ -396,8 +406,8 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
setBatchForceConfirmed(false);
|
||||
setBatchExpireReason(
|
||||
force
|
||||
? '管理员确认远端状态无法核验,强制关闭所选 PayPal 订单'
|
||||
: '确认所选 PayPal 订单均未完成支付',
|
||||
? t('管理员确认远端状态无法核验,强制关闭所选 PayPal 订单')
|
||||
: t('确认所选 PayPal 订单均未完成支付'),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -430,7 +440,12 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
(item) => !item.success,
|
||||
);
|
||||
showSuccess(
|
||||
`批量${batchExpire.force ? '强制' : ''}过期完成:成功 ${data.succeeded || 0} 笔,失败 ${data.failed || 0} 笔`,
|
||||
t(
|
||||
batchExpire.force
|
||||
? t('批量强制过期完成:成功 {{succeeded}} 笔,失败 {{failed}} 笔')
|
||||
: '批量过期完成:成功 {{succeeded}} 笔,失败 {{failed}} 笔',
|
||||
{ succeeded: data.succeeded || 0, failed: data.failed || 0 },
|
||||
),
|
||||
);
|
||||
if (failedResults.length > 0) {
|
||||
showError(
|
||||
@@ -565,17 +580,17 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
|
||||
const operationColumns = useMemo(
|
||||
() => [
|
||||
{ title: '本地订单号', dataIndex: 'trade_no' },
|
||||
{ title: t('本地订单号'), dataIndex: 'trade_no' },
|
||||
{ title: 'PayPal Order ID', dataIndex: 'third_trade_no' },
|
||||
{ title: '环境', dataIndex: 'payment_environment' },
|
||||
{ title: t('环境'), dataIndex: 'payment_environment' },
|
||||
{
|
||||
title: '创建时间',
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'create_time',
|
||||
render: (value) =>
|
||||
value ? new Date(value * 1000).toLocaleString() : '-',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('操作'),
|
||||
render: (_, row) => (
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
<Button
|
||||
@@ -583,7 +598,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
htmlType='button'
|
||||
onClick={() => inspectOperationOrder(row.trade_no)}
|
||||
>
|
||||
查询远端状态
|
||||
{t('查询远端状态')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -592,7 +607,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
onClick={() => reconcileOperationOrder(row.trade_no)}
|
||||
disabled={!row.third_trade_no}
|
||||
>
|
||||
触发对账
|
||||
{t('触发对账')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -602,10 +617,10 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
setExpireOrder(row);
|
||||
setForceExpire(false);
|
||||
setForceExpireConfirmed(false);
|
||||
setExpireReason('确认该订单未完成 PayPal 支付');
|
||||
setExpireReason(t('确认该订单未完成 PayPal 支付'));
|
||||
}}
|
||||
>
|
||||
确认未付款并过期
|
||||
{t('确认未付款并过期')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -616,17 +631,17 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
setForceExpire(true);
|
||||
setForceExpireConfirmed(false);
|
||||
setExpireReason(
|
||||
'管理员确认远端状态无法核验,强制关闭该 PayPal 订单',
|
||||
t('管理员确认远端状态无法核验,强制关闭该 PayPal 订单'),
|
||||
);
|
||||
}}
|
||||
>
|
||||
强制过期
|
||||
{t('强制过期')}
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
],
|
||||
[inspectOperationOrder, reconcileOperationOrder],
|
||||
[t, inspectOperationOrder, reconcileOperationOrder],
|
||||
);
|
||||
|
||||
const webhookBase = props.options?.ServerAddress
|
||||
@@ -664,7 +679,9 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
<Form.Section text={t('PayPal 设置')}>
|
||||
<Banner
|
||||
type='info'
|
||||
description={`${t('Webhook 地址')}:${webhookBase}/api/paypal/webhook`}
|
||||
description={t('Webhook 地址:{{url}}', {
|
||||
url: `${webhookBase}/api/paypal/webhook`,
|
||||
})}
|
||||
/>
|
||||
{isRoot() && (
|
||||
<>
|
||||
@@ -731,12 +748,13 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
type={operations?.pending_count ? 'warning' : 'success'}
|
||||
description={
|
||||
operations
|
||||
? `配置切换预检:${operations.pending_count || 0} 笔 PayPal pending 订单;${
|
||||
? t(
|
||||
operations.can_change_config
|
||||
? '可以切换环境或应用配置'
|
||||
: '请先隐藏新订单并完成历史订单排空'
|
||||
}`
|
||||
: '正在读取 PayPal 配置切换预检状态'
|
||||
? t('配置切换预检:{{n}} 笔 PayPal pending 订单;可以切换环境或应用配置')
|
||||
: '配置切换预检:{{n}} 笔 PayPal pending 订单;请先隐藏新订单并完成历史订单排空',
|
||||
{ n: operations.pending_count || 0 },
|
||||
)
|
||||
: t('正在读取 PayPal 配置切换预检状态')
|
||||
}
|
||||
style={{ marginTop: 16 }}
|
||||
/>
|
||||
@@ -746,7 +764,9 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
style={{ marginTop: 12 }}
|
||||
>
|
||||
<Text type='tertiary'>
|
||||
已选 {selectedOperationOrderKeys.length} 笔
|
||||
{t('已选 {{n}} 笔', {
|
||||
n: selectedOperationOrderKeys.length,
|
||||
})}
|
||||
</Text>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -754,7 +774,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
disabled={selectedOperationOrderKeys.length === 0}
|
||||
onClick={() => runBatchOperation('inspect')}
|
||||
>
|
||||
批量查询远端状态
|
||||
{t('批量查询远端状态')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -763,7 +783,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
disabled={selectedOperationOrderKeys.length === 0}
|
||||
onClick={() => runBatchOperation('reconcile')}
|
||||
>
|
||||
批量触发对账
|
||||
{t('批量触发对账')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -772,7 +792,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
disabled={selectedOperationOrderKeys.length === 0}
|
||||
onClick={() => openBatchExpire(false)}
|
||||
>
|
||||
批量确认过期
|
||||
{t('批量确认过期')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
@@ -781,7 +801,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
disabled={selectedOperationOrderKeys.length === 0}
|
||||
onClick={() => openBatchExpire(true)}
|
||||
>
|
||||
批量强制过期
|
||||
{t('批量强制过期')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -824,7 +844,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
onClick={() => refreshOperations(operationsPage)}
|
||||
style={{ marginTop: 12 }}
|
||||
>
|
||||
刷新配置切换预检
|
||||
{t('刷新配置切换预检')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
@@ -909,7 +929,9 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
type={fxStatus?.latest_valid ? 'success' : 'warning'}
|
||||
description={
|
||||
fxStatus?.latest_valid
|
||||
? `${t('当前市场汇率')}:1 USD = ${fxStatus.latest_valid.market_rate} CNY`
|
||||
? t('当前市场汇率:1 USD = {{rate}} CNY', {
|
||||
rate: fxStatus.latest_valid.market_rate,
|
||||
})
|
||||
: t('暂无可用的市场汇率快照')
|
||||
}
|
||||
style={{ marginTop: 16 }}
|
||||
@@ -929,25 +951,25 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
</Form>
|
||||
<Modal
|
||||
title={
|
||||
forceExpire ? '确认强制过期 PayPal 订单' : '确认 PayPal 订单过期'
|
||||
forceExpire ? t('确认强制过期 PayPal 订单') : t('确认 PayPal 订单过期')
|
||||
}
|
||||
visible={Boolean(expireOrder)}
|
||||
onCancel={() => setExpireOrder(null)}
|
||||
onOk={expireOperationOrder}
|
||||
okText='确认过期'
|
||||
cancelText='取消'
|
||||
okText={t('确认过期')}
|
||||
cancelText={t('取消')}
|
||||
>
|
||||
{expireOrder && (
|
||||
<div className='space-y-3'>
|
||||
<Text>
|
||||
订单:<strong>{expireOrder.trade_no}</strong>
|
||||
{t('订单')}:<strong>{expireOrder.trade_no}</strong>
|
||||
</Text>
|
||||
<Banner
|
||||
type={forceExpire ? 'danger' : 'warning'}
|
||||
description={
|
||||
forceExpire
|
||||
? '强制过期会绕过远端查询失败或仍可支付状态,可能导致 PayPal 后续付款无法入账。已确认完成支付的订单仍会被拒绝。'
|
||||
: '系统会再次查询 PayPal 远端状态;如果已完成支付,将拒绝过期操作。请确认未付款后再提交。'
|
||||
? t('强制过期会绕过远端查询失败或仍可支付状态,可能导致 PayPal 后续付款无法入账。已确认完成支付的订单仍会被拒绝。')
|
||||
: t('系统会再次查询 PayPal 远端状态;如果已完成支付,将拒绝过期操作。请确认未付款后再提交。')
|
||||
}
|
||||
/>
|
||||
{forceExpire && (
|
||||
@@ -959,7 +981,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
)
|
||||
}
|
||||
>
|
||||
我确认已核对 PayPal 后台或业务记录,同意强制关闭该订单
|
||||
{t('我确认已核对 PayPal 后台或业务记录,同意强制关闭该订单')}
|
||||
</Checkbox>
|
||||
)}
|
||||
<TextArea
|
||||
@@ -972,7 +994,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
)
|
||||
}
|
||||
rows={3}
|
||||
placeholder='填写处置原因,至少 6 个字符'
|
||||
placeholder={t('填写处置原因,至少 6 个字符')}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -980,24 +1002,28 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
<Modal
|
||||
title={
|
||||
batchExpire?.force
|
||||
? '确认批量强制过期 PayPal 订单'
|
||||
: '确认批量 PayPal 订单过期'
|
||||
? t('确认批量强制过期 PayPal 订单')
|
||||
: t('确认批量 PayPal 订单过期')
|
||||
}
|
||||
visible={Boolean(batchExpire)}
|
||||
onCancel={() => setBatchExpire(null)}
|
||||
onOk={confirmBatchExpire}
|
||||
okText='确认批量过期'
|
||||
cancelText='取消'
|
||||
okText={t('确认批量过期')}
|
||||
cancelText={t('取消')}
|
||||
>
|
||||
{batchExpire && (
|
||||
<div className='space-y-3'>
|
||||
<Text>已选择 {batchExpire.tradeNos.length} 笔 PayPal 订单。</Text>
|
||||
<Text>
|
||||
{t('已选择 {{n}} 笔 PayPal 订单。', {
|
||||
n: batchExpire.tradeNos.length,
|
||||
})}
|
||||
</Text>
|
||||
<Banner
|
||||
type={batchExpire.force ? 'danger' : 'warning'}
|
||||
description={
|
||||
batchExpire.force
|
||||
? '批量强制过期会绕过远端查询失败或仍可支付状态;已确认完成支付的订单仍会逐笔拒绝。'
|
||||
: '系统会逐笔查询 PayPal 远端状态,已完成或仍可支付的订单会逐笔失败并返回原因。'
|
||||
? t('批量强制过期会绕过远端查询失败或仍可支付状态;已确认完成支付的订单仍会逐笔拒绝。')
|
||||
: t('系统会逐笔查询 PayPal 远端状态,已完成或仍可支付的订单会逐笔失败并返回原因。')
|
||||
}
|
||||
/>
|
||||
{batchExpire.force && (
|
||||
@@ -1009,7 +1035,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
)
|
||||
}
|
||||
>
|
||||
我确认已核对所选订单,同意批量强制关闭
|
||||
{t('我确认已核对所选订单,同意批量强制关闭')}
|
||||
</Checkbox>
|
||||
)}
|
||||
<TextArea
|
||||
@@ -1022,7 +1048,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
|
||||
)
|
||||
}
|
||||
rows={3}
|
||||
placeholder='填写处置原因,至少 6 个字符'
|
||||
placeholder={t('填写处置原因,至少 6 个字符')}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -167,7 +167,7 @@ export default function SettingsPaymentGateway(props) {
|
||||
>
|
||||
<Form.Section text={t('Stripe 设置')}>
|
||||
<Text>
|
||||
Stripe 密钥、Webhook 等设置请
|
||||
{t('Stripe 密钥、Webhook 等设置请')}
|
||||
<a
|
||||
href='https://dashboard.stripe.com/developers'
|
||||
target='_blank'
|
||||
@@ -180,11 +180,15 @@ export default function SettingsPaymentGateway(props) {
|
||||
</Text>
|
||||
<Banner
|
||||
type='info'
|
||||
description={`Webhook 填:${props.options.ServerAddress ? removeTrailingSlash(props.options.ServerAddress) : t('网站地址')}/api/stripe/webhook`}
|
||||
description={t('Webhook 填:{{url}}', {
|
||||
url: `${props.options.ServerAddress ? removeTrailingSlash(props.options.ServerAddress) : t('网站地址')}/api/stripe/webhook`,
|
||||
})}
|
||||
/>
|
||||
<Banner
|
||||
type='warning'
|
||||
description={`需要包含事件:checkout.session.completed 和 checkout.session.expired`}
|
||||
description={t(
|
||||
'需要包含事件:checkout.session.completed 和 checkout.session.expired',
|
||||
)}
|
||||
/>
|
||||
<Row gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}>
|
||||
<Col xs={24} sm={24} md={8} lg={8} xl={8}>
|
||||
|
||||
@@ -109,7 +109,12 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
for (const config of configs) {
|
||||
const res = await API.put('/api/option/', config);
|
||||
if (!res.data.success) {
|
||||
throw new Error(`保存 ${config.key} 失败: ${res.data.message}`);
|
||||
throw new Error(
|
||||
t('保存 {{key}} 失败:{{message}}', {
|
||||
key: config.key,
|
||||
message: res.data.message,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,13 +131,13 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
<>
|
||||
<Title heading={5}>{t('微信支付配置')}</Title>
|
||||
<Text type='tertiary'>
|
||||
配置微信支付 Native(扫码)和 H5 支付方式。请前往{' '}
|
||||
{t('配置微信支付 Native(扫码)和 H5 支付方式。请前往')}{' '}
|
||||
<a
|
||||
href='https://pay.weixin.qq.com'
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
>{t('微信支付商户平台')}</a>{' '}
|
||||
获取相关配置信息。
|
||||
{t('获取相关配置信息。')}
|
||||
</Text>
|
||||
|
||||
<Divider margin='12px' />
|
||||
@@ -183,14 +188,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
field='WechatMchId'
|
||||
label={t('商户号 (Mch ID)')}
|
||||
placeholder={t('请输入微信支付商户号')}
|
||||
rules={[{ required: true, message: '请输入商户号' }]}
|
||||
rules={[{ required: true, message: t('请输入商户号') }]}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='WechatAppId'
|
||||
label={t('应用 ID (App ID)')}
|
||||
placeholder={t('请输入微信应用 ID')}
|
||||
rules={[{ required: true, message: '请输入应用 ID' }]}
|
||||
rules={[{ required: true, message: t('请输入应用 ID') }]}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
@@ -198,13 +203,13 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
label={t('APIv3 密钥')}
|
||||
placeholder={
|
||||
options.WechatAPIv3Key === '***ALREADY_SET***'
|
||||
? '已设置(留空不修改,填写新内容则更新)'
|
||||
: '请输入 APIv3 密钥'
|
||||
? t('已设置(留空不修改,填写新内容则更新)')
|
||||
: t('请输入 APIv3 密钥')
|
||||
}
|
||||
mode='password'
|
||||
extraText={
|
||||
options.WechatAPIv3Key === '***ALREADY_SET***'
|
||||
? '✓ 已配置 APIv3 密钥(留空则保持不变)'
|
||||
? t('✓ 已配置 APIv3 密钥(留空则保持不变)')
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
@@ -213,7 +218,7 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
field='WechatSerialNo'
|
||||
label={t('证书序列号')}
|
||||
placeholder={t('请输入证书序列号')}
|
||||
rules={[{ required: true, message: '请输入证书序列号' }]}
|
||||
rules={[{ required: true, message: t('请输入证书序列号') }]}
|
||||
/>
|
||||
|
||||
<Form.TextArea
|
||||
@@ -221,14 +226,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
label={t('商户私钥')}
|
||||
placeholder={
|
||||
options.WechatPrivateKey === '***ALREADY_SET***'
|
||||
? '已设置(留空不修改,填写新内容则更新)'
|
||||
: '请粘贴完整的 PEM 格式私钥内容(包含 -----BEGIN PRIVATE KEY----- 等)'
|
||||
? t('已设置(留空不修改,填写新内容则更新)')
|
||||
: t('请粘贴完整的 PEM 格式私钥内容(包含 -----BEGIN PRIVATE KEY----- 等)')
|
||||
}
|
||||
rows={6}
|
||||
extraText={
|
||||
options.WechatPrivateKey === '***ALREADY_SET***'
|
||||
? '✓ 已配置商户私钥(留空则保持不变)'
|
||||
: '支持直接粘贴 PEM 格式内容或填写文件路径'
|
||||
? t('✓ 已配置商户私钥(留空则保持不变)')
|
||||
: t('支持直接粘贴 PEM 格式内容或填写文件路径')
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -236,21 +241,22 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
|
||||
<Title heading={6} style={{ marginTop: 16, marginBottom: 8 }}>{t('公钥模式(2024年新商户必选)')}</Title>
|
||||
<Text type='tertiary' style={{ display: 'block', marginBottom: 12 }}>
|
||||
2024年后注册的微信支付商户默认使用公钥模式。如果初始化失败提示"无可用的平台证书",
|
||||
请从商户平台下载微信支付公钥并启用此模式。
|
||||
{t(
|
||||
'2024年后注册的微信支付商户默认使用公钥模式。如果初始化失败提示"无可用的平台证书",请从商户平台下载微信支付公钥并启用此模式。',
|
||||
)}
|
||||
</Text>
|
||||
|
||||
<Form.Switch
|
||||
field='WechatUsePublicKey'
|
||||
label={t('启用公钥模式')}
|
||||
extraText='2024年新商户必须开启此选项'
|
||||
extraText={t('2024年新商户必须开启此选项')}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='WechatPublicKeyID'
|
||||
label={t('微信支付公钥 ID')}
|
||||
placeholder='PUB_KEY_ID_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
extraText='从商户平台【API安全】→【微信支付公钥】获取,格式如 PUB_KEY_ID_xxx'
|
||||
extraText={t('从商户平台【API安全】→【微信支付公钥】获取,格式如 PUB_KEY_ID_xxx')}
|
||||
/>
|
||||
|
||||
<Form.TextArea
|
||||
@@ -258,14 +264,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
label={t('微信支付公钥内容')}
|
||||
placeholder={
|
||||
options.WechatPublicKeyPEM === '***ALREADY_SET***'
|
||||
? '已设置(留空不修改,填写新内容则更新)'
|
||||
: '请粘贴完整的微信支付公钥 PEM 内容(包含 -----BEGIN PUBLIC KEY----- 等)'
|
||||
? t('已设置(留空不修改,填写新内容则更新)')
|
||||
: t('请粘贴完整的微信支付公钥 PEM 内容(包含 -----BEGIN PUBLIC KEY----- 等)')
|
||||
}
|
||||
rows={6}
|
||||
extraText={
|
||||
options.WechatPublicKeyPEM === '***ALREADY_SET***'
|
||||
? '✓ 已配置微信支付公钥(留空则保持不变)'
|
||||
: '从商户平台下载的公钥文件内容'
|
||||
? t('✓ 已配置微信支付公钥(留空则保持不变)')
|
||||
: t('从商户平台下载的公钥文件内容')
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -277,14 +283,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
<Form.Switch
|
||||
field='WechatUseManualCert'
|
||||
label={t('启用手动证书模式')}
|
||||
extraText='开启后需要手动配置平台证书,关闭则使用自动下载模式(推荐)'
|
||||
extraText={t('开启后需要手动配置平台证书,关闭则使用自动下载模式(推荐)')}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='WechatPlatformCertPath'
|
||||
label={t('平台证书文件路径')}
|
||||
placeholder='/data/certs/wechatpay_platform_cert.pem'
|
||||
extraText='平台证书文件的绝对路径(与下方 PEM 内容二选一)'
|
||||
extraText={t('平台证书文件的绝对路径(与下方 PEM 内容二选一)')}
|
||||
/>
|
||||
|
||||
<Form.TextArea
|
||||
@@ -292,14 +298,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
label={t('平台证书 PEM 内容')}
|
||||
placeholder={
|
||||
options.WechatPlatformCertPEM === '***ALREADY_SET***'
|
||||
? '已设置(留空不修改,填写新内容则更新)'
|
||||
: '请粘贴完整的平台证书 PEM 内容(包含 -----BEGIN CERTIFICATE----- 等)'
|
||||
? t('已设置(留空不修改,填写新内容则更新)')
|
||||
: t('请粘贴完整的平台证书 PEM 内容(包含 -----BEGIN CERTIFICATE----- 等)')
|
||||
}
|
||||
rows={6}
|
||||
extraText={
|
||||
options.WechatPlatformCertPEM === '***ALREADY_SET***'
|
||||
? '✓ 已配置平台证书(留空则保持不变)'
|
||||
: '与上方文件路径二选一,优先使用文件路径'
|
||||
? t('✓ 已配置平台证书(留空则保持不变)')
|
||||
: t('与上方文件路径二选一,优先使用文件路径')
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -308,13 +314,13 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
<Form.Switch
|
||||
field='WechatNativeEnabled'
|
||||
label={t('启用 Native 扫码支付')}
|
||||
extraText='用户扫描二维码完成支付'
|
||||
extraText={t('用户扫描二维码完成支付')}
|
||||
/>
|
||||
|
||||
<Form.Switch
|
||||
field='WechatH5Enabled'
|
||||
label={t('启用 H5 支付')}
|
||||
extraText='在手机浏览器中唤起微信支付'
|
||||
extraText={t('在手机浏览器中唤起微信支付')}
|
||||
/>
|
||||
|
||||
<Divider margin='12px' />
|
||||
@@ -323,14 +329,14 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
field='WechatNotifyUrl'
|
||||
label={t('回调通知 URL')}
|
||||
placeholder={t('留空则使用默认地址')}
|
||||
extraText='默认: {服务器地址}/api/wechat/notify'
|
||||
extraText={t('默认: {服务器地址}/api/wechat/notify')}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='WechatDescription'
|
||||
label={t('商品描述')}
|
||||
placeholder={t('平台充值')}
|
||||
extraText='显示在微信支付界面的商品描述'
|
||||
extraText={t('显示在微信支付界面的商品描述')}
|
||||
/>
|
||||
|
||||
<Form.InputNumber
|
||||
@@ -338,7 +344,7 @@ const SettingsPaymentWechat = ({ options, refresh }) => {
|
||||
label={t('订单过期时间(分钟)')}
|
||||
min={1}
|
||||
max={1440}
|
||||
extraText='订单未支付的有效时间,默认 30 分钟'
|
||||
extraText={t('订单未支付的有效时间,默认 30 分钟')}
|
||||
/>
|
||||
|
||||
<Space style={{ marginTop: 20 }}>
|
||||
|
||||
@@ -1044,7 +1044,7 @@ export default function ModelCostSettings() {
|
||||
prefix='¥'
|
||||
suffix={
|
||||
<span className='text-xs text-gray-400'>
|
||||
{meta.suffix} {t(meta.label)}
|
||||
{t(meta.suffix)} {t(meta.label)}
|
||||
{tier ? ` · ${tier}` : ''}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) => setInputs({ ...inputs, ModelPrice: value })}
|
||||
@@ -174,7 +174,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) => setInputs({ ...inputs, ModelRatio: value })}
|
||||
@@ -193,7 +193,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) => setInputs({ ...inputs, CacheRatio: value })}
|
||||
@@ -213,7 +213,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) =>
|
||||
@@ -239,7 +239,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) => setInputs({ ...inputs, ImageRatio: value })}
|
||||
@@ -261,7 +261,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) => setInputs({ ...inputs, AudioRatio: value })}
|
||||
@@ -285,7 +285,7 @@ export default function ModelRatioSettings(props) {
|
||||
rules={[
|
||||
{
|
||||
validator: (rule, value) => verifyJSON(value),
|
||||
message: '不是合法的 JSON 字符串',
|
||||
message: t('不是合法的 JSON 字符串'),
|
||||
},
|
||||
]}
|
||||
onChange={(value) =>
|
||||
|
||||
@@ -593,8 +593,10 @@ export default function ModelRatioNotSetEditor(props) {
|
||||
)}
|
||||
|
||||
<Text type='tertiary'>
|
||||
{t('将为选中的 ')} <Text strong>{selectedRowKeys.length}</Text>{' '}
|
||||
{t(' 个模型设置相同的值')}
|
||||
{t('将为选中的 {{n}} 个模型设置相同的值', {
|
||||
n: selectedRowKeys.length,
|
||||
count: selectedRowKeys.length,
|
||||
})}
|
||||
</Text>
|
||||
<div style={{ marginTop: '8px' }}>
|
||||
<Text type='tertiary'>
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// 系统设置 →「WeyAi」配置分组(方案 M8)。只对超级管理员展示;
|
||||
// 系统设置 →「WeyAi」页签 →「账号接入」子页签(方案 M8;M21 起从「系统设置」页签搬到这里)。只对超级管理员展示;
|
||||
// 这些 key 在后端登记为 root-only(setting/console_setting/admin_delegation.go)。
|
||||
//
|
||||
// 分区:网页端接入(总开关/地址/凭证)→ 开放范围(模式 + 黑名单)→
|
||||
@@ -591,10 +591,16 @@ export default function SettingsWeyAi() {
|
||||
// 都在这里判,否则只能等保存时才拿到后端的报错。?/# 看原文而不是解析结果:
|
||||
// 末尾一个裸 # 解析出来 hash 是空串,却会让回调地址变成 /#/sso/callback
|
||||
if (Array.from(value).length > 400) {
|
||||
return `${label}:${t('地址不能超过 400 个字符')}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label,
|
||||
message: t('地址不能超过 400 个字符'),
|
||||
});
|
||||
}
|
||||
if (/[?#]/.test(value)) {
|
||||
return `${label}:${t('地址不能带查询参数(?)或锚点(#)')}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label,
|
||||
message: t('地址不能带查询参数(?)或锚点(#)'),
|
||||
});
|
||||
}
|
||||
let parsed = null;
|
||||
try {
|
||||
@@ -608,14 +614,25 @@ export default function SettingsWeyAi() {
|
||||
!parsed.host ||
|
||||
!/^https?:\/\//i.test(value)
|
||||
) {
|
||||
return `${label}:${t('地址必须以 http:// 或 https:// 开头')}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label,
|
||||
message: t('地址必须以 http:// 或 https:// 开头'),
|
||||
});
|
||||
}
|
||||
if (parsed.username || parsed.password) {
|
||||
return `${label}:${t('地址不能带用户名或密码')}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label,
|
||||
message: t('地址不能带用户名或密码'),
|
||||
});
|
||||
}
|
||||
// 更新源只接受 https:安装包链接随它以同样的协议发布(后端同样会拒)
|
||||
if (key === 'WeyAiReleaseBaseUrl' && parsed.protocol !== 'https:') {
|
||||
return `${label}:${t('更新源地址必须使用 https://,安装包链接会以同样的协议发布')}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label,
|
||||
message: t(
|
||||
'更新源地址必须使用 https://,安装包链接会以同样的协议发布',
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
// 「全部用户」下开放名单是隐藏的,但切换模式前改过的名单仍会提交:校验不过时
|
||||
@@ -631,7 +648,10 @@ export default function SettingsWeyAi() {
|
||||
'WeyAiWebAccessUsers',
|
||||
]) {
|
||||
if (isIdList(values[key])) continue;
|
||||
const message = `${t(KEY_LABELS[key])}:${t('只能填写正整数 ID')}`;
|
||||
const message = t('{{label}}:{{message}}', {
|
||||
label: t(KEY_LABELS[key]),
|
||||
message: t('只能填写正整数 ID'),
|
||||
});
|
||||
return key === 'WeyAiWebDenyUsers' ? message : hiddenHint(message);
|
||||
}
|
||||
// 指定范围但四项全空 = 除黑名单外没有任何人能用,保存后全站用户的 WeyAi
|
||||
@@ -654,14 +674,24 @@ export default function SettingsWeyAi() {
|
||||
// 存量值里可能有后端校验出现前写入的 auto;/api/group/ 会把 auto 也列出来,
|
||||
// 所以不能只看它在不在分组列表里
|
||||
if (values[key].includes('auto')) {
|
||||
return hiddenHint(`${t(card)}:${t('开放分组不能包含 auto')}`);
|
||||
return hiddenHint(
|
||||
t('{{label}}:{{message}}', {
|
||||
label: t(card),
|
||||
message: t('开放分组不能包含 auto'),
|
||||
}),
|
||||
);
|
||||
}
|
||||
const unknown = values[key].find(
|
||||
(group) => !groupOptions.some((opt) => opt.value === group),
|
||||
);
|
||||
if (unknown) {
|
||||
return hiddenHint(
|
||||
`${t(card)}:${t('开放分组 {{group}} 未在分组倍率中配置', { group: unknown })}`,
|
||||
t('{{label}}:{{message}}', {
|
||||
label: t(card),
|
||||
message: t('开放分组 {{group}} 未在分组倍率中配置', {
|
||||
group: unknown,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -680,7 +710,10 @@ export default function SettingsWeyAi() {
|
||||
group !== (original[key] || '').trim() &&
|
||||
!groupOptions.some((opt) => opt.value === group)
|
||||
) {
|
||||
return `${t(card)}:${t('密钥默认分组 {{group}} 未在分组倍率中配置', { group })}`;
|
||||
return t('{{label}}:{{message}}', {
|
||||
label: t(card),
|
||||
message: t('密钥默认分组 {{group}} 未在分组倍率中配置', { group }),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 系统设置 →「WeyAi」→「内容管理」(M21):管理 WeyAi 客户端展示的内容,
|
||||
// 比如首页短剧作品墙。内容位(展示在哪、有哪些字段)在后端代码里登记;
|
||||
// 这里增删改条目、上下架、排序,改完客户端下次刷新就能看到,不用发版。
|
||||
// root 和被下放了「WeyAi」页签的管理员都能用。
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Banner,
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Table,
|
||||
Tag,
|
||||
TagInput,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
import SettingsWeyAiContentEditor from './SettingsWeyAiContentEditor';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
const PREVIEW_USERS_KEY = 'WeyAiContentPreviewUsers';
|
||||
const DEFAULT_LOCALES = ['zh-CN', 'en-US'];
|
||||
|
||||
const STATUS_TAGS = {
|
||||
draft: { color: 'grey', label: '草稿' },
|
||||
published: { color: 'green', label: '已发布' },
|
||||
offline: { color: 'orange', label: '已下架' },
|
||||
};
|
||||
|
||||
const formatTime = (sec) => (sec ? new Date(sec * 1000).toLocaleString() : '');
|
||||
|
||||
const SettingsWeyAiContent = () => {
|
||||
const { t } = useTranslation();
|
||||
const [overview, setOverview] = useState(null);
|
||||
const [slotId, setSlotId] = useState('');
|
||||
const [items, setItems] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [busyId, setBusyId] = useState(0);
|
||||
const [editor, setEditor] = useState({ visible: false, item: null });
|
||||
const [previewUsers, setPreviewUsers] = useState([]);
|
||||
const [savedPreviewUsers, setSavedPreviewUsers] = useState([]);
|
||||
const [savingPreview, setSavingPreview] = useState(false);
|
||||
|
||||
const slot = overview?.slots?.find((s) => s.id === slotId);
|
||||
|
||||
const loadOverview = useCallback(async () => {
|
||||
const res = await API.get('/api/admin/weyai/content/overview', {
|
||||
skipErrorHandler: true,
|
||||
});
|
||||
if (!res?.data?.success) {
|
||||
throw new Error(res?.data?.message || t('加载失败,请重试'));
|
||||
}
|
||||
setOverview(res.data.data);
|
||||
setSlotId((current) => current || res.data.data.slots?.[0]?.id || '');
|
||||
}, [t]);
|
||||
|
||||
const loadPreviewUsers = useCallback(async () => {
|
||||
const res = await API.get('/api/option/', { skipErrorHandler: true });
|
||||
const entry = (res?.data?.data || []).find(
|
||||
(o) => o.key === PREVIEW_USERS_KEY,
|
||||
);
|
||||
const list = (entry?.value || '')
|
||||
.split(/[,\s]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
setPreviewUsers(list);
|
||||
setSavedPreviewUsers(list);
|
||||
}, []);
|
||||
|
||||
const loadItems = useCallback(
|
||||
async (id) => {
|
||||
if (!id) return;
|
||||
const res = await API.get('/api/admin/weyai/content/items', {
|
||||
params: { slot: id },
|
||||
skipErrorHandler: true,
|
||||
});
|
||||
if (!res?.data?.success) {
|
||||
throw new Error(res?.data?.message || t('加载失败,请重试'));
|
||||
}
|
||||
setItems(res.data.data || []);
|
||||
},
|
||||
[t],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
Promise.all([loadOverview(), loadPreviewUsers()])
|
||||
.catch((e) => showError(e.message))
|
||||
.finally(() => setLoading(false));
|
||||
}, [loadOverview, loadPreviewUsers]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!slotId) return;
|
||||
setLoading(true);
|
||||
loadItems(slotId)
|
||||
.catch((e) => showError(e.message))
|
||||
.finally(() => setLoading(false));
|
||||
}, [slotId, loadItems]);
|
||||
|
||||
const refresh = () =>
|
||||
Promise.all([loadItems(slotId), loadOverview()]).catch((e) =>
|
||||
showError(e.message),
|
||||
);
|
||||
|
||||
const call = async (id, request) => {
|
||||
setBusyId(id);
|
||||
try {
|
||||
const res = await request();
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('操作失败,请重试'));
|
||||
return false;
|
||||
}
|
||||
await refresh();
|
||||
return true;
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('操作失败,请重试'));
|
||||
return false;
|
||||
} finally {
|
||||
setBusyId(0);
|
||||
}
|
||||
};
|
||||
|
||||
const setStatus = (item, status) =>
|
||||
call(item.id, () =>
|
||||
API.post(
|
||||
`/api/admin/weyai/content/items/${item.id}/status`,
|
||||
{ status },
|
||||
{ skipErrorHandler: true },
|
||||
),
|
||||
).then((ok) => ok && showSuccess(t('已更新')));
|
||||
|
||||
const remove = (item) =>
|
||||
call(item.id, () =>
|
||||
API.delete(`/api/admin/weyai/content/items/${item.id}`, {
|
||||
skipErrorHandler: true,
|
||||
}),
|
||||
).then((ok) => ok && showSuccess(t('已删除')));
|
||||
|
||||
const move = (index, delta) => {
|
||||
const ids = items.map((it) => it.id);
|
||||
const target = index + delta;
|
||||
if (target < 0 || target >= ids.length) return;
|
||||
[ids[index], ids[target]] = [ids[target], ids[index]];
|
||||
call(items[index].id, () =>
|
||||
API.post(
|
||||
'/api/admin/weyai/content/sort',
|
||||
{ slot: slotId, ids },
|
||||
{ skipErrorHandler: true },
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const savePreviewUsers = async () => {
|
||||
setSavingPreview(true);
|
||||
try {
|
||||
const res = await API.put(
|
||||
'/api/option/',
|
||||
{ key: PREVIEW_USERS_KEY, value: previewUsers.join(',') },
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('保存失败,请重试'));
|
||||
return;
|
||||
}
|
||||
setSavedPreviewUsers(previewUsers);
|
||||
showSuccess(t('保存成功'));
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('保存失败,请重试'));
|
||||
} finally {
|
||||
setSavingPreview(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('封面'),
|
||||
width: 80,
|
||||
render: (_, item) =>
|
||||
item.media?.poster?.preview_url ? (
|
||||
<img
|
||||
src={item.media.poster.preview_url}
|
||||
alt=''
|
||||
style={{
|
||||
width: 45,
|
||||
height: 80,
|
||||
objectFit: 'cover',
|
||||
borderRadius: 4,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Text type='tertiary'>—</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('标题'),
|
||||
render: (_, item) => (
|
||||
<div>
|
||||
<Text strong>{item.texts?.['zh-CN']?.title || t('(未填写)')}</Text>
|
||||
{item.fields?.hero === true && (
|
||||
<Tag size='small' color='blue' className='ml-2'>
|
||||
{t('首屏')}
|
||||
</Tag>
|
||||
)}
|
||||
<div>
|
||||
<Text type='tertiary' size='small'>
|
||||
ID {item.id} · rev {item.rev}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
width: 100,
|
||||
render: (_, item) => {
|
||||
const tag = STATUS_TAGS[item.status] || STATUS_TAGS.draft;
|
||||
return <Tag color={tag.color}>{t(tag.label)}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('适用端'),
|
||||
width: 110,
|
||||
render: (_, item) => (item.platforms || []).join('、') || '—',
|
||||
},
|
||||
{
|
||||
title: t('上下架时间'),
|
||||
width: 190,
|
||||
render: (_, item) =>
|
||||
item.start_at || item.end_at ? (
|
||||
<Text size='small'>
|
||||
{formatTime(item.start_at) || t('不限')}
|
||||
<br />~ {formatTime(item.end_at) || t('不限')}
|
||||
</Text>
|
||||
) : (
|
||||
<Text type='tertiary'>{t('不限')}</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
render: (_, item, index) => (
|
||||
<Space wrap>
|
||||
<Button
|
||||
size='small'
|
||||
onClick={() => setEditor({ visible: true, item })}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{item.status === 'published' ? (
|
||||
<Button
|
||||
size='small'
|
||||
loading={busyId === item.id}
|
||||
onClick={() => setStatus(item, 'offline')}
|
||||
>
|
||||
{t('下架')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
loading={busyId === item.id}
|
||||
onClick={() => setStatus(item, 'published')}
|
||||
>
|
||||
{t('发布')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
disabled={index === 0}
|
||||
aria-label={t('上移')}
|
||||
onClick={() => move(index, -1)}
|
||||
>
|
||||
↑
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
disabled={index === items.length - 1}
|
||||
aria-label={t('下移')}
|
||||
onClick={() => move(index, 1)}
|
||||
>
|
||||
↓
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title={t('确定删除这个条目?')}
|
||||
content={t('删除后客户端不再显示;它的文件 7 天后清理')}
|
||||
onConfirm={() => remove(item)}
|
||||
>
|
||||
<Button size='small' type='danger' theme='borderless'>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const previewDirty = previewUsers.join(',') !== savedPreviewUsers.join(',');
|
||||
|
||||
return (
|
||||
<Spin spinning={loading}>
|
||||
<Card className='mb-3'>
|
||||
<Banner
|
||||
type='warning'
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={t(
|
||||
'素材规则:作品必须由我方用中转上的模型生成并有权使用;含真人肖像要有授权;不用未授权的音乐;片内带 AI 生成标识。上传和发布的管理员对内容负责。签名地址 6 小时内可被转发,不要上传不能公开的内容',
|
||||
)}
|
||||
/>
|
||||
{overview && !overview.storage_configured && (
|
||||
<Banner
|
||||
type='danger'
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={t(
|
||||
'内容存储桶还没有配置,暂时不能上传,客户端也不会收到任何内容。请超级管理员在「WeyAi → 内容存储」里配置',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<div className='flex flex-wrap items-center gap-3 mb-2'>
|
||||
<Text strong>{t('内容位')}</Text>
|
||||
<Select
|
||||
value={slotId}
|
||||
onChange={setSlotId}
|
||||
style={{ minWidth: 260 }}
|
||||
optionList={(overview?.slots || []).map((s) => ({
|
||||
value: s.id,
|
||||
label: `${t(s.name)}(${s.item_count})`,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
{slot && (
|
||||
<Text type='tertiary' size='small'>
|
||||
{t(slot.description)} ·{' '}
|
||||
{t('最多 {{count}} 条', { count: slot.max_items })}
|
||||
</Text>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card className='mb-3'>
|
||||
<Title heading={6} className='mb-1'>
|
||||
{t('预览名单')}
|
||||
</Title>
|
||||
<Text type='tertiary' size='small' className='block mb-2'>
|
||||
{t(
|
||||
'名单里的用户在 WeyAi 客户端里还能看到草稿,用来发布前在真实客户端里检查。填用户 ID',
|
||||
)}
|
||||
</Text>
|
||||
<div className='flex flex-wrap gap-2 items-center'>
|
||||
<TagInput
|
||||
value={previewUsers}
|
||||
onChange={setPreviewUsers}
|
||||
placeholder={t('回车添加')}
|
||||
style={{ minWidth: 320, flex: 1 }}
|
||||
/>
|
||||
<Button
|
||||
loading={savingPreview}
|
||||
disabled={!previewDirty}
|
||||
onClick={savePreviewUsers}
|
||||
>
|
||||
{t('保存')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<div className='flex justify-between items-center mb-3'>
|
||||
<Title heading={6}>{t('条目')}</Title>
|
||||
<Button
|
||||
type='primary'
|
||||
disabled={!slot || !overview?.storage_configured}
|
||||
onClick={() => setEditor({ visible: true, item: null })}
|
||||
>
|
||||
{t('新建条目')}
|
||||
</Button>
|
||||
</div>
|
||||
{items.length === 0 ? (
|
||||
<Empty description={t('还没有条目')} />
|
||||
) : (
|
||||
<Table
|
||||
rowKey='id'
|
||||
columns={columns}
|
||||
dataSource={items}
|
||||
pagination={false}
|
||||
size='small'
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<SettingsWeyAiContentEditor
|
||||
visible={editor.visible}
|
||||
slot={slot}
|
||||
item={editor.item}
|
||||
locales={overview?.locales || DEFAULT_LOCALES}
|
||||
onClose={() => setEditor({ visible: false, item: null })}
|
||||
onSaved={() => {
|
||||
setEditor({ visible: false, item: null });
|
||||
refresh();
|
||||
}}
|
||||
/>
|
||||
</Spin>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsWeyAiContent;
|
||||
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 「WeyAi → 内容管理」的条目编辑(M21)。表单完全按后端的内容位定义生成:
|
||||
// 每种语言一组文字、结构化字段、每个文件位一个上传框、适用端、版本、上下架时间、
|
||||
// 可见范围。保存只存草稿或原状态;发布在列表里单独点。
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
Banner,
|
||||
Button,
|
||||
CheckboxGroup,
|
||||
DatePicker,
|
||||
Input,
|
||||
InputNumber,
|
||||
Progress,
|
||||
Select,
|
||||
SideSheet,
|
||||
Space,
|
||||
Switch,
|
||||
TabPane,
|
||||
Tabs,
|
||||
TagInput,
|
||||
TextArea,
|
||||
Typography,
|
||||
Upload,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
import { formatBytes, uploadContentFile } from './contentUpload';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
const emptyForm = (locales) => ({
|
||||
texts: Object.fromEntries(locales.map((l) => [l, {}])),
|
||||
fields: {},
|
||||
media: {},
|
||||
platforms: [],
|
||||
min_app_version: '',
|
||||
max_app_version: '',
|
||||
start_at: 0,
|
||||
end_at: 0,
|
||||
audience: { groups: [], orgs: [], org_groups: [] },
|
||||
});
|
||||
|
||||
const formFromItem = (item, locales, slot) => {
|
||||
const base = emptyForm(locales);
|
||||
if (!item) {
|
||||
// A slot shown on one platform only: preselect it, like the server does.
|
||||
return slot?.platforms?.length === 1
|
||||
? { ...base, platforms: [...slot.platforms] }
|
||||
: base;
|
||||
}
|
||||
return {
|
||||
...base,
|
||||
texts: { ...base.texts, ...(item.texts || {}) },
|
||||
fields: { ...(item.fields || {}) },
|
||||
media: { ...(item.media || {}) },
|
||||
platforms: item.platforms || [],
|
||||
min_app_version: item.min_app_version || '',
|
||||
max_app_version: item.max_app_version || '',
|
||||
start_at: item.start_at || 0,
|
||||
end_at: item.end_at || 0,
|
||||
audience: {
|
||||
groups: item.audience?.groups || [],
|
||||
orgs: item.audience?.orgs || [],
|
||||
org_groups: item.audience?.org_groups || [],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const FieldControl = ({ field, value, onChange, t }) => {
|
||||
switch (field.type) {
|
||||
case 'bool':
|
||||
return <Switch checked={value === true} onChange={onChange} />;
|
||||
case 'int':
|
||||
return (
|
||||
<InputNumber
|
||||
value={value}
|
||||
min={field.min || undefined}
|
||||
max={field.max || undefined}
|
||||
precision={0}
|
||||
onChange={(v) => onChange(v === '' || v == null ? undefined : v)}
|
||||
style={{ width: 200 }}
|
||||
/>
|
||||
);
|
||||
case 'enum':
|
||||
return (
|
||||
<Select
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
showClear
|
||||
style={{ width: 200 }}
|
||||
optionList={(field.enum || []).map((v) => ({ value: v, label: v }))}
|
||||
/>
|
||||
);
|
||||
case 'string_list':
|
||||
return (
|
||||
<TagInput
|
||||
value={value || []}
|
||||
onChange={(list) => onChange(list.length ? list : undefined)}
|
||||
maxLength={field.max_len || undefined}
|
||||
max={field.max_items || undefined}
|
||||
placeholder={t('回车添加')}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<Input
|
||||
value={value || ''}
|
||||
onChange={(v) => onChange(v || undefined)}
|
||||
maxLength={field.max_len || undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const MediaPreview = ({ role, object }) => {
|
||||
if (!object?.preview_url) return null;
|
||||
if (role.kind === 'image') {
|
||||
return (
|
||||
<img
|
||||
src={object.preview_url}
|
||||
alt=''
|
||||
style={{ maxHeight: 96, maxWidth: 160, borderRadius: 6 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (role.kind === 'video') {
|
||||
return (
|
||||
<video
|
||||
src={object.preview_url}
|
||||
controls
|
||||
muted
|
||||
preload='metadata'
|
||||
style={{ maxHeight: 120, maxWidth: 200, borderRadius: 6 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const SettingsWeyAiContentEditor = ({
|
||||
visible,
|
||||
slot,
|
||||
item,
|
||||
locales,
|
||||
onClose,
|
||||
onSaved,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [form, setForm] = useState(() => emptyForm(locales));
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [progress, setProgress] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
setForm(formFromItem(item, locales, slot));
|
||||
setProgress({});
|
||||
}
|
||||
}, [visible, item, locales, slot]);
|
||||
|
||||
if (!slot) return null;
|
||||
|
||||
const setText = (locale, key, value) =>
|
||||
setForm((f) => ({
|
||||
...f,
|
||||
texts: { ...f.texts, [locale]: { ...f.texts[locale], [key]: value } },
|
||||
}));
|
||||
const setField = (key, value) =>
|
||||
setForm((f) => {
|
||||
const fields = { ...f.fields };
|
||||
if (value === undefined) delete fields[key];
|
||||
else fields[key] = value;
|
||||
return { ...f, fields };
|
||||
});
|
||||
const set = (key, value) => setForm((f) => ({ ...f, [key]: value }));
|
||||
const setAudience = (key, value) =>
|
||||
setForm((f) => ({ ...f, audience: { ...f.audience, [key]: value } }));
|
||||
|
||||
const doUpload = async (role, file) => {
|
||||
setProgress((p) => ({ ...p, [role.key]: 0 }));
|
||||
try {
|
||||
const object = await uploadContentFile({
|
||||
slot: slot.id,
|
||||
role,
|
||||
file,
|
||||
onProgress: (n) => setProgress((p) => ({ ...p, [role.key]: n })),
|
||||
});
|
||||
setForm((f) => ({ ...f, media: { ...f.media, [role.key]: object } }));
|
||||
showSuccess(t('上传完成'));
|
||||
} catch (e) {
|
||||
showError(
|
||||
e.code === 'cors'
|
||||
? t(
|
||||
'浏览器无法直连存储桶,请超级管理员在「WeyAi → 内容存储」里测试连接并写入跨域规则',
|
||||
)
|
||||
: e.message,
|
||||
);
|
||||
} finally {
|
||||
setProgress((p) => {
|
||||
const next = { ...p };
|
||||
delete next[role.key];
|
||||
return next;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
const payload = {
|
||||
texts: form.texts,
|
||||
fields: form.fields,
|
||||
media: Object.fromEntries(
|
||||
Object.entries(form.media)
|
||||
.filter(([, v]) => v?.key)
|
||||
.map(([k, v]) => [k, v.key]),
|
||||
),
|
||||
platforms: form.platforms,
|
||||
min_app_version: form.min_app_version.trim(),
|
||||
max_app_version: form.max_app_version.trim(),
|
||||
start_at: form.start_at || 0,
|
||||
end_at: form.end_at || 0,
|
||||
audience: {
|
||||
groups: form.audience.groups,
|
||||
orgs: form.audience.orgs
|
||||
.map((v) => Number(v))
|
||||
.filter((n) => Number.isInteger(n) && n > 0),
|
||||
org_groups: form.audience.org_groups,
|
||||
},
|
||||
};
|
||||
setSaving(true);
|
||||
try {
|
||||
const res = item
|
||||
? await API.put(`/api/admin/weyai/content/items/${item.id}`, payload, {
|
||||
skipErrorHandler: true,
|
||||
})
|
||||
: await API.post(
|
||||
'/api/admin/weyai/content/items',
|
||||
{ slot: slot.id, ...payload },
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('保存失败,请重试'));
|
||||
return;
|
||||
}
|
||||
showSuccess(t('保存成功'));
|
||||
onSaved();
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('保存失败,请重试'));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const uploading = Object.keys(progress).length > 0;
|
||||
const toDate = (sec) => (sec ? new Date(sec * 1000) : undefined);
|
||||
const toSec = (d) => (d ? Math.floor(new Date(d).getTime() / 1000) : 0);
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
width={720}
|
||||
title={item ? t('编辑条目') : t('新建条目')}
|
||||
footer={
|
||||
<div className='flex justify-end gap-2'>
|
||||
<Button onClick={onClose}>{t('取消')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
loading={saving}
|
||||
disabled={uploading}
|
||||
onClick={save}
|
||||
>
|
||||
{t('保存')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{item?.status === 'published' && (
|
||||
<Banner
|
||||
type='warning'
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={t(
|
||||
'这个条目已发布,保存后客户端在下次刷新时就会看到改动;改完仍要符合发布要求',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Title heading={6} className='mb-2'>
|
||||
{t('文字')}
|
||||
</Title>
|
||||
<Tabs type='line' size='small'>
|
||||
{locales.map((locale) => (
|
||||
<TabPane itemKey={locale} tab={locale} key={locale}>
|
||||
{slot.texts.map((def) => {
|
||||
const Control = def.multi ? TextArea : Input;
|
||||
const required = def.required && locale === 'zh-CN';
|
||||
return (
|
||||
<div key={def.key} className='mb-3 mt-2'>
|
||||
<Text className='block mb-1'>
|
||||
{t(def.label)}
|
||||
{required && <Text type='danger'> *</Text>}
|
||||
</Text>
|
||||
<Control
|
||||
value={form.texts[locale]?.[def.key] || ''}
|
||||
onChange={(v) => setText(locale, def.key, v)}
|
||||
maxLength={def.max_len || undefined}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</TabPane>
|
||||
))}
|
||||
</Tabs>
|
||||
|
||||
<Title heading={6} className='mb-2 mt-4'>
|
||||
{t('字段')}
|
||||
</Title>
|
||||
{slot.fields.map((field) => (
|
||||
<div key={field.key} className='mb-3'>
|
||||
<Text className='block mb-1'>{t(field.label)}</Text>
|
||||
<FieldControl
|
||||
field={field}
|
||||
value={form.fields[field.key]}
|
||||
onChange={(v) => setField(field.key, v)}
|
||||
t={t}
|
||||
/>
|
||||
{field.max_true > 0 && (
|
||||
<Text type='tertiary' size='small' className='block'>
|
||||
{t('已发布的条目里最多 {{count}} 条打开这一项', {
|
||||
count: field.max_true,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
<Title heading={6} className='mb-2 mt-4'>
|
||||
{t('文件')}
|
||||
</Title>
|
||||
{slot.media.map((role) => {
|
||||
const object = form.media[role.key];
|
||||
const required =
|
||||
role.required ||
|
||||
(role.required_if && form.fields[role.required_if] === true);
|
||||
return (
|
||||
<div
|
||||
key={role.key}
|
||||
className='mb-4 p-3'
|
||||
style={{
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
borderRadius: 8,
|
||||
}}
|
||||
>
|
||||
<div className='flex items-center justify-between mb-2'>
|
||||
<Text strong>
|
||||
{t(role.label)}
|
||||
{required && <Text type='danger'> *</Text>}
|
||||
</Text>
|
||||
<Space>
|
||||
{object && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
onClick={() =>
|
||||
setForm((f) => {
|
||||
const media = { ...f.media };
|
||||
delete media[role.key];
|
||||
return { ...f, media };
|
||||
})
|
||||
}
|
||||
>
|
||||
{t('移除')}
|
||||
</Button>
|
||||
)}
|
||||
<Upload
|
||||
action=''
|
||||
accept={role.mime_types.join(',')}
|
||||
showUploadList={false}
|
||||
disabled={progress[role.key] !== undefined}
|
||||
beforeUpload={({ file }) => {
|
||||
const raw = file.fileInstance;
|
||||
if (raw.size > role.max_bytes) {
|
||||
showError(
|
||||
t('「{{name}}」不能超过 {{size}}', {
|
||||
name: t(role.label),
|
||||
size: formatBytes(role.max_bytes),
|
||||
}),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
doUpload(role, raw);
|
||||
return false;
|
||||
}}
|
||||
>
|
||||
<Button size='small'>{object ? t('替换') : t('上传')}</Button>
|
||||
</Upload>
|
||||
</Space>
|
||||
</div>
|
||||
<Text type='tertiary' size='small' className='block mb-2'>
|
||||
{role.mime_types.join('、')} ·{' '}
|
||||
{t('不超过 {{size}}', { size: formatBytes(role.max_bytes) })}
|
||||
{role.cacheable ? ` · ${t('客户端会缓存')}` : ''}
|
||||
</Text>
|
||||
{progress[role.key] !== undefined && (
|
||||
<Progress percent={progress[role.key]} showInfo />
|
||||
)}
|
||||
{object && (
|
||||
<div className='flex items-center gap-3'>
|
||||
<MediaPreview role={role} object={object} />
|
||||
<Text type='tertiary' size='small'>
|
||||
{formatBytes(object.size)}
|
||||
{object.width ? ` · ${object.width}×${object.height}` : ''}
|
||||
{object.duration
|
||||
? ` · ${t('{{n}} 秒', { n: Math.round(object.duration) })}`
|
||||
: ''}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
<Title heading={6} className='mb-2 mt-4'>
|
||||
{t('投放')}
|
||||
</Title>
|
||||
<div className='mb-3'>
|
||||
<Text className='block mb-1'>
|
||||
{t('适用端')}
|
||||
<Text type='danger'> *</Text>
|
||||
</Text>
|
||||
<CheckboxGroup
|
||||
direction='horizontal'
|
||||
value={form.platforms}
|
||||
onChange={(v) => set('platforms', v)}
|
||||
options={slot.platforms.map((p) => ({ value: p, label: p }))}
|
||||
/>
|
||||
</div>
|
||||
<div className='mb-3 flex gap-3 flex-wrap'>
|
||||
<div>
|
||||
<Text className='block mb-1'>{t('最低客户端版本')}</Text>
|
||||
<Input
|
||||
value={form.min_app_version}
|
||||
onChange={(v) => set('min_app_version', v)}
|
||||
placeholder='2.3.0'
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Text className='block mb-1'>{t('最高客户端版本')}</Text>
|
||||
<Input
|
||||
value={form.max_app_version}
|
||||
onChange={(v) => set('max_app_version', v)}
|
||||
placeholder='3.0.0'
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className='mb-3 flex gap-3 flex-wrap'>
|
||||
<div>
|
||||
<Text className='block mb-1'>{t('上架时间')}</Text>
|
||||
<DatePicker
|
||||
type='dateTime'
|
||||
value={toDate(form.start_at)}
|
||||
onChange={(d) => set('start_at', toSec(d))}
|
||||
placeholder={t('不限')}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Text className='block mb-1'>{t('下架时间')}</Text>
|
||||
<DatePicker
|
||||
type='dateTime'
|
||||
value={toDate(form.end_at)}
|
||||
onChange={(d) => set('end_at', toSec(d))}
|
||||
placeholder={t('不限')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<Text className='block mb-1'>{t('可见范围')}</Text>
|
||||
<Text type='tertiary' size='small' className='block mb-2'>
|
||||
{t(
|
||||
'都不填表示所有人可见。规则与网页端开放范围相同:企业账号按企业 ID 或企业分组判断,个人账号按用户分组判断',
|
||||
)}
|
||||
</Text>
|
||||
<div className='mb-2'>
|
||||
<Text size='small' className='block mb-1'>
|
||||
{t('用户分组')}
|
||||
</Text>
|
||||
<TagInput
|
||||
value={form.audience.groups}
|
||||
onChange={(v) => setAudience('groups', v)}
|
||||
placeholder={t('回车添加')}
|
||||
/>
|
||||
</div>
|
||||
<div className='mb-2'>
|
||||
<Text size='small' className='block mb-1'>
|
||||
{t('企业 ID')}
|
||||
</Text>
|
||||
<TagInput
|
||||
value={form.audience.orgs.map(String)}
|
||||
onChange={(v) => setAudience('orgs', v)}
|
||||
placeholder={t('回车添加')}
|
||||
/>
|
||||
</div>
|
||||
<div className='mb-2'>
|
||||
<Text size='small' className='block mb-1'>
|
||||
{t('企业分组')}
|
||||
</Text>
|
||||
<TagInput
|
||||
value={form.audience.org_groups}
|
||||
onChange={(v) => setAudience('org_groups', v)}
|
||||
placeholder={t('回车添加')}
|
||||
/>
|
||||
</div>
|
||||
</SideSheet>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsWeyAiContentEditor;
|
||||
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 系统设置 →「WeyAi」→「内容存储」(M21):WeyAi 展示内容(作品视频、封面、模板包)
|
||||
// 专用的 COS 桶。和系统 COS 桶分开,权限、费用、生命周期都单独管;没配置时
|
||||
// 内容功能整体关闭,不会退回系统桶。只对超级管理员显示,后端按 root-only 校验。
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Banner,
|
||||
Button,
|
||||
Card,
|
||||
Col,
|
||||
Form,
|
||||
Input,
|
||||
Row,
|
||||
Spin,
|
||||
Switch,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const MASKED_PLACEHOLDER = '***ALREADY_SET***';
|
||||
const BUCKET_KEY = 'WeyAiContentCosBucket';
|
||||
const REGION_KEY = 'WeyAiContentCosRegion';
|
||||
const SECRET_ID_KEY = 'WeyAiContentCosSecretId';
|
||||
const SECRET_KEY_KEY = 'WeyAiContentCosSecretKey';
|
||||
const USE_SYSTEM_KEY = 'WeyAiContentCosUseSystemKey';
|
||||
|
||||
const KEY_LABELS = {
|
||||
[BUCKET_KEY]: '存储桶名称',
|
||||
[REGION_KEY]: '地域',
|
||||
[SECRET_ID_KEY]: 'SecretId',
|
||||
[SECRET_KEY_KEY]: 'SecretKey',
|
||||
[USE_SYSTEM_KEY]: '沿用系统 COS 的密钥',
|
||||
};
|
||||
|
||||
const CHECK_LABELS = {
|
||||
config: '配置完整',
|
||||
bucket: '能访问存储桶',
|
||||
write: '能写入并删除对象',
|
||||
cors: '已有浏览器直传所需的跨域规则',
|
||||
};
|
||||
|
||||
const EMPTY_VALUES = {
|
||||
[BUCKET_KEY]: '',
|
||||
[REGION_KEY]: '',
|
||||
[SECRET_ID_KEY]: '',
|
||||
[USE_SYSTEM_KEY]: false,
|
||||
};
|
||||
|
||||
const SettingsWeyAiContentStorage = () => {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [testing, setTesting] = useState(false);
|
||||
const [writingCors, setWritingCors] = useState(false);
|
||||
const [values, setValues] = useState(EMPTY_VALUES);
|
||||
const [original, setOriginal] = useState(EMPTY_VALUES);
|
||||
const [secretKeySet, setSecretKeySet] = useState(false);
|
||||
const [secretKeyInput, setSecretKeyInput] = useState('');
|
||||
const [checks, setChecks] = useState(null);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await API.get('/api/option/');
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('加载失败,请重试'));
|
||||
return;
|
||||
}
|
||||
const map = {};
|
||||
(res.data.data || []).forEach((item) => {
|
||||
map[item.key] = item.value;
|
||||
});
|
||||
const next = {
|
||||
[BUCKET_KEY]: map[BUCKET_KEY] || '',
|
||||
[REGION_KEY]: map[REGION_KEY] || '',
|
||||
[SECRET_ID_KEY]: map[SECRET_ID_KEY] || '',
|
||||
[USE_SYSTEM_KEY]: map[USE_SYSTEM_KEY] === 'true',
|
||||
};
|
||||
setValues(next);
|
||||
setOriginal(next);
|
||||
setSecretKeySet(Boolean(map[SECRET_KEY_KEY]));
|
||||
setSecretKeyInput('');
|
||||
} catch (_e) {
|
||||
showError(t('加载失败,请重试'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [t]);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, [load]);
|
||||
|
||||
const setField = (key) => (value) =>
|
||||
setValues((prev) => ({ ...prev, [key]: value }));
|
||||
|
||||
const save = async () => {
|
||||
const updates = [];
|
||||
Object.keys(values).forEach((key) => {
|
||||
if (values[key] !== original[key]) {
|
||||
const value =
|
||||
typeof values[key] === 'boolean'
|
||||
? String(values[key])
|
||||
: values[key].trim();
|
||||
updates.push({ key, value });
|
||||
}
|
||||
});
|
||||
// 密钥只在填写了新值时提交,留空不覆盖已保存的值
|
||||
const secret = secretKeyInput.trim();
|
||||
if (secret && secret !== MASKED_PLACEHOLDER) {
|
||||
updates.push({ key: SECRET_KEY_KEY, value: secret });
|
||||
}
|
||||
if (updates.length === 0) {
|
||||
showSuccess(t('没有需要保存的修改'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
updates.map((item) =>
|
||||
API.put('/api/option/', item, { skipErrorHandler: true }).then(
|
||||
(res) => ({ key: item.key, res }),
|
||||
(err) => ({ key: item.key, err }),
|
||||
),
|
||||
),
|
||||
);
|
||||
const failed = results.filter(({ res }) => !res?.data?.success);
|
||||
if (failed.length > 0) {
|
||||
failed.forEach(({ key, res, err }) => {
|
||||
const message =
|
||||
res?.data?.message ||
|
||||
err?.response?.data?.message ||
|
||||
t('保存失败,请重试');
|
||||
showError(
|
||||
t('{{label}}:{{message}}', {
|
||||
label: t(KEY_LABELS[key] || key),
|
||||
message,
|
||||
}),
|
||||
);
|
||||
});
|
||||
// 已成功的项记为新的原值,改回旧值时才能再次提交
|
||||
const saved = results
|
||||
.filter(({ res }) => res?.data?.success)
|
||||
.map(({ key }) => key);
|
||||
setOriginal((prev) => {
|
||||
const next = { ...prev };
|
||||
saved.forEach((key) => {
|
||||
if (key in values) next[key] = values[key];
|
||||
});
|
||||
return next;
|
||||
});
|
||||
if (saved.includes(SECRET_KEY_KEY)) {
|
||||
setSecretKeySet(true);
|
||||
setSecretKeyInput('');
|
||||
}
|
||||
return;
|
||||
}
|
||||
showSuccess(t('保存成功'));
|
||||
setChecks(null);
|
||||
await load();
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const dirty =
|
||||
secretKeyInput.trim() !== '' ||
|
||||
Object.keys(values).some((key) => values[key] !== original[key]);
|
||||
|
||||
const runTest = async () => {
|
||||
setTesting(true);
|
||||
try {
|
||||
const res = await API.post(
|
||||
'/api/option/weyai/content_storage/test',
|
||||
{},
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('测试失败,请重试'));
|
||||
return;
|
||||
}
|
||||
setChecks(res.data.data?.checks || []);
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('测试失败,请重试'));
|
||||
} finally {
|
||||
setTesting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const writeCors = async () => {
|
||||
setWritingCors(true);
|
||||
try {
|
||||
const res = await API.post(
|
||||
'/api/option/weyai/content_storage/cors',
|
||||
{},
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('写入失败,请重试'));
|
||||
return;
|
||||
}
|
||||
showSuccess(t('跨域规则已写入'));
|
||||
await runTest();
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('写入失败,请重试'));
|
||||
} finally {
|
||||
setWritingCors(false);
|
||||
}
|
||||
};
|
||||
|
||||
const corsMissing = checks?.some(
|
||||
(check) => check.name === 'cors' && !check.ok,
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Form.Section
|
||||
text={t('内容存储')}
|
||||
extraText={t(
|
||||
'WeyAi 展示内容(作品视频、封面、模板包)专用的腾讯云 COS 存储桶,和系统 COS 桶分开;没有配置时内容功能不可用,不会改用系统桶',
|
||||
)}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
<Banner
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
className='mb-4'
|
||||
description={t(
|
||||
'请在腾讯云单独建一个私有读写的存储桶,推荐再建一个只授权给这个桶的子账号密钥。客户端拿到的是有时效的签名地址,不需要公有读',
|
||||
)}
|
||||
/>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12} className='mb-3'>
|
||||
<Text className='block mb-1'>{t('存储桶名称')}</Text>
|
||||
<Input
|
||||
value={values[BUCKET_KEY]}
|
||||
onChange={setField(BUCKET_KEY)}
|
||||
placeholder='weyai-content-1250000000'
|
||||
aria-label={t('存储桶名称')}
|
||||
/>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('带 APPID 后缀的完整桶名')}
|
||||
</Text>
|
||||
</Col>
|
||||
<Col xs={24} md={12} className='mb-3'>
|
||||
<Text className='block mb-1'>{t('地域')}</Text>
|
||||
<Input
|
||||
value={values[REGION_KEY]}
|
||||
onChange={setField(REGION_KEY)}
|
||||
placeholder='ap-guangzhou'
|
||||
aria-label={t('地域')}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<div className='mb-3 flex items-center gap-2'>
|
||||
<Switch
|
||||
checked={values[USE_SYSTEM_KEY]}
|
||||
onChange={setField(USE_SYSTEM_KEY)}
|
||||
aria-label={t('沿用系统 COS 的密钥')}
|
||||
/>
|
||||
<Text>{t('沿用系统 COS 的密钥')}</Text>
|
||||
</div>
|
||||
<Text type='tertiary' size='small' className='block mb-3'>
|
||||
{values[USE_SYSTEM_KEY]
|
||||
? t(
|
||||
'使用「运营设置」里腾讯云 COS 的 SecretId 和 SecretKey,只需填写桶名和地域;那组密钥要有这个桶的读写权限',
|
||||
)
|
||||
: t(
|
||||
'填写一组有这个桶读写权限的密钥;推荐使用只授权给这个桶的子账号密钥,泄露时影响最小',
|
||||
)}
|
||||
</Text>
|
||||
{!values[USE_SYSTEM_KEY] && (
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12} className='mb-3'>
|
||||
<Text className='block mb-1'>SecretId</Text>
|
||||
<Input
|
||||
value={values[SECRET_ID_KEY]}
|
||||
onChange={setField(SECRET_ID_KEY)}
|
||||
aria-label='SecretId'
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} md={12} className='mb-3'>
|
||||
<Text className='block mb-1'>SecretKey</Text>
|
||||
<Input
|
||||
mode='password'
|
||||
value={secretKeyInput}
|
||||
onChange={setSecretKeyInput}
|
||||
aria-label='SecretKey'
|
||||
placeholder={
|
||||
secretKeySet
|
||||
? t('已设置,留空则不修改')
|
||||
: t('敏感信息不会发送到前端显示')
|
||||
}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
<div className='flex flex-wrap gap-2 mt-2'>
|
||||
<Button type='primary' loading={saving} onClick={save}>
|
||||
{t('保存')}
|
||||
</Button>
|
||||
<Button loading={testing} disabled={dirty} onClick={runTest}>
|
||||
{t('测试连接')}
|
||||
</Button>
|
||||
{corsMissing && (
|
||||
<Button loading={writingCors} onClick={writeCors}>
|
||||
{t('写入跨域规则')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{dirty && (
|
||||
<Text type='tertiary' size='small' className='block mt-2'>
|
||||
{t('测试的是已保存的配置,请先保存再测试')}
|
||||
</Text>
|
||||
)}
|
||||
{checks && (
|
||||
<div className='mt-4'>
|
||||
{checks.map((check) => (
|
||||
<div key={check.name} className='mb-1'>
|
||||
<Text type={check.ok ? 'success' : 'danger'}>
|
||||
{check.ok ? '✓ ' : '✗ '}
|
||||
{t(CHECK_LABELS[check.name] || check.name)}
|
||||
</Text>
|
||||
{!check.ok && check.message && (
|
||||
<Text type='tertiary' size='small' className='ml-2'>
|
||||
{check.message}
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Spin>
|
||||
</Form.Section>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsWeyAiContentStorage;
|
||||
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 系统设置 →「WeyAi」→「版本说明」:每个 WeyAi 桌面版本的更新概要(Markdown)。
|
||||
// 发布后,WeyAi 的「关于」页显示当前版本和历史版本的说明,发现新版本时的更新卡片
|
||||
// 也会带上这里写的内容。客户端读公开接口 GET /api/weyai/desktop/release-notes,
|
||||
// 未登录也能看到;草稿只在这里可见。root 和被下放了「WeyAi」页签的管理员都能用。
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Banner,
|
||||
Button,
|
||||
DatePicker,
|
||||
Empty,
|
||||
Input,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
TabPane,
|
||||
Tabs,
|
||||
Tag,
|
||||
TextArea,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API, showError, showSuccess } from '../../../helpers';
|
||||
import MarkdownRenderer from '../../../components/common/markdown/MarkdownRenderer';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const BASE = '/api/admin/weyai/release-notes';
|
||||
|
||||
const EMPTY_DRAFT = {
|
||||
id: 0,
|
||||
version: '',
|
||||
title: '',
|
||||
content: '',
|
||||
prerelease: false,
|
||||
released_at: 0,
|
||||
};
|
||||
|
||||
const contentPlaceholder = (t) => `### ${t('新功能')}
|
||||
-
|
||||
|
||||
### ${t('改进')}
|
||||
-
|
||||
|
||||
### ${t('修复')}
|
||||
- `;
|
||||
|
||||
const formatDate = (sec) =>
|
||||
sec ? new Date(sec * 1000).toLocaleDateString() : '';
|
||||
|
||||
const SettingsWeyAiReleaseNotes = () => {
|
||||
const { t } = useTranslation();
|
||||
const [notes, setNotes] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [busyId, setBusyId] = useState(0);
|
||||
const [draft, setDraft] = useState(null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
const res = await API.get(BASE, { skipErrorHandler: true });
|
||||
if (!res?.data?.success) {
|
||||
throw new Error(res?.data?.message || t('加载失败,请重试'));
|
||||
}
|
||||
setNotes(res.data.data || []);
|
||||
}, [t]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
load()
|
||||
.catch((e) => showError(e.message))
|
||||
.finally(() => setLoading(false));
|
||||
}, [load]);
|
||||
|
||||
const call = async (id, request, successText) => {
|
||||
setBusyId(id);
|
||||
try {
|
||||
const res = await request();
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('操作失败,请重试'));
|
||||
return;
|
||||
}
|
||||
showSuccess(successText);
|
||||
await load();
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('操作失败,请重试'));
|
||||
} finally {
|
||||
setBusyId(0);
|
||||
}
|
||||
};
|
||||
|
||||
const setStatus = (note, status) =>
|
||||
call(
|
||||
note.id,
|
||||
() =>
|
||||
API.post(
|
||||
`${BASE}/${note.id}/status`,
|
||||
{ status },
|
||||
{ skipErrorHandler: true },
|
||||
),
|
||||
status === 'published' ? t('已发布') : t('已撤回为草稿'),
|
||||
);
|
||||
|
||||
const remove = (note) =>
|
||||
call(
|
||||
note.id,
|
||||
() => API.delete(`${BASE}/${note.id}`, { skipErrorHandler: true }),
|
||||
t('已删除'),
|
||||
);
|
||||
|
||||
const save = async () => {
|
||||
if (!draft) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
const body = {
|
||||
version: draft.version,
|
||||
title: draft.title,
|
||||
content: draft.content,
|
||||
prerelease: draft.prerelease,
|
||||
released_at: draft.released_at,
|
||||
};
|
||||
const res = draft.id
|
||||
? await API.put(`${BASE}/${draft.id}`, body, { skipErrorHandler: true })
|
||||
: await API.post(BASE, body, { skipErrorHandler: true });
|
||||
if (!res?.data?.success) {
|
||||
showError(res?.data?.message || t('保存失败,请重试'));
|
||||
return;
|
||||
}
|
||||
showSuccess(
|
||||
draft.id ? t('保存成功') : t('已保存为草稿,确认无误后点「发布」'),
|
||||
);
|
||||
setDraft(null);
|
||||
await load();
|
||||
} catch (err) {
|
||||
showError(err?.response?.data?.message || t('保存失败,请重试'));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('版本'),
|
||||
width: 160,
|
||||
render: (_, note) => (
|
||||
<Space>
|
||||
<Text strong>v{note.version}</Text>
|
||||
{note.prerelease && (
|
||||
<Tag size='small' color='orange'>
|
||||
{t('预发布')}
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('标题'),
|
||||
render: (_, note) => note.title || <Text type='tertiary'>—</Text>,
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
width: 100,
|
||||
render: (_, note) =>
|
||||
note.status === 'published' ? (
|
||||
<Tag color='green'>{t('已发布')}</Tag>
|
||||
) : (
|
||||
<Tag color='grey'>{t('草稿')}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('发布日期'),
|
||||
width: 130,
|
||||
render: (_, note) =>
|
||||
formatDate(note.released_at) || <Text type='tertiary'>—</Text>,
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 240,
|
||||
render: (_, note) => (
|
||||
<Space>
|
||||
<Button size='small' onClick={() => setDraft({ ...note })}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{note.status === 'published' ? (
|
||||
<Button
|
||||
size='small'
|
||||
type='warning'
|
||||
loading={busyId === note.id}
|
||||
onClick={() => setStatus(note, 'draft')}
|
||||
>
|
||||
{t('撤回')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
theme='solid'
|
||||
loading={busyId === note.id}
|
||||
onClick={() => setStatus(note, 'published')}
|
||||
>
|
||||
{t('发布')}
|
||||
</Button>
|
||||
)}
|
||||
<Popconfirm
|
||||
title={t('确定删除这条版本说明吗?')}
|
||||
content={t('删除后客户端不再显示这个版本的说明')}
|
||||
onConfirm={() => remove(note)}
|
||||
>
|
||||
<Button size='small' type='danger' disabled={busyId === note.id}>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Banner
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
className='mb-4'
|
||||
description={t(
|
||||
'每个版本写一条更新概要,支持 Markdown。发布后 WeyAi「关于」页会显示当前版本和历史版本的说明,发现新版本时的更新提示也会带上对应内容;草稿不会下发。',
|
||||
)}
|
||||
/>
|
||||
<div className='mb-3'>
|
||||
<Button theme='solid' onClick={() => setDraft({ ...EMPTY_DRAFT })}>
|
||||
{t('新建版本说明')}
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={notes}
|
||||
pagination={false}
|
||||
empty={<Empty description={t('还没有版本说明')} />}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={draft?.id ? t('编辑版本说明') : t('新建版本说明')}
|
||||
visible={Boolean(draft)}
|
||||
width={760}
|
||||
onCancel={() => setDraft(null)}
|
||||
onOk={save}
|
||||
okText={t('保存')}
|
||||
confirmLoading={saving}
|
||||
maskClosable={false}
|
||||
>
|
||||
{draft && (
|
||||
<div className='flex flex-col gap-3'>
|
||||
<div className='flex gap-3 flex-wrap items-center'>
|
||||
<Input
|
||||
style={{ width: 200 }}
|
||||
prefix='v'
|
||||
placeholder='2.3.0'
|
||||
value={draft.version}
|
||||
onChange={(version) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
version,
|
||||
// 1.2.3-beta.1 → 1.2.3: the pre-release mark came from the suffix, drop it
|
||||
prerelease:
|
||||
draft.version.includes('-') && !version.includes('-')
|
||||
? false
|
||||
: draft.prerelease,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<DatePicker
|
||||
type='date'
|
||||
placeholder={t('发布日期(留空则在发布时自动填写)')}
|
||||
style={{ width: 280 }}
|
||||
// A published note keeps its date; clearing it would be ignored on save.
|
||||
showClear={draft.status !== 'published'}
|
||||
value={
|
||||
draft.released_at
|
||||
? new Date(draft.released_at * 1000)
|
||||
: undefined
|
||||
}
|
||||
onChange={(date) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
// Local noon: the same calendar day in every time zone within ±12 h.
|
||||
released_at: date
|
||||
? Math.floor(new Date(date).setHours(12, 0, 0, 0) / 1000)
|
||||
: 0,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={draft.prerelease || draft.version.includes('-')}
|
||||
disabled={draft.version.includes('-')}
|
||||
onChange={(prerelease) => setDraft({ ...draft, prerelease })}
|
||||
/>
|
||||
<Text>{t('预发布版本')}</Text>
|
||||
</Space>
|
||||
</div>
|
||||
<Input
|
||||
placeholder={t('标题(可选),例如:对话显示每轮 token 用量')}
|
||||
maxLength={100}
|
||||
value={draft.title}
|
||||
onChange={(title) => setDraft({ ...draft, title })}
|
||||
/>
|
||||
<Tabs type='button' size='small'>
|
||||
<TabPane tab={t('编辑')} itemKey='edit'>
|
||||
<TextArea
|
||||
className='mt-2'
|
||||
autosize={{ minRows: 12, maxRows: 24 }}
|
||||
maxCount={20000}
|
||||
placeholder={contentPlaceholder(t)}
|
||||
value={draft.content}
|
||||
onChange={(content) => setDraft({ ...draft, content })}
|
||||
/>
|
||||
</TabPane>
|
||||
<TabPane tab={t('预览')} itemKey='preview'>
|
||||
<div
|
||||
className='mt-2 p-3 rounded'
|
||||
style={{
|
||||
minHeight: 200,
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
}}
|
||||
>
|
||||
{draft.content.trim() ? (
|
||||
<MarkdownRenderer content={draft.content} />
|
||||
) : (
|
||||
<Text type='tertiary'>{t('还没有内容')}</Text>
|
||||
)}
|
||||
</div>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsWeyAiReleaseNotes;
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 「WeyAi → 内容管理」的浏览器直传(M21):本地检查 → 申请上传地址 → 直传 COS →
|
||||
// 让后台核对。文件不经过 monkey-ai 服务器,不受 nginx 上传大小的限制。
|
||||
|
||||
import { API } from '../../../helpers';
|
||||
|
||||
/** Whether the server records and verifies the file's sha256 (mirrors ContentMediaRole.NeedsSha256). */
|
||||
export const roleNeedsSha256 = (role) =>
|
||||
Boolean(role?.cacheable) || role?.kind === 'zip';
|
||||
|
||||
/** Human readable size, e.g. 3 MB. */
|
||||
export const formatBytes = (n) => {
|
||||
if (n >= 1 << 20) return `${Math.round((n / (1 << 20)) * 10) / 10} MB`;
|
||||
if (n >= 1 << 10) return `${Math.round(n / (1 << 10))} KB`;
|
||||
return `${n} B`;
|
||||
};
|
||||
|
||||
/** Content type the server expects; browsers report zip files inconsistently. */
|
||||
export const contentTypeOf = (file, role) => {
|
||||
if (role?.kind === 'zip') return 'application/zip';
|
||||
return file.type || '';
|
||||
};
|
||||
|
||||
const sha256Hex = async (file) => {
|
||||
const digest = await crypto.subtle.digest(
|
||||
'SHA-256',
|
||||
await file.arrayBuffer(),
|
||||
);
|
||||
return Array.from(new Uint8Array(digest))
|
||||
.map((b) => b.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
};
|
||||
|
||||
const readMediaMeta = (file, kind) =>
|
||||
new Promise((resolve) => {
|
||||
const url = URL.createObjectURL(file);
|
||||
const done = (meta) => {
|
||||
URL.revokeObjectURL(url);
|
||||
resolve(meta);
|
||||
};
|
||||
if (kind === 'video') {
|
||||
const video = document.createElement('video');
|
||||
video.preload = 'metadata';
|
||||
video.onloadedmetadata = () =>
|
||||
done({
|
||||
width: video.videoWidth,
|
||||
height: video.videoHeight,
|
||||
duration: Number.isFinite(video.duration) ? video.duration : 0,
|
||||
});
|
||||
video.onerror = () => done({});
|
||||
video.src = url;
|
||||
} else if (kind === 'image') {
|
||||
const img = new Image();
|
||||
img.onload = () =>
|
||||
done({ width: img.naturalWidth, height: img.naturalHeight });
|
||||
img.onerror = () => done({});
|
||||
img.src = url;
|
||||
} else {
|
||||
done({});
|
||||
}
|
||||
});
|
||||
|
||||
const putWithProgress = (ticket, file, onProgress) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open(ticket.method || 'PUT', ticket.url);
|
||||
Object.entries(ticket.headers || {}).forEach(([k, v]) =>
|
||||
xhr.setRequestHeader(k, v),
|
||||
);
|
||||
xhr.upload.onprogress = (e) => {
|
||||
if (e.lengthComputable && onProgress) {
|
||||
onProgress(Math.round((e.loaded / e.total) * 100));
|
||||
}
|
||||
};
|
||||
xhr.onload = () =>
|
||||
xhr.status >= 200 && xhr.status < 300
|
||||
? resolve()
|
||||
: reject(new Error(`HTTP ${xhr.status}`));
|
||||
xhr.onerror = () => reject(new Error('network'));
|
||||
xhr.send(file);
|
||||
});
|
||||
|
||||
/**
|
||||
* Uploads one file for a slot role and returns the confirmed object.
|
||||
* Throws an Error whose message is meant for the administrator; `code` is
|
||||
* 'cors' when the browser could not reach the bucket at all.
|
||||
*/
|
||||
export const uploadContentFile = async ({ slot, role, file, onProgress }) => {
|
||||
const contentType = contentTypeOf(file, role);
|
||||
const [meta, sha256] = await Promise.all([
|
||||
readMediaMeta(file, role.kind),
|
||||
roleNeedsSha256(role) ? sha256Hex(file) : Promise.resolve(''),
|
||||
]);
|
||||
const signed = await API.post(
|
||||
'/api/admin/weyai/content/uploads',
|
||||
{ slot, role: role.key, content_type: contentType, size: file.size },
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!signed?.data?.success) {
|
||||
throw new Error(signed?.data?.message || 'sign failed');
|
||||
}
|
||||
try {
|
||||
await putWithProgress(signed.data.data, file, onProgress);
|
||||
} catch (e) {
|
||||
const err = new Error(e.message);
|
||||
err.code = e.message === 'network' ? 'cors' : 'upload';
|
||||
throw err;
|
||||
}
|
||||
const confirmed = await API.post(
|
||||
'/api/admin/weyai/content/uploads/confirm',
|
||||
{
|
||||
key: signed.data.data.key,
|
||||
sha256,
|
||||
width: Math.round(meta.width || 0),
|
||||
height: Math.round(meta.height || 0),
|
||||
duration: meta.duration || 0,
|
||||
},
|
||||
{ skipErrorHandler: true },
|
||||
);
|
||||
if (!confirmed?.data?.success) {
|
||||
throw new Error(confirmed?.data?.message || 'confirm failed');
|
||||
}
|
||||
return confirmed.data.data;
|
||||
};
|
||||
@@ -45,12 +45,14 @@ import {
|
||||
ShieldCheck,
|
||||
ShieldAlert,
|
||||
Layers,
|
||||
Bot,
|
||||
} from 'lucide-react';
|
||||
|
||||
import SystemSetting from '../../components/settings/SystemSetting';
|
||||
import { isAdmin, isRoot } from '../../helpers';
|
||||
import OtherSetting from '../../components/settings/OtherSetting';
|
||||
import OperationSetting from '../../components/settings/OperationSetting';
|
||||
import WeyAiSetting from '../../components/settings/WeyAiSetting';
|
||||
import DataSecuritySetting from '../../components/settings/DataSecuritySetting';
|
||||
import ContentGuardSetting from '../../components/settings/ContentGuardSetting';
|
||||
import RateLimitSetting from '../../components/settings/RateLimitSetting';
|
||||
@@ -97,6 +99,16 @@ const Setting = () => {
|
||||
content: <OperationSetting />,
|
||||
itemKey: 'operation',
|
||||
});
|
||||
panes.push({
|
||||
tab: (
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: '5px' }}>
|
||||
<Bot size={18} />
|
||||
{t('WeyAi')}
|
||||
</span>
|
||||
),
|
||||
content: <WeyAiSetting />,
|
||||
itemKey: 'weyai',
|
||||
});
|
||||
panes.push({
|
||||
tab: (
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: '5px' }}>
|
||||
|
||||
@@ -91,7 +91,7 @@ const SkillCatalog = ({
|
||||
<div className='sm-result-bar'>
|
||||
<div>
|
||||
<h2>{t(scope === 'mine' ? '我的技能' : '全部技能')}</h2>
|
||||
{showTotal ? <span>{t('{{total}} 个技能', { total })}</span> : null}
|
||||
{showTotal ? <span>{t('{{total}} 个技能', { total, count: total })}</span> : null}
|
||||
{selectedTagCount > 0 && (
|
||||
<span className='sm-selected-count'>
|
||||
{t('已选 {{count}} 个标签', { count: selectedTagCount })}
|
||||
|
||||
@@ -653,7 +653,16 @@ const SkillPlatform = () => {
|
||||
return (
|
||||
<GrayscaleProgress
|
||||
percent={Math.round(sum.percent / importJobs.length)}
|
||||
label={`${t('快照导入')} · ${t('技能包')} ${done}/${importJobs.length} · ${t('成功')} ${sum.imported} / ${t('跳过')} ${sum.skipped} / ${t('失败')} ${sum.failed}`}
|
||||
label={t(
|
||||
'快照导入 · 技能包 {{done}}/{{total}} · 成功 {{imported}} / 跳过 {{skipped}} / 失败 {{failed}}',
|
||||
{
|
||||
done,
|
||||
total: importJobs.length,
|
||||
imported: sum.imported,
|
||||
skipped: sum.skipped,
|
||||
failed: sum.failed,
|
||||
},
|
||||
)}
|
||||
/>
|
||||
);
|
||||
})()}
|
||||
|
||||
@@ -110,14 +110,14 @@ const RemainingTag = ({ endDate, status, t }) => {
|
||||
if (days < 0) {
|
||||
return (
|
||||
<span className='text-xs text-gray-400'>
|
||||
{t('已过期 {{n}} 天', { n: Math.abs(days) })}
|
||||
{t('已过期 {{n}} 天', { n: Math.abs(days), count: Math.abs(days) })}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
let cls = 'text-xs text-gray-500';
|
||||
if (days <= 3) cls = 'text-xs text-red-500 font-semibold';
|
||||
else if (days <= 7) cls = 'text-xs text-amber-500 font-medium';
|
||||
return <span className={cls}>{t('剩余 {{n}} 天', { n: days })}</span>;
|
||||
return <span className={cls}>{t('剩余 {{n}} 天', { n: days, count: days })}</span>;
|
||||
};
|
||||
|
||||
const Subscription = () => {
|
||||
@@ -757,7 +757,7 @@ const CreateMembershipModal = ({
|
||||
const [userId, setUserId] = useState();
|
||||
const [planId, setPlanId] = useState();
|
||||
const [days, setDays] = useState(30);
|
||||
const [reason, setReason] = useState('管理员手动开通会员');
|
||||
const [reason, setReason] = useState(() => t('管理员手动开通会员'));
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -765,7 +765,7 @@ const CreateMembershipModal = ({
|
||||
setUserId(undefined);
|
||||
setPlanId(undefined);
|
||||
setDays(30);
|
||||
setReason('管理员手动开通会员');
|
||||
setReason(t('管理员手动开通会员'));
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
@@ -827,9 +827,9 @@ const CreateMembershipModal = ({
|
||||
|
||||
const planOptions = enabledPlans.map((plan) => ({
|
||||
value: plan.id,
|
||||
label: `${plan.name} / ${plan.tier || '-'} / ${plan.duration_days} ${t(
|
||||
'天',
|
||||
)}`,
|
||||
label: `${plan.name} / ${plan.tier || '-'} / ${t('{{days}} 天', {
|
||||
days: plan.duration_days,
|
||||
})}`,
|
||||
}));
|
||||
|
||||
return (
|
||||
|
||||
@@ -45,6 +45,7 @@ import {
|
||||
} from '@/components/ui/icons';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { DEFAULT_LOGIN_REDIRECT } from '../../helpers/data';
|
||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
||||
import VideoTutorial from './components/VideoTutorial';
|
||||
import './styles.css';
|
||||
|
||||
@@ -668,13 +669,23 @@ source ~/.bashrc`,
|
||||
},
|
||||
];
|
||||
|
||||
// WeyAi 小程序里不出现充值步骤(helpers/miniProgram.js)。其余步骤保留原编号,
|
||||
// 与标题里的「第四步」等一致。
|
||||
const inMiniProgram = isMiniProgramWebView();
|
||||
const visibleSteps = steps
|
||||
.map((step, index) => ({ ...step, number: index + 1 }))
|
||||
.filter((step) => !(inMiniProgram && step.key === 'recharge'));
|
||||
const visibleStepComponents = allStepComponents
|
||||
.map((step, index) => ({ ...step, number: index + 1 }))
|
||||
.filter((step) => !(inMiniProgram && step.component === rechargeStep));
|
||||
|
||||
// 图文教程内容 - 滚动浏览模式(使用 JSX 变量而非内联组件,避免状态更新时重新挂载导致滚动位置重置)
|
||||
const stepsTutorial = (
|
||||
<div className='tutorial-scroll-wrapper'>
|
||||
{/* 顶部快速导航 */}
|
||||
<div className='tutorial-quick-nav'>
|
||||
<div className='tutorial-quick-nav-inner'>
|
||||
{steps.map((step, index) => (
|
||||
{visibleSteps.map((step, index) => (
|
||||
<a
|
||||
key={step.key}
|
||||
href={`#tutorial-step-${index}`}
|
||||
@@ -693,7 +704,7 @@ source ~/.bashrc`,
|
||||
}
|
||||
}}
|
||||
>
|
||||
<span className='tutorial-quick-nav-number'>{index + 1}</span>
|
||||
<span className='tutorial-quick-nav-number'>{step.number}</span>
|
||||
<span className='tutorial-quick-nav-title'>{step.title}</span>
|
||||
</a>
|
||||
))}
|
||||
@@ -707,7 +718,7 @@ source ~/.bashrc`,
|
||||
{/* 可滚动的内容区域 */}
|
||||
<div className='tutorial-scroll-container' ref={scrollContainerRef}>
|
||||
<div className='tutorial-all-steps'>
|
||||
{allStepComponents.map((step, index) => (
|
||||
{visibleStepComponents.map((step, index) => (
|
||||
<div
|
||||
key={`step-wrapper-${index}`}
|
||||
id={`tutorial-step-${index}`}
|
||||
@@ -720,7 +731,7 @@ source ~/.bashrc`,
|
||||
background: `linear-gradient(135deg, ${step.color}, color-mix(in srgb, ${step.color} 85%, transparent))`,
|
||||
}}
|
||||
>
|
||||
{index + 1} / {allStepComponents.length}
|
||||
{step.number} / {allStepComponents.length}
|
||||
</div>
|
||||
</div>
|
||||
{step.component}
|
||||
|
||||
@@ -306,7 +306,7 @@ const Invoice = () => {
|
||||
title: t('支付方式'),
|
||||
dataIndex: 'payment_method',
|
||||
width: 100,
|
||||
render: (v) => (v ? paymentMethodMap[v] || v : '-'),
|
||||
render: (v) => (v ? t(paymentMethodMap[v] || v) : '-'),
|
||||
},
|
||||
{
|
||||
title: t('支付金额'),
|
||||
@@ -618,8 +618,10 @@ const Invoice = () => {
|
||||
>
|
||||
<span>{formatTime(topup.complete_time)}</span>
|
||||
<span>
|
||||
{paymentMethodMap[topup.payment_method] ||
|
||||
topup.payment_method}
|
||||
{t(
|
||||
paymentMethodMap[topup.payment_method] ||
|
||||
topup.payment_method,
|
||||
)}
|
||||
</span>
|
||||
<span className='font-medium'>
|
||||
¥{Number(topup.money).toFixed(2)}
|
||||
|
||||
@@ -19,6 +19,10 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useMemo, useContext } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
isMiniProgramPaymentPath,
|
||||
isMiniProgramWebView,
|
||||
} from '../../helpers/miniProgram';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
LayoutGrid,
|
||||
@@ -166,10 +170,15 @@ const UserCenterSidebar = () => {
|
||||
if (!sidebarConfig.enabled) {
|
||||
return [];
|
||||
}
|
||||
const inMiniProgram = isMiniProgramWebView();
|
||||
return allItems.filter(
|
||||
(item) =>
|
||||
sidebarConfig[item.configKey] !== false &&
|
||||
isGroupAllowed(sidebarConfig.moduleGroups?.[item.configKey], userGroup),
|
||||
isGroupAllowed(
|
||||
sidebarConfig.moduleGroups?.[item.configKey],
|
||||
userGroup,
|
||||
) &&
|
||||
!(inMiniProgram && isMiniProgramPaymentPath(item.itemKey)),
|
||||
);
|
||||
}, [allItems, sidebarConfig, userGroup]);
|
||||
|
||||
|
||||
@@ -239,8 +239,10 @@ const UserDashboard = () => {
|
||||
<Tag size='small'>{membershipInfo.plan_name}</Tag>
|
||||
<span className='uc-member-benefits-meta'>
|
||||
<Clock size={12} />
|
||||
{dashboardData.t('剩余')} {membershipInfo.remaining_days}{' '}
|
||||
{dashboardData.t('天')}
|
||||
{dashboardData.t('剩余 {{n}} 天', {
|
||||
n: membershipInfo.remaining_days,
|
||||
count: membershipInfo.remaining_days,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ import ServiceDashboard from '../ServiceDashboard';
|
||||
import WeyAiDownload from '../WeyAiDownload';
|
||||
import KeyManagement from '../KeyManagement';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import {
|
||||
isMiniProgramPaymentPath,
|
||||
isMiniProgramWebView,
|
||||
} from '../../helpers/miniProgram';
|
||||
|
||||
// 移动端底部导航组件
|
||||
const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
@@ -109,9 +113,12 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
},
|
||||
];
|
||||
|
||||
const inMiniProgram = isMiniProgramWebView();
|
||||
const visibleNavItems = navItems.filter(
|
||||
(item) =>
|
||||
sidebarConfig?.enabled !== false && sidebarConfig?.[item.key] !== false,
|
||||
sidebarConfig?.enabled !== false &&
|
||||
sidebarConfig?.[item.key] !== false &&
|
||||
!(inMiniProgram && isMiniProgramPaymentPath(item.path)),
|
||||
);
|
||||
|
||||
if (visibleNavItems.length === 0) {
|
||||
@@ -177,11 +184,20 @@ const UserCenter = ({ keyManagementMode = false }) => {
|
||||
invite: 'invite',
|
||||
settings: 'settings',
|
||||
};
|
||||
// 小程序里付费页面会被 App.jsx 送回 /user-center,所以默认页不能落在它们上面,否则来回跳转。
|
||||
const inMiniProgram = isMiniProgramWebView();
|
||||
const firstVisiblePath =
|
||||
userCenterConfig.enabled === false
|
||||
? null
|
||||
: routePathMap[
|
||||
userCenterRoutes.find((key) => userCenterConfig[key] !== false)
|
||||
userCenterRoutes.find(
|
||||
(key) =>
|
||||
userCenterConfig[key] !== false &&
|
||||
!(
|
||||
inMiniProgram &&
|
||||
isMiniProgramPaymentPath(`/user-center/${routePathMap[key]}`)
|
||||
),
|
||||
)
|
||||
] || null;
|
||||
const firstVisibleRoute = firstVisiblePath
|
||||
? `/user-center/${firstVisiblePath}`
|
||||
|
||||
Reference in New Issue
Block a user