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[]