mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
feat(pluginStore): add default plugin store source identification and update localization strings
This commit is contained in:
@@ -20,7 +20,12 @@ import { pluginStoreApi } from '@/services/api';
|
||||
import { useAuthStore, useConfigStore, useNotificationStore } from '@/stores';
|
||||
import { getErrorMessage, isRecord } from '@/utils/helpers';
|
||||
import type { PluginStoreEntry, PluginStoreResponse } from '@/types';
|
||||
import { buildRepositoryURL, isOfficialPlugin, resolvePluginAssetURL } from './pluginResources';
|
||||
import {
|
||||
buildRepositoryURL,
|
||||
isDefaultPluginStoreSource,
|
||||
isOfficialPlugin,
|
||||
resolvePluginAssetURL,
|
||||
} from './pluginResources';
|
||||
import { PluginInstallGateModal } from './components/PluginInstallGateModal';
|
||||
import styles from './PluginStorePage.module.scss';
|
||||
|
||||
@@ -327,9 +332,10 @@ export function PluginStorePage() {
|
||||
: entry.version
|
||||
? `v${entry.version}`
|
||||
: '';
|
||||
const sourceText = entry.sourceName
|
||||
? t('plugin_store.source_name', { source: entry.sourceName })
|
||||
: '';
|
||||
const sourceName = isDefaultPluginStoreSource(entry)
|
||||
? t('plugin_store.cli_proxy_api_source')
|
||||
: entry.sourceName;
|
||||
const sourceText = sourceName ? t('plugin_store.source_name', { source: sourceName }) : '';
|
||||
const metaItems = [versionText, sourceText, entry.author, entry.license].filter(Boolean);
|
||||
const isInstalling = installingKey === entryKey;
|
||||
const hasPendingInstall = Boolean(installingKey);
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { PluginStoreEntry } from '@/types';
|
||||
import {
|
||||
getPluginConfirmToken,
|
||||
getPluginRepositorySlug,
|
||||
isDefaultPluginStoreSource,
|
||||
resolvePluginAssetURL,
|
||||
} from '../pluginResources';
|
||||
import styles from './PluginInstallGateModal.module.scss';
|
||||
@@ -61,7 +62,10 @@ export function PluginInstallGateModal({
|
||||
const repoSlug = getPluginRepositorySlug(entry.repository);
|
||||
const token = getPluginConfirmToken(entry);
|
||||
const logo = resolvePluginAssetURL(entry.logo, apiBase);
|
||||
const sourceText = entry.sourceName || entry.sourceUrl;
|
||||
const rawSourceText = entry.sourceName || entry.sourceUrl;
|
||||
const sourceText = isDefaultPluginStoreSource(entry)
|
||||
? t('plugin_store.cli_proxy_api_source')
|
||||
: rawSourceText;
|
||||
const tokenMatches = typed.trim() === token;
|
||||
|
||||
const handleClose = () => {
|
||||
|
||||
@@ -46,6 +46,8 @@ export const buildRepositoryURL = (repository: string) => {
|
||||
// hosts like "https://github.com.evil.com/router-for-me/..." from being
|
||||
// mistaken for the official org.
|
||||
export const OFFICIAL_PLUGIN_REPO_PREFIX = 'https://github.com/router-for-me/';
|
||||
export const DEFAULT_PLUGIN_STORE_SOURCE_ID = 'official';
|
||||
const DEFAULT_PLUGIN_STORE_SOURCE_NAME = 'official';
|
||||
|
||||
// Normalize an "owner/repo" slug or repository URL to a bare "owner/repo".
|
||||
export const getPluginRepositorySlug = (repository: string): string => {
|
||||
@@ -72,6 +74,12 @@ export const isOfficialRepository = (repository: string): boolean =>
|
||||
export const isOfficialPlugin = (entry: PluginStoreEntry): boolean =>
|
||||
isOfficialRepository(entry.repository);
|
||||
|
||||
export const isDefaultPluginStoreSource = (
|
||||
entry: Pick<PluginStoreEntry, 'sourceId' | 'sourceName'>
|
||||
): boolean =>
|
||||
entry.sourceId.trim().toLowerCase() === DEFAULT_PLUGIN_STORE_SOURCE_ID ||
|
||||
entry.sourceName.trim().toLowerCase() === DEFAULT_PLUGIN_STORE_SOURCE_NAME;
|
||||
|
||||
// The string a user must retype to confirm a risky install: the repo slug when
|
||||
// available (most faithful to the source), otherwise the plugin id.
|
||||
export const getPluginConfirmToken = (entry: PluginStoreEntry): string =>
|
||||
|
||||
@@ -1174,6 +1174,7 @@
|
||||
"description_show_more": "Show more",
|
||||
"description_show_less": "Show less",
|
||||
"source_name": "Source: {{source}}",
|
||||
"cli_proxy_api_source": "CLIProxyAPI source",
|
||||
"refresh": "Refresh",
|
||||
"retry": "Retry",
|
||||
"load_failed": "Failed to load the plugin store",
|
||||
|
||||
@@ -1161,6 +1161,7 @@
|
||||
"description_show_more": "Показать больше",
|
||||
"description_show_less": "Свернуть",
|
||||
"source_name": "Источник: {{source}}",
|
||||
"cli_proxy_api_source": "Источник CLIProxyAPI",
|
||||
"refresh": "Обновить",
|
||||
"retry": "Повторить",
|
||||
"load_failed": "Не удалось загрузить магазин плагинов",
|
||||
|
||||
@@ -1174,6 +1174,7 @@
|
||||
"description_show_more": "展开描述",
|
||||
"description_show_less": "收起描述",
|
||||
"source_name": "来源:{{source}}",
|
||||
"cli_proxy_api_source": "CLIProxyAPI源",
|
||||
"refresh": "刷新",
|
||||
"retry": "重试",
|
||||
"load_failed": "插件商店加载失败",
|
||||
|
||||
@@ -1200,6 +1200,7 @@
|
||||
"description_show_more": "展開描述",
|
||||
"description_show_less": "收起描述",
|
||||
"source_name": "來源:{{source}}",
|
||||
"cli_proxy_api_source": "CLIProxyAPI來源",
|
||||
"refresh": "重新整理",
|
||||
"retry": "重試",
|
||||
"load_failed": "插件商店載入失敗",
|
||||
|
||||
Reference in New Issue
Block a user