diff --git a/.gitignore b/.gitignore index 1e7248a74..15ab085d4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,8 @@ addons/plugins tests/astrbot_plugin_openai chroma -node_modules/ +dashboard/node_modules/ +dashboard/dist/ .DS_Store package-lock.json package.json diff --git a/astrbot/core/updator.py b/astrbot/core/updator.py index 66322f4ec..a6aca5198 100644 --- a/astrbot/core/updator.py +++ b/astrbot/core/updator.py @@ -48,7 +48,7 @@ class AstrBotUpdator(RepoZipUpdator): async def check_update(self, url: str, current_version: str) -> ReleaseInfo: return await super().check_update(self.ASTRBOT_RELEASE_API, VERSION) - async def update(self, reboot = False, latest = True, version = None): + async def update(self, reboot = False, latest = True, version = None, proxy = ""): update_data = await self.fetch_release_info(self.ASTRBOT_RELEASE_API, latest) file_url = None @@ -70,6 +70,10 @@ class AstrBotUpdator(RepoZipUpdator): raise Exception("commit hash 长度不正确,应为 40") logger.info(f"正在尝试更新到指定 commit: {version}") file_url = "https://github.com/Soulter/AstrBot/archive/" + version + ".zip" + + if proxy: + proxy = proxy.removesuffix("/") + file_url = f"{proxy}/{file_url}" try: await download_file(file_url, "temp.zip") diff --git a/astrbot/dashboard/routes/update.py b/astrbot/dashboard/routes/update.py index d5e06e652..b0eb45d8c 100644 --- a/astrbot/dashboard/routes/update.py +++ b/astrbot/dashboard/routes/update.py @@ -56,8 +56,13 @@ class UpdateRoute(Route): version = '' else: latest = False + + proxy: str = data.get("proxy", None) + if proxy: + proxy = proxy.removesuffix("/") + try: - await self.astrbot_updator.update(latest=latest, version=version) + await self.astrbot_updator.update(latest=latest, version=version, proxy=proxy) if latest: try: diff --git a/dashboard/src/layouts/full/vertical-header/VerticalHeader.vue b/dashboard/src/layouts/full/vertical-header/VerticalHeader.vue index 37686d2ca..8c9eb87c8 100644 --- a/dashboard/src/layouts/full/vertical-header/VerticalHeader.vue +++ b/dashboard/src/layouts/full/vertical-header/VerticalHeader.vue @@ -86,7 +86,8 @@ function checkUpdate() { function switchVersion(version: string) { updateStatus.value = '正在切换版本...'; axios.post('/api/update/do', { - version: version + version: version, + proxy: localStorage.getItem('selectedGitHubProxy') || '' }) .then((res) => { updateStatus.value = res.data.message; diff --git a/dashboard/src/views/Settings.vue b/dashboard/src/views/Settings.vue index fb8a20425..26ed09712 100644 --- a/dashboard/src/views/Settings.vue +++ b/dashboard/src/views/Settings.vue @@ -5,7 +5,7 @@ 网络 - +