mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
[Desktop] Fix torch mirror setting (#2475)
This commit is contained in:
@@ -80,11 +80,28 @@ const getTorchMirrorItem = (device: TorchDeviceType): UVMirror => {
|
||||
}
|
||||
}
|
||||
|
||||
const mirrors = computed<[UVMirror, ModelRef<string>][]>(() => [
|
||||
[PYTHON_MIRROR, pythonMirror],
|
||||
[PYPI_MIRROR, pypiMirror],
|
||||
[getTorchMirrorItem(device), torchMirror]
|
||||
])
|
||||
const userIsInChina = ref(false)
|
||||
onMounted(async () => {
|
||||
userIsInChina.value = await isInChina()
|
||||
})
|
||||
|
||||
const useFallbackMirror = (mirror: UVMirror) => ({
|
||||
...mirror,
|
||||
mirror: mirror.fallbackMirror
|
||||
})
|
||||
|
||||
const mirrors = computed<[UVMirror, ModelRef<string>][]>(() =>
|
||||
(
|
||||
[
|
||||
[PYTHON_MIRROR, pythonMirror],
|
||||
[PYPI_MIRROR, pypiMirror],
|
||||
[getTorchMirrorItem(device), torchMirror]
|
||||
] as [UVMirror, ModelRef<string>][]
|
||||
).map(([item, modelValue]) => [
|
||||
userIsInChina.value ? useFallbackMirror(item) : item,
|
||||
modelValue
|
||||
])
|
||||
)
|
||||
|
||||
const validationStates = ref<ValidationState[]>(
|
||||
mirrors.value.map(() => ValidationState.IDLE)
|
||||
@@ -102,13 +119,4 @@ const validationStateTooltip = computed(() => {
|
||||
return t('install.settings.checkingMirrors')
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
// Check if user is in China and set fallback mirrors directly
|
||||
if (await isInChina()) {
|
||||
for (const [item, modelValue] of mirrors.value) {
|
||||
modelValue.value = item.fallbackMirror
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -44,10 +44,7 @@ const normalizedSettingId = computed(() => {
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// Set mirror value if not already set
|
||||
if (!modelValue.value) {
|
||||
modelValue.value = item.mirror
|
||||
}
|
||||
modelValue.value = item.mirror
|
||||
})
|
||||
|
||||
watch(validationState, (newState) => {
|
||||
|
||||
Reference in New Issue
Block a user