diff --git a/frontend/src/hooks/useSettingsData.ts b/frontend/src/hooks/useSettingsData.ts index 270e9ff..a376244 100644 --- a/frontend/src/hooks/useSettingsData.ts +++ b/frontend/src/hooks/useSettingsData.ts @@ -11,6 +11,7 @@ interface RoutingConfig { interface InstallConfig { pythonIndexUrl: string; + npmRegistry: string; } interface SystemSettings { @@ -28,9 +29,9 @@ export const useSettingsData = () => { enableGlobalRoute: true, enableGroupNameRoute: true, }); - const [installConfig, setInstallConfig] = useState({ pythonIndexUrl: '', + npmRegistry: '', }); const [loading, setLoading] = useState(false); @@ -67,10 +68,10 @@ export const useSettingsData = () => { enableGroupNameRoute: data.data.systemConfig.routing.enableGroupNameRoute ?? true, }); } - if (data.success && data.data?.systemConfig?.install) { setInstallConfig({ pythonIndexUrl: data.data.systemConfig.install.pythonIndexUrl || '', + npmRegistry: data.data.systemConfig.install.npmRegistry || '', }); } } catch (error) { diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 1ba17e2..b4cb2ec 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -247,6 +247,9 @@ "pythonIndexUrl": "Python Package Repository URL", "pythonIndexUrlDescription": "Set UV_DEFAULT_INDEX environment variable for Python package installation", "pythonIndexUrlPlaceholder": "e.g. https://pypi.org/simple", + "npmRegistry": "NPM Registry URL", + "npmRegistryDescription": "Set npm_config_registry environment variable for NPM package installation", + "npmRegistryPlaceholder": "e.g. https://registry.npmjs.org/", "installConfig": "Installation Configuration", "systemConfigUpdated": "System configuration updated successfully" } diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 37a7d50..98a8bc8 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -248,6 +248,9 @@ "pythonIndexUrl": "Python 包仓库地址", "pythonIndexUrlDescription": "设置 UV_DEFAULT_INDEX 环境变量,用于 Python 包安装", "pythonIndexUrlPlaceholder": "例如: https://mirrors.aliyun.com/pypi/simple", + "npmRegistry": "NPM 仓库地址", + "npmRegistryDescription": "设置 npm_config_registry 环境变量,用于 NPM 包安装", + "npmRegistryPlaceholder": "例如: https://registry.npmmirror.com/", "installConfig": "安装配置", "systemConfigUpdated": "系统配置更新成功" } diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index cf16c2c..d4df296 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -16,11 +16,12 @@ const SettingsPage: React.FC = () => { useEffect(() => { setCurrentLanguage(i18n.language); }, [i18n.language]); - const [installConfig, setInstallConfig] = useState<{ pythonIndexUrl: string; + npmRegistry: string; }>({ pythonIndexUrl: '', + npmRegistry: '', }); const { @@ -54,16 +55,15 @@ const SettingsPage: React.FC = () => { const handleRoutingConfigChange = async (key: 'enableGlobalRoute' | 'enableGroupNameRoute', value: boolean) => { await updateRoutingConfig(key, value); }; - - const handleInstallConfigChange = (value: string) => { + const handleInstallConfigChange = (key: 'pythonIndexUrl' | 'npmRegistry', value: string) => { setInstallConfig({ ...installConfig, - pythonIndexUrl: value + [key]: value }); }; - const saveInstallConfig = async () => { - await updateInstallConfig('pythonIndexUrl', installConfig.pythonIndexUrl); + const saveInstallConfig = async (key: 'pythonIndexUrl' | 'npmRegistry') => { + await updateInstallConfig(key, installConfig[key]); }; const handlePasswordChangeSuccess = () => { @@ -87,21 +87,19 @@ const SettingsPage: React.FC = () => {

{t('pages.settings.language')}

+
+ + +
+
+

{t('settings.npmRegistry')}

+

{t('settings.npmRegistryDescription')}

+
+
+ handleInstallConfigChange('npmRegistry', e.target.value)} + placeholder={t('settings.npmRegistryPlaceholder')} + className="flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" + disabled={loading} + /> +