mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-27 12:50:37 +03:00
fix: correct proxy string label displaying on dashboard
This commit is contained in:
@@ -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';
|
||||||
|
|||||||
7
fe-app-podkop/src/helpers/splitProxyString.ts
Normal file
7
fe-app-podkop/src/helpers/splitProxyString.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export function splitProxyString(str: string) {
|
||||||
|
return str
|
||||||
|
.split('\n')
|
||||||
|
.map((line) => line.trim())
|
||||||
|
.filter((line) => !line.startsWith('//'))
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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]*)?$/;
|
||||||
|
|||||||
@@ -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 _(
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user