diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index a1029246c..3d4d08769 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -376,14 +376,14 @@ class PluginManager: logger.debug(f"unbind handler {v.handler_name} from {plugin_name} (map)") del star_handlers_registry.star_handlers_map[k] - async def update_plugin(self, plugin_name: str): + async def update_plugin(self, plugin_name: str, proxy = ""): plugin = self.context.get_registered_star(plugin_name) if not plugin: raise Exception("插件不存在。") if plugin.reserved: raise Exception("该插件是 AstrBot 保留插件,无法更新。") - await self.updator.update(plugin) + await self.updator.update(plugin, proxy=proxy) await self.reload() async def turn_off_plugin(self, plugin_name: str): diff --git a/astrbot/core/star/updator.py b/astrbot/core/star/updator.py index 02b9dc2da..3ea211432 100644 --- a/astrbot/core/star/updator.py +++ b/astrbot/core/star/updator.py @@ -23,12 +23,16 @@ class PluginUpdator(RepoZipUpdator): return plugin_path - async def update(self, plugin: StarMetadata) -> str: + async def update(self, plugin: StarMetadata, proxy="") -> str: repo_url = plugin.repo if not repo_url: raise Exception(f"插件 {plugin.name} 没有指定仓库地址。") + if proxy: + proxy = proxy.removesuffix("/") + repo_url = f"{proxy}/{repo_url}" + plugin_path = os.path.join(self.plugin_store_path, plugin.root_dir_name) logger.info(f"正在更新插件,路径: {plugin_path},仓库地址: {repo_url}") diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 0ff4fff6e..c75ec2294 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -142,6 +142,12 @@ class PluginRoute(Route): async def install_plugin(self): post_data = await request.json repo_url = post_data["url"] + + proxy: str = post_data.get("proxy", None) + if proxy: + proxy = proxy.removesuffix("/") + repo_url = f"{proxy}/{repo_url}" + try: logger.info(f"正在安装插件 {repo_url}") await self.plugin_manager.install_plugin(repo_url) @@ -182,9 +188,10 @@ class PluginRoute(Route): async def update_plugin(self): post_data = await request.json plugin_name = post_data["name"] + proxy: str = post_data.get("proxy", None) try: logger.info(f"正在更新插件 {plugin_name}") - await self.plugin_manager.update_plugin(plugin_name) + await self.plugin_manager.update_plugin(plugin_name, proxy) self.core_lifecycle.restart() logger.info(f"更新插件 {plugin_name} 成功。") return Response().ok(None, "更新成功。").__dict__ diff --git a/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts b/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts index bfccdbe91..0f6f69111 100644 --- a/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts +++ b/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts @@ -16,12 +16,12 @@ export interface menu { const sidebarItem: menu[] = [ { - title: '面板', + title: '统计', icon: 'mdi-view-dashboard', to: '/dashboard/default' }, { - title: '配置', + title: '配置文件', icon: 'mdi-cog', to: '/config', }, @@ -40,6 +40,11 @@ const sidebarItem: menu[] = [ icon: 'mdi-console', to: '/console' }, + { + title: '设置', + icon: 'mdi-wrench', + to: '/settings' + }, { title: '关于', icon: 'mdi-information', diff --git a/dashboard/src/router/MainRoutes.ts b/dashboard/src/router/MainRoutes.ts index 62a729e5c..bd407ad26 100644 --- a/dashboard/src/router/MainRoutes.ts +++ b/dashboard/src/router/MainRoutes.ts @@ -42,6 +42,11 @@ const MainRoutes = { path: '/chat', component: () => import('@/views/ChatPage.vue') }, + { + name: 'Settings', + path: '/settings', + component: () => import('@/views/Settings.vue') + }, { name: 'About', path: '/about', diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 2fe29479c..6a538add0 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -10,8 +10,8 @@ import { max } from 'date-fns';