[Desktop] Fix mirror validation in settings dialog (#2375)

This commit is contained in:
Chenlei Hu
2025-01-29 14:57:36 -08:00
committed by GitHub
parent e019277ba0
commit 766710cf37
3 changed files with 38 additions and 15 deletions

View File

@@ -1,8 +1,10 @@
import { PYTHON_MIRROR } from '@/constants/uvMirrors'
import { t } from '@/i18n'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { useWorkflowStore } from '@/stores/workflowStore'
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
import { checkMirrorReachable } from '@/utils/networkUtil'
;(async () => {
if (!isElectron()) return
@@ -60,21 +62,34 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
name: 'Python Install Mirror',
tooltip: `Managed Python installations are downloaded from the Astral python-build-standalone project. This variable can be set to a mirror URL to use a different source for Python installations. The provided URL will replace https://github.com/astral-sh/python-build-standalone/releases/download in, e.g., https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz. Distributions can be read from a local directory by using the file:// URL scheme.`,
type: 'url',
defaultValue: ''
defaultValue: '',
attrs: {
validateUrlFn(mirror: string) {
return checkMirrorReachable(
mirror + PYTHON_MIRROR.validationPathSuffix
)
}
}
},
{
id: 'Comfy-Desktop.UV.PypiInstallMirror',
name: 'Pypi Install Mirror',
tooltip: `Default pip install mirror`,
type: 'url',
defaultValue: ''
defaultValue: '',
attrs: {
validateUrlFn: checkMirrorReachable
}
},
{
id: 'Comfy-Desktop.UV.TorchInstallMirror',
name: 'Torch Install Mirror',
tooltip: `Pip install mirror for pytorch`,
type: 'url',
defaultValue: ''
defaultValue: '',
attrs: {
validateUrlFn: checkMirrorReachable
}
}
],