mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
[Desktop] Fix mirror validation in settings dialog (#2375)
This commit is contained in:
@@ -10,7 +10,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<UrlInput
|
<UrlInput
|
||||||
v-model="modelValue"
|
v-model="modelValue"
|
||||||
:validate-url-fn="checkMirrorReachable"
|
:validate-url-fn="
|
||||||
|
(mirror: string) =>
|
||||||
|
checkMirrorReachable(mirror + (item.validationPathSuffix ?? ''))
|
||||||
|
"
|
||||||
@state-change="validationState = $event"
|
@state-change="validationState = $event"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,8 +23,8 @@
|
|||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
import { UVMirror } from '@/constants/uvMirrors'
|
import { UVMirror } from '@/constants/uvMirrors'
|
||||||
import { electronAPI } from '@/utils/envUtil'
|
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||||
import { isValidUrl, normalizeI18nKey } from '@/utils/formatUtil'
|
import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||||
import { ValidationState } from '@/utils/validationUtil'
|
import { ValidationState } from '@/utils/validationUtil'
|
||||||
|
|
||||||
const { item } = defineProps<{
|
const { item } = defineProps<{
|
||||||
@@ -39,15 +42,6 @@ const normalizedSettingId = computed(() => {
|
|||||||
return normalizeI18nKey(item.settingId)
|
return normalizeI18nKey(item.settingId)
|
||||||
})
|
})
|
||||||
|
|
||||||
const checkMirrorReachable = async (mirror: string) => {
|
|
||||||
return (
|
|
||||||
isValidUrl(mirror) &&
|
|
||||||
(await electronAPI().NetWork.canAccessUrl(
|
|
||||||
mirror + (item.validationPathSuffix ?? '')
|
|
||||||
))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
modelValue.value = item.mirror
|
modelValue.value = item.mirror
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import { PYTHON_MIRROR } from '@/constants/uvMirrors'
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { app } from '@/scripts/app'
|
import { app } from '@/scripts/app'
|
||||||
import { useDialogService } from '@/services/dialogService'
|
import { useDialogService } from '@/services/dialogService'
|
||||||
import { useWorkflowStore } from '@/stores/workflowStore'
|
import { useWorkflowStore } from '@/stores/workflowStore'
|
||||||
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
||||||
|
import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
if (!isElectron()) return
|
if (!isElectron()) return
|
||||||
@@ -60,21 +62,34 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
|||||||
name: 'Python Install Mirror',
|
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.`,
|
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',
|
type: 'url',
|
||||||
defaultValue: ''
|
defaultValue: '',
|
||||||
|
attrs: {
|
||||||
|
validateUrlFn(mirror: string) {
|
||||||
|
return checkMirrorReachable(
|
||||||
|
mirror + PYTHON_MIRROR.validationPathSuffix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'Comfy-Desktop.UV.PypiInstallMirror',
|
id: 'Comfy-Desktop.UV.PypiInstallMirror',
|
||||||
name: 'Pypi Install Mirror',
|
name: 'Pypi Install Mirror',
|
||||||
tooltip: `Default pip install mirror`,
|
tooltip: `Default pip install mirror`,
|
||||||
type: 'url',
|
type: 'url',
|
||||||
defaultValue: ''
|
defaultValue: '',
|
||||||
|
attrs: {
|
||||||
|
validateUrlFn: checkMirrorReachable
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'Comfy-Desktop.UV.TorchInstallMirror',
|
id: 'Comfy-Desktop.UV.TorchInstallMirror',
|
||||||
name: 'Torch Install Mirror',
|
name: 'Torch Install Mirror',
|
||||||
tooltip: `Pip install mirror for pytorch`,
|
tooltip: `Pip install mirror for pytorch`,
|
||||||
type: 'url',
|
type: 'url',
|
||||||
defaultValue: ''
|
defaultValue: '',
|
||||||
|
attrs: {
|
||||||
|
validateUrlFn: checkMirrorReachable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import { electronAPI } from './envUtil'
|
||||||
|
import { isValidUrl } from './formatUtil'
|
||||||
|
|
||||||
const VALID_STATUS_CODES = [200, 201, 301, 302, 307, 308]
|
const VALID_STATUS_CODES = [200, 201, 301, 302, 307, 308]
|
||||||
export const checkUrlReachable = async (url: string): Promise<boolean> => {
|
export const checkUrlReachable = async (url: string): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
@@ -10,3 +13,14 @@ export const checkUrlReachable = async (url: string): Promise<boolean> => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a mirror is reachable from the electron App.
|
||||||
|
* @param mirror - The mirror to check.
|
||||||
|
* @returns True if the mirror is reachable, false otherwise.
|
||||||
|
*/
|
||||||
|
export const checkMirrorReachable = async (mirror: string) => {
|
||||||
|
return (
|
||||||
|
isValidUrl(mirror) && (await electronAPI().NetWork.canAccessUrl(mirror))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user