fix: adapt dashboard for new sections structure

This commit is contained in:
divocat
2025-10-10 20:49:44 +03:00
parent b90f520c68
commit 1bdd49e198
3 changed files with 14 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ interface IGetDashboardSectionsResponse {
export async function getDashboardSections(): Promise<IGetDashboardSectionsResponse> {
const configSections = await getConfigSections();
console.log('configSections', configSections)
const clashProxies = await getClashProxies();
if (!clashProxies.success) {
@@ -27,9 +28,9 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
);
const data = configSections
.filter((section) => section.mode !== 'block')
.filter((section) => section.connection_type !== 'block' && section[".type"] !== 'settings')
.map((section) => {
if (section.mode === 'proxy') {
if (section.connection_type === 'proxy') {
if (section.proxy_config_type === 'url') {
const outbound = proxies.find(
(proxy) => proxy.code === `${section['.name']}-out`,
@@ -122,7 +123,7 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
}
}
if (section.mode === 'vpn') {
if (section.connection_type === 'vpn') {
const outbound = proxies.find(
(proxy) => proxy.code === `${section['.name']}-out`,
);

View File

@@ -16,30 +16,30 @@ export namespace Podkop {
}
export interface ConfigProxyUrlTestSection {
mode: 'proxy';
connection_type: 'proxy';
proxy_config_type: 'urltest';
urltest_proxy_links: string[];
}
export interface ConfigProxyUrlSection {
mode: 'proxy';
connection_type: 'proxy';
proxy_config_type: 'url';
proxy_string: string;
}
export interface ConfigProxyOutboundSection {
mode: 'proxy';
connection_type: 'proxy';
proxy_config_type: 'outbound';
outbound_json: string;
}
export interface ConfigVpnSection {
mode: 'vpn';
connection_type: 'vpn';
interface: string;
}
export interface ConfigBlockSection {
mode: 'block';
connection_type: 'block';
}
export type ConfigBaseSection =
@@ -51,6 +51,6 @@ export namespace Podkop {
export type ConfigSection = ConfigBaseSection & {
'.name': string;
'.type': 'main' | 'extra';
'.type': 'settings' | 'section';
};
}

View File

@@ -943,6 +943,7 @@ async function getConfigSections() {
// src/podkop/methods/getDashboardSections.ts
async function getDashboardSections() {
const configSections = await getConfigSections();
console.log("configSections", configSections);
const clashProxies = await getClashProxies();
if (!clashProxies.success) {
return {
@@ -956,8 +957,8 @@ async function getDashboardSections() {
value
})
);
const data = configSections.filter((section) => section.mode !== "block").map((section) => {
if (section.mode === "proxy") {
const data = configSections.filter((section) => section.connection_type !== "block" && section[".type"] !== "settings").map((section) => {
if (section.connection_type === "proxy") {
if (section.proxy_config_type === "url") {
const outbound = proxies.find(
(proxy) => proxy.code === `${section[".name"]}-out`
@@ -1032,7 +1033,7 @@ async function getDashboardSections() {
};
}
}
if (section.mode === "vpn") {
if (section.connection_type === "vpn") {
const outbound = proxies.find(
(proxy) => proxy.code === `${section[".name"]}-out`
);