feat: 支持 AstrBot 更新使用 Github 加速地址
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<v-list lines="two">
|
||||
<v-list-subheader>网络</v-list-subheader>
|
||||
|
||||
<v-list-item subtitle="设置下载插件时所用的 GitHub 加速地址。这在中国大陆的网络环境有效。可以自定义,输入结果实时生效" title="GitHub 加速地址">
|
||||
<v-list-item subtitle="设置下载插件或者更新 AstrBot 时所用的 GitHub 加速地址。这在中国大陆的网络环境有效。可以自定义,输入结果实时生效" title="GitHub 加速地址">
|
||||
|
||||
<v-combobox variant="outlined" style="width: 100%; margin-top: 16px;" v-model="selectedGitHubProxy" :items="githubProxies"
|
||||
label="选择 GitHub 加速地址">
|
||||
|
||||
Reference in New Issue
Block a user