fix(ui): 修复登录和并发请求并统一页面展示

调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 9b6eb1c7c4
commit 7908ed53a3
128 changed files with 4672 additions and 5391 deletions
@@ -140,7 +140,7 @@ const hasImageTaskType = (dataTransfer) =>
const Section = ({ title, extra, children, className = '' }) => (
<div
className={`mb-4 rounded-3xl border border-white/[0.45] bg-white/[0.28] p-3 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.045] ${className}`}
className={`mb-4 rounded-3xl border border-[var(--igf-line)] bg-white/[0.28] p-3 backdrop-blur-xl dark:bg-white/[0.045] ${className}`}
>
{title || extra ? (
<div className='flex items-center justify-between gap-2 mb-2'>
@@ -383,12 +383,14 @@ const ImageGenerationForm = ({ creation }) => {
loading={submitting}
onClick={handleSubmit}
disabled={isButtonDisabled}
className='!rounded-2xl !shadow-lg !shadow-brand/20 hover:!shadow-xl hover:!shadow-brand/25 !transition-all'
className='!rounded-2xl !transition-colors'
style={{
background: isButtonDisabled
? 'var(--ui-color-fill-1)'
: 'linear-gradient(135deg, var(--brand-gradient-from) 0%, var(--brand-primary) 52%, var(--brand-gradient-to) 100%)',
border: 'none',
border: isButtonDisabled
? '1px solid var(--igf-line)'
: '1px solid transparent',
color: isButtonDisabled ? 'var(--ui-color-text-3)' : 'white',
height: '48px',
fontSize: '15px',
@@ -538,328 +540,337 @@ const ImageGenerationForm = ({ creation }) => {
return (
<div
className={`image-generation-form relative flex h-full flex-col overflow-y-auto overflow-x-hidden rounded-[28px] border border-white/[0.55] bg-white/[0.42] p-4 shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors app-scrollbar dark:border-white/10 dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`}
className={`image-generation-form relative flex h-full min-h-0 flex-col overflow-hidden rounded-[28px] border border-[var(--igf-line)] bg-white/[0.42] shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
>
{/* 标题 */}
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'>
<div className='flex items-center justify-between gap-2'>
<div className='flex-1 min-w-0'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'>
<Sparkles size={12} />
{t('AI 图片创作')}
<div className='igf-form-scroll app-scrollbar'>
{/* 标题 */}
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'>
<div className='flex items-center justify-between gap-2'>
<div className='flex-1 min-w-0'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'>
<Sparkles size={12} />
{t('AI 图片创作')}
</div>
<Title
heading={4}
style={{ margin: 0 }}
className='text-gray-900 dark:text-white'
>
{t('图片生成')}
</Title>
<Text
type='secondary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
</Text>
</div>
<Title
heading={4}
style={{ margin: 0 }}
className='text-gray-900 dark:text-white'
>
{t('图片生成')}
</Title>
<div className='flex items-center gap-1'>
{!formBodyHidden && (
<Button
icon={<ActionRotateCcw size={12} />}
size='small'
theme='borderless'
onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
>
{t('重置')}
</Button>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={14} />
) : (
<ActionChevronUp size={14} />
)
}
size='small'
theme='borderless'
onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500'
>
{mobileCollapsed ? t('展开') : t('收起')}
</Button>
)}
</div>
</div>
</div>
{/* 移动端折叠时只显示生成按钮 + 简略 */}
{formBodyHidden && (
<div className='mt-2'>
{renderGenerateArea()}
<Text
type='secondary'
type='tertiary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
className='block mt-2 text-center'
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
<div className='flex items-center gap-1'>
{!formBodyHidden && (
<Button
icon={<ActionRotateCcw size={12} />}
size='small'
theme='borderless'
onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
>
{t('重置')}
</Button>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={14} />
) : (
<ActionChevronUp size={14} />
)
}
size='small'
theme='borderless'
onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500'
>
{mobileCollapsed ? t('展开') : t('收起')}
</Button>
)}
</div>
</div>
</div>
)}
{/* 移动端折叠时只显示生成按钮 + 简略 */}
{formBodyHidden && (
<div className='mt-2'>
{renderGenerateArea()}
<Text type='tertiary' size='small' className='block mt-2 text-center'>
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
)}
{!formBodyHidden && (
<>
{/* 模型选择 */}
<Section title={t('选择模型')}>{renderModelSection()}</Section>
{!formBodyHidden && (
<>
{/* 模型选择 */}
<Section title={t('选择模型')}>{renderModelSection()}</Section>
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<Section title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<Section title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{/* 提示词 + 模板 + 历史 */}
<Section
title={t('提示词')}
extra={
<div className='flex items-center gap-2'>
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */}
<button
type='button'
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
className={[
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<Sparkles
size={10}
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => (
<Dropdown.Item key={idx} onClick={() => setPrompt(p)}>
<div
style={{
maxWidth: 320,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item>
))}
</Dropdown.Menu>
{/* 提示词 + 模板 + 历史 */}
<Section
title={t('提示词')}
extra={
<div className='flex items-center gap-2'>
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */}
<button
type='button'
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
className={[
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<button
type='button'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
<Sparkles
size={10}
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => (
<Dropdown.Item
key={idx}
onClick={() => setPrompt(p)}
>
<div
style={{
maxWidth: 320,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item>
))}
</Dropdown.Menu>
}
>
<ActionHistory size={10} />
<span>{t('历史')}</span>
</button>
</Dropdown>
)}
<span className='flex items-center gap-1 text-[10px] text-gray-400'>
{IS_MAC ? (
<Command size={10} />
) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span>
<button
type='button'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
>
<ActionHistory size={10} />
<span>{t('历史')}</span>
</button>
</Dropdown>
)}
<span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span>
<span>{t('生成')}</span>
</span>
</div>
}
>
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
<div className='flex flex-wrap items-center gap-1.5 mt-2'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'>
<Sparkles size={10} />
<span>{t('快速模板')}</span>
</div>
{PROMPT_TEMPLATES.map((tpl) => (
<Tag
key={tpl.label}
size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
>
{t(tpl.label)}
</Tag>
))}
</div>
</Section>
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? (
<Section
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
<span className='flex items-center gap-1 text-[10px] text-gray-400'>
{IS_MAC ? (
<Command size={10} />
) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span>
)}
<span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span>
<span>{t('生成')}</span>
</span>
</div>
}
>
<div className='igf-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active
? slot.status || 'ready'
: 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`ref-${entry.index}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.index, file)}
onRemove={() => removeImage(entry.index)}
onRetry={() => retryImage(entry.index, slot)}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'>
{t('置灰的图片当前不会提交,切回支持的模型或模式后自动恢复')}
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
<div className='flex flex-wrap items-center gap-1.5 mt-2'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'>
<Sparkles size={10} />
<span>{t('快速模板')}</span>
</div>
) : null}
{PROMPT_TEMPLATES.map((tpl) => (
<Tag
key={tpl.label}
size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
>
{t(tpl.label)}
</Tag>
))}
</div>
</Section>
) : null}
{/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}>
{sizeParam ? (
<ImageSizePicker
param={sizeParam}
value={formData.params?.size}
onChange={(v) => updateParam('size', v)}
/>
) : null}
{dockParams.length > 0 ? (
<ParamRenderer
className={sizeParam ? 'igf-dock-params' : ''}
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='dock'
constraints={constraints}
/>
) : null}
</Section>
) : null}
{/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? (
<Section>
<button
type='button'
onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? (
<Section
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
}
>
<ActionSettings size={12} />
<span>{t('高级选项')}</span>
{showAdvanced ? (
<ActionChevronUp size={12} />
) : (
<ActionChevronDown size={12} />
)}
</button>
<Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'>
<div className='igf-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active
? slot.status || 'ready'
: 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`ref-${entry.index}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.index, file)}
onRemove={() => removeImage(entry.index)}
onRetry={() => retryImage(entry.index, slot)}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'>
{t(
'置灰的图片当前不会提交,切回支持的模型或模式后自动恢复',
)}
</div>
) : null}
</Section>
) : null}
{/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}>
{sizeParam ? (
<ImageSizePicker
param={sizeParam}
value={formData.params?.size}
onChange={(v) => updateParam('size', v)}
/>
) : null}
{dockParams.length > 0 ? (
<ParamRenderer
className={sizeParam ? 'igf-dock-params' : ''}
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
placement='dock'
constraints={constraints}
/>
</div>
</Collapsible>
</Section>
) : null}
) : null}
</Section>
) : null}
{/* 生成按钮 + 估价 */}
<div className='sticky bottom-0 -mx-4 mt-auto bg-transparent px-4 pt-4 pb-1'>
{renderGenerateArea()}
</div>
</>
{/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? (
<Section>
<button
type='button'
onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
>
<ActionSettings size={12} />
<span>{t('高级选项')}</span>
{showAdvanced ? (
<ActionChevronUp size={12} />
) : (
<ActionChevronDown size={12} />
)}
</button>
<Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
constraints={constraints}
/>
</div>
</Collapsible>
</Section>
) : null}
</>
)}
</div>
{!formBodyHidden && (
<div className='igf-generate-wrap'>{renderGenerateArea()}</div>
)}
</div>
);