From cac64c0d2a80105db14ae04e0aeb4eacb148a771 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sun, 30 May 2021 16:33:27 +0800 Subject: Use vite --- src/components/shared/Head.tsx | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/components/shared') diff --git a/src/components/shared/Head.tsx b/src/components/shared/Head.tsx index 3f2e966..1622473 100644 --- a/src/components/shared/Head.tsx +++ b/src/components/shared/Head.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Helmet } from 'react-helmet'; import { connect } from 'src/components/StateProvider'; import { getClashAPIConfig, getClashAPIConfigs } from 'src/store/app'; @@ -8,21 +7,27 @@ const mapState = (s) => ({ apiConfigs: getClashAPIConfigs(s), }); -function HeadImpl({ apiConfig, apiConfigs }: { apiConfig: { baseURL: string }, apiConfigs: any[] }) { - let title = 'yacd'; - if (apiConfigs.length > 1) { - try { - const host = new URL(apiConfig.baseURL).host; - title = `${host} - yacd`; - } catch (e) { - // ignore +function HeadImpl({ + apiConfig, + apiConfigs, +}: { + apiConfig: { baseURL: string }; + apiConfigs: any[]; +}) { + React.useEffect(() => { + let title = 'yacd'; + if (apiConfigs.length > 1) { + try { + const host = new URL(apiConfig.baseURL).host; + title = `${host} - yacd`; + } catch (e) { + // ignore + } } - } - return ( - - {title} - - ); + document.title = title; + }); + + return <>; } export const Head = connect(mapState)(HeadImpl); -- cgit v1.3.1