fix: correct proxy string label displaying on dashboard

This commit is contained in:
divocat
2025-10-07 20:34:38 +03:00
parent 72b2a34af9
commit 48c8f01d2f
7 changed files with 35 additions and 21 deletions

View File

@@ -7,3 +7,4 @@ export * from './maskIP';
export * from './getProxyUrlName'; export * from './getProxyUrlName';
export * from './onMount'; export * from './onMount';
export * from './getClashApiUrl'; export * from './getClashApiUrl';
export * from './splitProxyString';

View File

@@ -0,0 +1,7 @@
export function splitProxyString(str: string) {
return str
.split('\n')
.map((line) => line.trim())
.filter((line) => !line.startsWith('//'))
.filter(Boolean);
}

View File

@@ -1,7 +1,7 @@
import { Podkop } from '../types'; import { Podkop } from '../types';
import { getConfigSections } from './getConfigSections'; import { getConfigSections } from './getConfigSections';
import { getClashProxies } from '../../clash'; import { getClashProxies } from '../../clash';
import { getProxyUrlName } from '../../helpers'; import { getProxyUrlName, splitProxyString } from '../../helpers';
interface IGetDashboardSectionsResponse { interface IGetDashboardSectionsResponse {
success: boolean; success: boolean;
@@ -35,6 +35,11 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
(proxy) => proxy.code === `${section['.name']}-out`, (proxy) => proxy.code === `${section['.name']}-out`,
); );
const activeConfigs = splitProxyString(section.proxy_string);
const proxyDisplayName =
getProxyUrlName(activeConfigs?.[0]) || outbound?.value?.name || '';
return { return {
withTagSelect: false, withTagSelect: false,
code: outbound?.code || section['.name'], code: outbound?.code || section['.name'],
@@ -42,10 +47,7 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
outbounds: [ outbounds: [
{ {
code: outbound?.code || section['.name'], code: outbound?.code || section['.name'],
displayName: displayName: proxyDisplayName,
getProxyUrlName(section.proxy_string) ||
outbound?.value?.name ||
'',
latency: outbound?.value?.history?.[0]?.delay || 0, latency: outbound?.value?.history?.[0]?.delay || 0,
type: outbound?.value?.type || '', type: outbound?.value?.type || '',
selected: true, selected: true,

View File

@@ -2,7 +2,7 @@ import { ValidationResult } from './types';
export function validateDomain( export function validateDomain(
domain: string, domain: string,
allowDotTLD = false allowDotTLD = false,
): ValidationResult { ): ValidationResult {
const domainRegex = const domainRegex =
/^(?=.{1,253}(?:\/|$))(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9-]{1,59}[a-zA-Z0-9])(?:\/[^\s]*)?$/; /^(?=.{1,253}(?:\/|$))(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9-]{1,59}[a-zA-Z0-9])(?:\/[^\s]*)?$/;

View File

@@ -130,11 +130,7 @@ function createConfigSection(section) {
} }
try { try {
const activeConfigs = value const activeConfigs = main.splitProxyString(value);
.split('\n')
.map((line) => line.trim())
.filter((line) => !line.startsWith('//'))
.filter(Boolean);
if (!activeConfigs.length) { if (!activeConfigs.length) {
return _( return _(

View File

@@ -771,6 +771,11 @@ function getClashWsUrl() {
return `ws://${hostname}:9090`; return `ws://${hostname}:9090`;
} }
// src/helpers/splitProxyString.ts
function splitProxyString(str) {
return str.split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("//")).filter(Boolean);
}
// src/clash/methods/createBaseApiRequest.ts // src/clash/methods/createBaseApiRequest.ts
async function createBaseApiRequest(fetchFn) { async function createBaseApiRequest(fetchFn) {
try { try {
@@ -899,6 +904,8 @@ async function getDashboardSections() {
const outbound = proxies.find( const outbound = proxies.find(
(proxy) => proxy.code === `${section[".name"]}-out` (proxy) => proxy.code === `${section[".name"]}-out`
); );
const activeConfigs = splitProxyString(section.proxy_string);
const proxyDisplayName = getProxyUrlName(activeConfigs?.[0]) || outbound?.value?.name || "";
return { return {
withTagSelect: false, withTagSelect: false,
code: outbound?.code || section[".name"], code: outbound?.code || section[".name"],
@@ -906,7 +913,7 @@ async function getDashboardSections() {
outbounds: [ outbounds: [
{ {
code: outbound?.code || section[".name"], code: outbound?.code || section[".name"],
displayName: getProxyUrlName(section.proxy_string) || outbound?.value?.name || "", displayName: proxyDisplayName,
latency: outbound?.value?.history?.[0]?.delay || 0, latency: outbound?.value?.history?.[0]?.delay || 0,
type: outbound?.value?.type || "", type: outbound?.value?.type || "",
selected: true selected: true
@@ -1897,6 +1904,7 @@ return baseclass.extend({
onMount, onMount,
parseValueList, parseValueList,
renderDashboard, renderDashboard,
splitProxyString,
triggerLatencyGroupTest, triggerLatencyGroupTest,
triggerLatencyProxyTest, triggerLatencyProxyTest,
triggerProxySelector, triggerProxySelector,