From 8709ab35c8ee896e87431f8670193222376d65c7 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Sat, 9 Sep 2023 21:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E9=80=82=E9=85=8D=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20i18n=20=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/const/url.ts | 10 +++++++++- src/services/pluginMarket.ts | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/const/url.ts b/src/const/url.ts index 5c233c5f8be6..2d2df90c72b3 100644 --- a/src/const/url.ts +++ b/src/const/url.ts @@ -1,3 +1,5 @@ +import { Locales } from '@/locales/resources'; + import pkg from '../../package.json'; import { INBOX_SESSION_ID } from './session'; @@ -8,7 +10,13 @@ export const FEEDBACK = pkg.bugs.url; export const DISCORD = 'https://discord.gg/AYFPHvv2jT'; export const PLUGINS_INDEX_URL = - process.env.PLUGINS_INDEX_URL ?? 'https://chat-plugins.lobehub.com'; + process.env.PLUGINS_INDEX_URL ?? 'https://chat-plugins.lobehub.com/index'; + +export const getPluginIndexJSON = (lang: Locales = 'en-US', baseUrl = PLUGINS_INDEX_URL) => { + if (lang === 'en-US') return baseUrl; + + return `${baseUrl}.${lang}.json`; +}; export const AGENTS_INDEX_URL = process.env.AGENTS_INDEX_URL ?? 'https://chat-agents.lobehub.com'; diff --git a/src/services/pluginMarket.ts b/src/services/pluginMarket.ts index 3a485db32364..9f992845fd87 100644 --- a/src/services/pluginMarket.ts +++ b/src/services/pluginMarket.ts @@ -1,10 +1,13 @@ -import { PLUGINS_INDEX_URL } from '@/const/url'; +import { getPluginIndexJSON } from '@/const/url'; +import { useGlobalStore } from '@/store/global'; /** * 请求插件列表 */ export const getPluginList = async () => { - const res = await fetch(PLUGINS_INDEX_URL); + const url = getPluginIndexJSON(useGlobalStore.getState().settings.language); + + const res = await fetch(url); return res.json(); };