From 5ad4448988d231e3534a63da0a3469c092d92122 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 23 Dec 2021 17:14:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=E6=8F=92=E4=BB=B6=E7=9A=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/cache/cache.ts | 8 +++++--- shared/model/plugin.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/shared/cache/cache.ts b/shared/cache/cache.ts index 2ec18d68..ae74af3b 100644 --- a/shared/cache/cache.ts +++ b/shared/cache/cache.ts @@ -3,6 +3,7 @@ import { findGroupInviteByCode, GroupInvite } from '../model/group'; import { fetchGithubStaticRegistryPlugins, fetchRegistryPlugins, + fetchServiceRegistryPlugins, PluginManifest, } from '../model/plugin'; import { fetchUserInfo, UserBaseInfo } from '../model/user'; @@ -60,9 +61,10 @@ export async function getCachedRegistryPlugins(): Promise { ['pluginRegistry'], () => Promise.all([ - fetchRegistryPlugins(), - fetchGithubStaticRegistryPlugins(), - ]).then(([a, b]) => [...a, ...b]), + fetchRegistryPlugins().catch(() => []), + fetchServiceRegistryPlugins().catch(() => []), + fetchGithubStaticRegistryPlugins().catch(() => []), + ]).then(([a, b, c]) => [...a, ...b, ...c]), { staleTime: 2 * 60 * 60 * 1000, // 缓存2小时 } diff --git a/shared/model/plugin.ts b/shared/model/plugin.ts index b73d812f..5501864c 100644 --- a/shared/model/plugin.ts +++ b/shared/model/plugin.ts @@ -49,14 +49,32 @@ export interface PluginManifest { requireRestart: boolean; } +/** + * 获取服务端插件中心的插件列表 + * + * 后端动态 + */ export async function fetchRegistryPlugins(): Promise { const { data } = await request.get('/api/plugin/registry/list'); return data; } +/** + * 获取服务器安装的插件列表 + * + * 后端固定 + */ +export async function fetchServiceRegistryPlugins() { + const { data } = await request.get('/registry.json'); + + return data; +} + /** * 获取官方Github注册表文件 + * + * 前端固定 */ export async function fetchGithubStaticRegistryPlugins(): Promise< PluginManifest[]