mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-05 00:04:32 +08:00
fix: limit custom title to browser tab
This commit is contained in:
committed by
GitHub
parent
3e308cf9d7
commit
2e33cbae3a
+13
-2
@@ -47,7 +47,9 @@ export default function () {
|
||||
const [user, setUser] = useState<any>({});
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [systemInfo, setSystemInfo] = useState<TSystemInfo>();
|
||||
const [siteTitle, setSiteTitle] = useState(config.siteName);
|
||||
const [siteTitle, setSiteTitle] = useState(
|
||||
() => localStorage.getItem('qinglong_panel_title')?.trim() || intl.get('青龙'),
|
||||
);
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
const [initLoading, setInitLoading] = useState<boolean>(true);
|
||||
const {
|
||||
@@ -166,6 +168,15 @@ export default function () {
|
||||
reloadSystemConfig();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!['/login', '/initialization', '/error'].includes(location.pathname)) {
|
||||
return;
|
||||
}
|
||||
const title =
|
||||
(config.documentTitleMap as any)[location.pathname] || intl.get('未找到');
|
||||
document.title = `${title} - ${siteTitle}`;
|
||||
}, [location.pathname, siteTitle]);
|
||||
|
||||
useEffect(() => {
|
||||
if (theme === 'vs-dark') {
|
||||
document.body.setAttribute('data-dark', 'true');
|
||||
@@ -281,7 +292,7 @@ export default function () {
|
||||
<>
|
||||
<Image preview={false} src="https://qn.whyour.cn/logo.png" />
|
||||
<div className="title">
|
||||
<span className="title">{siteTitle}</span>
|
||||
<span className="title">{intl.get('青龙')}</span>
|
||||
<span
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
+1
-4
@@ -1,11 +1,8 @@
|
||||
import intl from 'react-intl-universal';
|
||||
const baseUrl = window.__ENV__QlBaseUrl || '/';
|
||||
const defaultSiteName = intl.get('青龙');
|
||||
const siteName =
|
||||
localStorage.getItem('qinglong_panel_title')?.trim() || defaultSiteName;
|
||||
|
||||
export default {
|
||||
siteName,
|
||||
siteName: intl.get('青龙'),
|
||||
baseUrl,
|
||||
apiPrefix: `${baseUrl}api/`,
|
||||
authKey: 'token',
|
||||
|
||||
Reference in New Issue
Block a user