Refine title style

Only show backend host when there are multiple backends.
This commit is contained in:
CzBiX 2021-02-23 19:49:20 +08:00 committed by CzBiX
parent d56fd19c5e
commit c52a88acaf

View file

@ -1,18 +1,22 @@
import * as React from 'react';
import { Helmet } from 'react-helmet';
import { connect } from 'src/components/StateProvider';
import { getClashAPIConfig } from 'src/store/app';
import { getClashAPIConfig, getClashAPIConfigs } from 'src/store/app';
const mapState = (s) => ({
apiConfig: getClashAPIConfig(s),
apiConfigs: getClashAPIConfigs(s),
});
function HeadImpl({ apiConfig }: { apiConfig: { baseURL: string } }) {
function HeadImpl({ apiConfig, apiConfigs }: { apiConfig: { baseURL: string }, apiConfigs: any[] }) {
let title = 'yacd';
try {
title = new URL(apiConfig.baseURL).host;
} catch (e) {
// ignore
if (apiConfigs.length > 1) {
try {
const host = new URL(apiConfig.baseURL).host;
title = `${host} - yacd`;
} catch (e) {
// ignore
}
}
return (
<Helmet>