Refine title style
Only show backend host when there are multiple backends.
This commit is contained in:
parent
d56fd19c5e
commit
c52a88acaf
1 changed files with 10 additions and 6 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue