feat: change dns check output

This commit is contained in:
divocat
2025-10-13 21:49:38 +03:00
parent 0fba31c10a
commit aea6fd9453
5 changed files with 51 additions and 19 deletions

View File

@@ -11,3 +11,4 @@ export * from './splitProxyString';
export * from './preserveScrollForPage';
export * from './parseQueryString';
export * from './svgEl';
export * from './insertIf';

View 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);
}

View File

@@ -1,5 +1,7 @@
import { getDNSCheck } from '../../../methods';
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
import { insertIf } from '../../../../helpers';
import { IDiagnosticsChecksItem } from '../../../../store';
export async function runDnsCheck() {
const code = 'dns_check';
@@ -58,20 +60,25 @@ export async function runDnsCheck() {
description: _('DNS checks passed'),
state: getStatus(),
items: [
{
state: data.bootstrap_dns_status ? 'success' : 'error',
key: _('Bootsrap DNS'),
value: data.bootstrap_dns_server,
},
...insertIf<IDiagnosticsChecksItem>(
data.dns_type === 'doh' || data.dns_type === 'dot',
[
{
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',
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',
key: _('Local DNS'),
value: data.local_dns_status ? _('Enabled') : _('Failed'),
value: data.local_dns_status ? '✅' : '❌',
},
],
});

View File

@@ -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 {
code: string;
title: string;
description: string;
state: 'loading' | 'warning' | 'success' | 'error' | 'skipped';
items: Array<{
state: 'error' | 'warning' | 'success';
key: string;
value: string;
}>;
items: Array<IDiagnosticsChecksItem>;
}
export interface StoreType {