mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 15:08:39 +00:00
Frontend (web)
- ModelsActions.jsx
- Replace “Sync Official” with “Sync” and open a new two-step SyncWizard.
- Pass selected locale through to preview, sync, and overwrite flows.
- Keep conflict resolution flow; inject locale into overwrite submission.
- New: models/modals/SyncWizardModal.jsx
- Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja).
- Horizontal, centered Radio cards; returns { option, locale } via onConfirm.
- UpstreamConflictModal.jsx
- Add search input (model fuzzy search) and native pagination.
- Column header checkbox now only applies to rows in the current filtered result.
- Fix “Cannot access ‘filteredDataSource’ before initialization”.
- Refactor with useMemo/useCallback; extract helpers to remove duplicated logic:
- getPresentRowsForField, getHeaderState, applyHeaderChange
- Minor code cleanups and stability improvements.
- i18n (en.json)
- Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.).
- Adjust minor translations.
Hooks
- useModelsData.jsx
- Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale.
- Send locale via query/body accordingly.
Backend (Go)
- controller/model_sync.go
- Accept locale from query/body and resolve i18n upstream URLs.
- Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata).
- Make HTTP timeouts/retries/limits configurable:
- SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB
- Add ETag-based caching and support both envelope and pure array JSON formats.
- Concurrently fetch vendors and models; improve error responses with locale and source URLs.
- Include source meta (locale, models_url, vendors_url) in success payloads.
Notes
- No breaking changes expected.
- Lint passes for touched files.
133 lines
4.1 KiB
JavaScript
133 lines
4.1 KiB
JavaScript
/*
|
|
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, useState } from 'react';
|
|
import { Modal, RadioGroup, Radio, Steps, Button } from '@douyinfe/semi-ui';
|
|
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
|
|
|
const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
|
|
const [step, setStep] = useState(0);
|
|
const [option, setOption] = useState('official');
|
|
const [locale, setLocale] = useState('zh');
|
|
const isMobile = useIsMobile();
|
|
|
|
useEffect(() => {
|
|
if (visible) {
|
|
setStep(0);
|
|
setOption('official');
|
|
setLocale('zh');
|
|
}
|
|
}, [visible]);
|
|
|
|
return (
|
|
<Modal
|
|
title={t('同步向导')}
|
|
visible={visible}
|
|
onCancel={onClose}
|
|
footer={
|
|
<div className='flex justify-end'>
|
|
{step === 1 && (
|
|
<Button onClick={() => setStep(0)}>{t('上一步')}</Button>
|
|
)}
|
|
<Button onClick={onClose}>{t('取消')}</Button>
|
|
{step === 0 && (
|
|
<Button
|
|
type='primary'
|
|
onClick={() => setStep(1)}
|
|
disabled={option !== 'official'}
|
|
>
|
|
{t('下一步')}
|
|
</Button>
|
|
)}
|
|
{step === 1 && (
|
|
<Button
|
|
type='primary'
|
|
theme='solid'
|
|
loading={loading}
|
|
onClick={async () => {
|
|
await onConfirm?.({ option, locale });
|
|
}}
|
|
>
|
|
{t('开始同步')}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
}
|
|
width={isMobile ? '100%' : 'small'}
|
|
>
|
|
<div className='mb-3'>
|
|
<Steps type='basic' current={step} size='small'>
|
|
<Steps.Step title={t('选择方式')} description={t('选择同步来源')} />
|
|
<Steps.Step title={t('选择语言')} description={t('选择同步语言')} />
|
|
</Steps>
|
|
</div>
|
|
|
|
{step === 0 && (
|
|
<div className='mt-2 flex justify-center'>
|
|
<RadioGroup
|
|
value={option}
|
|
onChange={(e) => setOption(e?.target?.value ?? e)}
|
|
type='card'
|
|
direction='horizontal'
|
|
aria-label='同步方式选择'
|
|
name='sync-mode-selection'
|
|
>
|
|
<Radio value='official' extra={t('从官方模型库同步')}>
|
|
{t('官方模型同步')}
|
|
</Radio>
|
|
<Radio value='config' extra={t('从配置文件同步')} disabled>
|
|
{t('配置文件同步')}
|
|
</Radio>
|
|
</RadioGroup>
|
|
</div>
|
|
)}
|
|
|
|
{step === 1 && (
|
|
<div className='mt-2'>
|
|
<div className='mb-2 text-[var(--semi-color-text-2)]'>
|
|
{t('请选择同步语言')}
|
|
</div>
|
|
<div className='flex justify-center'>
|
|
<RadioGroup
|
|
value={locale}
|
|
onChange={(e) => setLocale(e?.target?.value ?? e)}
|
|
type='card'
|
|
direction='horizontal'
|
|
aria-label='语言选择'
|
|
name='sync-locale-selection'
|
|
>
|
|
<Radio value='en' extra='English'>
|
|
EN
|
|
</Radio>
|
|
<Radio value='zh' extra='中文'>
|
|
ZH
|
|
</Radio>
|
|
<Radio value='ja' extra='日本語'>
|
|
JA
|
|
</Radio>
|
|
</RadioGroup>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
export default SyncWizardModal;
|