Skip to content

Commit

Permalink
Add mirror settings
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Jan 24, 2025
1 parent d8f515a commit d68f6a7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 3 deletions.
89 changes: 88 additions & 1 deletion src/components/install/DesktopSettingsConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,47 @@
</div>
<ToggleSwitch v-model="allowMetrics" />
</div>

<!-- Mirror Settings (Conditional) -->
<template v-if="showMirrorInputs">
<Divider />

<!-- Python Mirror Setting -->
<div class="flex flex-col items-center gap-4">
<div class="w-full">
<h3 class="text-lg font-medium text-neutral-100">
{{ $t('settings.Comfy-Desktop_PythonInstallMirror.name') }}
</h3>
<p class="text-sm text-neutral-400 mt-1">
{{ $t('settings.Comfy-Desktop_PythonInstallMirror.tooltip') }}
</p>
</div>
<UrlInput
v-model="pythonMirror"
:placeholder="$t('install.settings.pythonMirrorPlaceholder')"
:validate-url-fn="checkPythonMirrorReachable"
/>
</div>

<Divider />

<!-- Pypi Mirror Setting -->
<div class="flex flex-col items-center gap-4">
<div class="w-full">
<h3 class="text-lg font-medium text-neutral-100">
{{ $t('settings.Comfy-Desktop_PypiMirror.name') }}
</h3>
<p class="text-sm text-neutral-400 mt-1">
{{ $t('settings.Comfy-Desktop_PypiMirror.tooltip') }}
</p>
</div>
<UrlInput
v-model="pypiMirror"
:placeholder="$t('install.settings.pypiMirrorPlaceholder')"
:validate-url-fn="checkPypiMirrorReachable"
/>
</div>
</template>
</div>

<!-- Info Dialog -->
Expand Down Expand Up @@ -127,11 +168,57 @@
import Dialog from 'primevue/dialog'
import Divider from 'primevue/divider'
import ToggleSwitch from 'primevue/toggleswitch'
import { ref } from 'vue'
import { onMounted, ref } from 'vue'
import UrlInput from '@/components/common/UrlInput.vue'
import {
DEFAULT_UV_PYPY_INSTALL_MIRROR,
DEFAULT_UV_PYTHON_INSTALL_MIRROR,
FALLBACK_UV_PYPY_INSTALL_MIRROR,
FALLBACK_UV_PYTHON_INSTALL_MIRROR
} from '@/constants/uvMirrors'
import { electronAPI } from '@/utils/envUtil'
import { isValidUrl } from '@/utils/formatUtil'
const showDialog = ref(false)
const showMirrorInputs = ref(false)
const autoUpdate = defineModel<boolean>('autoUpdate', { required: true })
const allowMetrics = defineModel<boolean>('allowMetrics', { required: true })
const pythonMirror = defineModel<string>('pythonMirror', { required: true })
const pypiMirror = defineModel<string>('pypiMirror', { required: true })
const checkPythonMirrorReachable = async (mirror: string) => {
return (
isValidUrl(mirror) &&
(await electronAPI().NetWork.canAccessUrl(
`${mirror}/cpython-3.10.16+20250115-aarch64-apple-darwin-debug-full.tar.zst`
))
)
}
const checkPypiMirrorReachable = async (mirror: string) => {
return (
isValidUrl(mirror) &&
(await electronAPI().NetWork.canAccessUrl(
`${mirror}/pypy3.8-v7.3.7-osx64.tar.bz2`
))
)
}
onMounted(async () => {
const isPythonMirrorReachable = await checkPythonMirrorReachable(
DEFAULT_UV_PYTHON_INSTALL_MIRROR
)
const isPypiMirrorReachable = await checkPypiMirrorReachable(
DEFAULT_UV_PYPY_INSTALL_MIRROR
)
showMirrorInputs.value = !isPythonMirrorReachable || !isPypiMirrorReachable
if (showMirrorInputs.value) {
pythonMirror.value = FALLBACK_UV_PYTHON_INSTALL_MIRROR
pypiMirror.value = FALLBACK_UV_PYPY_INSTALL_MIRROR
}
})
const showMetricsInfo = () => {
showDialog.value = true
Expand Down
15 changes: 14 additions & 1 deletion src/extensions/core/electronAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { t } from '@/i18n'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { useSettingStore } from '@/stores/settingStore'
import { useWorkflowStore } from '@/stores/workflowStore'
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'

Expand Down Expand Up @@ -55,6 +54,20 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'

electronAPI.Config.setWindowStyle(newValue)
}
},
{
id: 'Comfy-Desktop.UV.PythonInstallMirror',
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: ''
},
{
id: 'Comfy-Desktop.UV.PypiInstallMirror',
name: 'Pypi Install Mirror',
tooltip: `Managed PyPy installations are downloaded from python.org. This variable can be set to a mirror URL to use a different source for PyPy installations. The provided URL will replace https://downloads.python.org/pypy in, e.g., https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2. Distributions can be read from a local directory by using the file:// URL scheme`,
type: 'url',
defaultValue: ''
}
],

Expand Down
4 changes: 3 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@
"customNodeConfigurations": "Custom node configurations"
},
"viewFullPolicy": "View full policy"
}
},
"pythonMirrorPlaceholder": "Enter Python mirror URL",
"pypiMirrorPlaceholder": "Enter PyPI mirror URL"
},
"customNodes": "Custom Nodes",
"customNodesDescription": "Reinstall custom nodes from existing ComfyUI installations.",
Expand Down
6 changes: 6 additions & 0 deletions src/views/InstallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
<DesktopSettingsConfiguration
v-model:autoUpdate="autoUpdate"
v-model:allowMetrics="allowMetrics"
v-model:pythonMirror="pythonMirror"
v-model:pypiMirror="pypiMirror"
/>
<div class="flex pt-6 justify-between">
<Button
Expand Down Expand Up @@ -133,6 +135,8 @@ const migrationItemIds = ref<string[]>([])
const autoUpdate = ref(true)
const allowMetrics = ref(true)
const pythonMirror = ref('')
const pypiMirror = ref('')
/** Forces each install step to be visited at least once. */
const highestStep = ref(0)
Expand Down Expand Up @@ -162,6 +166,8 @@ const install = () => {
allowMetrics: allowMetrics.value,
migrationSourcePath: migrationSourcePath.value,
migrationItemIds: toRaw(migrationItemIds.value),
pythonMirror: pythonMirror.value,
pypiMirror: pypiMirror.value,
device: device.value
}
electron.installComfyUI(options)
Expand Down

0 comments on commit d68f6a7

Please sign in to comment.