refactor: 调整后端插件路由插件url策略,以自适应后端服务变更

pull/81/head
moonrailgun 3 years ago
parent f274fc6ce9
commit c0d186770c

@ -34,9 +34,12 @@ Nightly版 体验地址: [https://nightly.paw.msgbyte.com/](https://nightly.paw.
```bash
pnpm install
cd web
pnpm build
SERVICE_URL=http://127.0.0.1:11000 pnpm build
```
环境变量:
- `SERVICE_URL`: 后端服务的地址
使用任意方式代理 `web/dist` 目录即可。

@ -1,3 +1,4 @@
import { getServiceUrl } from '../manager/service';
import { ChatConverseInfo, fetchConverseInfo } from '../model/converse';
import { findGroupInviteByCode, GroupInvite } from '../model/group';
import {
@ -62,7 +63,15 @@ export async function getCachedRegistryPlugins(): Promise<PluginManifest[]> {
() =>
Promise.all([
fetchRegistryPlugins().catch(() => []),
fetchServiceRegistryPlugins().catch(() => []),
fetchServiceRegistryPlugins()
.then((list) =>
list.map((manifest) => ({
...manifest,
// 后端url策略。根据前端的url在获取时自动变更为当前链接的后端地址
url: String(manifest.url).replace('{BACKEND}', getServiceUrl()),
}))
)
.catch(() => []),
fetchLocalStaticRegistryPlugins().catch(() => []),
]).then(([a, b, c]) => [...a, ...b, ...c]),
{

@ -65,7 +65,7 @@ export async function fetchRegistryPlugins(): Promise<PluginManifest[]> {
*
*
*/
export async function fetchServiceRegistryPlugins() {
export async function fetchServiceRegistryPlugins(): Promise<PluginManifest[]> {
const { data } = await request.get('/registry.json');
return data;

Loading…
Cancel
Save