mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 03:56:55 +03:00
feat: change dns check output
This commit is contained in:
@@ -11,3 +11,4 @@ export * from './splitProxyString';
|
|||||||
export * from './preserveScrollForPage';
|
export * from './preserveScrollForPage';
|
||||||
export * from './parseQueryString';
|
export * from './parseQueryString';
|
||||||
export * from './svgEl';
|
export * from './svgEl';
|
||||||
|
export * from './insertIf';
|
||||||
|
|||||||
7
fe-app-podkop/src/helpers/insertIf.ts
Normal file
7
fe-app-podkop/src/helpers/insertIf.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export function insertIf<T>(condition: boolean, elements: Array<T>) {
|
||||||
|
return condition ? elements : ([] as Array<T>);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function insertIfObj<T>(condition: boolean, object: T) {
|
||||||
|
return condition ? object : ({} as T);
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import { getDNSCheck } from '../../../methods';
|
import { getDNSCheck } from '../../../methods';
|
||||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||||
|
import { insertIf } from '../../../../helpers';
|
||||||
|
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||||
|
|
||||||
export async function runDnsCheck() {
|
export async function runDnsCheck() {
|
||||||
const code = 'dns_check';
|
const code = 'dns_check';
|
||||||
@@ -58,20 +60,25 @@ export async function runDnsCheck() {
|
|||||||
description: _('DNS checks passed'),
|
description: _('DNS checks passed'),
|
||||||
state: getStatus(),
|
state: getStatus(),
|
||||||
items: [
|
items: [
|
||||||
{
|
...insertIf<IDiagnosticsChecksItem>(
|
||||||
state: data.bootstrap_dns_status ? 'success' : 'error',
|
data.dns_type === 'doh' || data.dns_type === 'dot',
|
||||||
key: _('Bootsrap DNS'),
|
[
|
||||||
value: data.bootstrap_dns_server,
|
{
|
||||||
},
|
state: data.bootstrap_dns_status ? 'success' : 'error',
|
||||||
|
key: _('Bootsrap DNS'),
|
||||||
|
value: `${data.bootstrap_dns_server} ${data.bootstrap_dns_status ? '✅' : '❌'}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
{
|
{
|
||||||
state: data.dns_status ? 'success' : 'error',
|
state: data.dns_status ? 'success' : 'error',
|
||||||
key: _('Main DNS'),
|
key: _('Main DNS'),
|
||||||
value: `${data.dns_server} [${data.dns_type}]`,
|
value: `${data.dns_server} [${data.dns_type}] ${data.dns_status ? '✅' : '❌'}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.local_dns_status ? 'success' : 'error',
|
state: data.local_dns_status ? 'success' : 'error',
|
||||||
key: _('Local DNS'),
|
key: _('Local DNS'),
|
||||||
value: data.local_dns_status ? _('Enabled') : _('Failed'),
|
value: data.local_dns_status ? '✅' : '❌',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -112,16 +112,18 @@ class Store<T extends Record<string, any>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IDiagnosticsChecksItem {
|
||||||
|
state: 'error' | 'warning' | 'success';
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IDiagnosticsChecksStoreItem {
|
export interface IDiagnosticsChecksStoreItem {
|
||||||
code: string;
|
code: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
state: 'loading' | 'warning' | 'success' | 'error' | 'skipped';
|
state: 'loading' | 'warning' | 'success' | 'error' | 'skipped';
|
||||||
items: Array<{
|
items: Array<IDiagnosticsChecksItem>;
|
||||||
state: 'error' | 'warning' | 'success';
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StoreType {
|
export interface StoreType {
|
||||||
|
|||||||
@@ -768,6 +768,14 @@ function svgEl(tag, attrs = {}, children = []) {
|
|||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/helpers/insertIf.ts
|
||||||
|
function insertIf(condition, elements) {
|
||||||
|
return condition ? elements : [];
|
||||||
|
}
|
||||||
|
function insertIfObj(condition, object) {
|
||||||
|
return condition ? object : {};
|
||||||
|
}
|
||||||
|
|
||||||
// src/validators/validateVlessUrl.ts
|
// src/validators/validateVlessUrl.ts
|
||||||
function validateVlessUrl(url) {
|
function validateVlessUrl(url) {
|
||||||
try {
|
try {
|
||||||
@@ -2538,20 +2546,25 @@ async function runDnsCheck() {
|
|||||||
description: _("DNS checks passed"),
|
description: _("DNS checks passed"),
|
||||||
state: getStatus(),
|
state: getStatus(),
|
||||||
items: [
|
items: [
|
||||||
{
|
...insertIf(
|
||||||
state: data.bootstrap_dns_status ? "success" : "error",
|
data.dns_type === "doh" || data.dns_type === "dot",
|
||||||
key: _("Bootsrap DNS"),
|
[
|
||||||
value: data.bootstrap_dns_server
|
{
|
||||||
},
|
state: data.bootstrap_dns_status ? "success" : "error",
|
||||||
|
key: _("Bootsrap DNS"),
|
||||||
|
value: `${data.bootstrap_dns_server} ${data.bootstrap_dns_status ? "\u2705" : "\u274C"}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
),
|
||||||
{
|
{
|
||||||
state: data.dns_status ? "success" : "error",
|
state: data.dns_status ? "success" : "error",
|
||||||
key: _("Main DNS"),
|
key: _("Main DNS"),
|
||||||
value: `${data.dns_server} [${data.dns_type}]`
|
value: `${data.dns_server} [${data.dns_type}] ${data.dns_status ? "\u2705" : "\u274C"}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.local_dns_status ? "success" : "error",
|
state: data.local_dns_status ? "success" : "error",
|
||||||
key: _("Local DNS"),
|
key: _("Local DNS"),
|
||||||
value: data.local_dns_status ? _("Enabled") : _("Failed")
|
value: data.local_dns_status ? "\u2705" : "\u274C"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -2812,6 +2825,8 @@ return baseclass.extend({
|
|||||||
initDashboardController,
|
initDashboardController,
|
||||||
initDiagnosticController,
|
initDiagnosticController,
|
||||||
injectGlobalStyles,
|
injectGlobalStyles,
|
||||||
|
insertIf,
|
||||||
|
insertIfObj,
|
||||||
maskIP,
|
maskIP,
|
||||||
onMount,
|
onMount,
|
||||||
parseQueryString,
|
parseQueryString,
|
||||||
|
|||||||
Reference in New Issue
Block a user