mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-27 18:06:08 +08:00
修复pageTitle
This commit is contained in:
parent
41ef87d9f8
commit
ea44e5f209
22
src/app.tsx
22
src/app.tsx
|
@ -1,22 +0,0 @@
|
||||||
import { history } from 'umi';
|
|
||||||
import { request } from '@/utils/http';
|
|
||||||
import config from '@/utils/config';
|
|
||||||
|
|
||||||
const titleMap: any = {
|
|
||||||
'/': '控制面板',
|
|
||||||
'/login': '登录',
|
|
||||||
'/crontab': '定时任务',
|
|
||||||
'/env': '环境变量',
|
|
||||||
'/config': '配置文件',
|
|
||||||
'/script': '脚本管理',
|
|
||||||
'/diff': '对比工具',
|
|
||||||
'/log': '任务日志',
|
|
||||||
'/setting': '系统设置',
|
|
||||||
};
|
|
||||||
|
|
||||||
export function onRouteChange({ matchedRoutes }: any) {
|
|
||||||
if (matchedRoutes.length) {
|
|
||||||
const path: string = matchedRoutes[matchedRoutes.length - 1].route.path;
|
|
||||||
document.title = `${titleMap[path]} - 控制面板`;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -62,9 +62,6 @@ export default {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
location: {
|
|
||||||
pathname: '/',
|
|
||||||
},
|
|
||||||
navTheme: 'light',
|
navTheme: 'light',
|
||||||
fixSiderbar: true,
|
fixSiderbar: true,
|
||||||
contentWidth: 'Fixed',
|
contentWidth: 'Fixed',
|
||||||
|
|
|
@ -56,9 +56,6 @@ export default function (props: any) {
|
||||||
history.push('/login');
|
history.push('/login');
|
||||||
}
|
}
|
||||||
vhCheck();
|
vhCheck();
|
||||||
|
|
||||||
// patch custome layout title as react node [object, object]
|
|
||||||
document.title = '控制面板';
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -135,7 +132,12 @@ export default function (props: any) {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}}
|
}}
|
||||||
pageTitleRender={() => '控制面板'}
|
pageTitleRender={(props, pageName, info) => {
|
||||||
|
if (info) {
|
||||||
|
return `${info.pageName} - 控制面板`;
|
||||||
|
}
|
||||||
|
return '控制面板';
|
||||||
|
}}
|
||||||
{...defaultProps}
|
{...defaultProps}
|
||||||
>
|
>
|
||||||
{React.Children.map(props.children, (child) => {
|
{React.Children.map(props.children, (child) => {
|
||||||
|
|
|
@ -42,7 +42,7 @@ const LangMap: any = {
|
||||||
const Script = ({ headerStyle, isPhone, theme }: any) => {
|
const Script = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
const [title, setTitle] = useState('请选择脚本文件');
|
const [title, setTitle] = useState('请选择脚本文件');
|
||||||
const [value, setValue] = useState('请选择脚本文件');
|
const [value, setValue] = useState('请选择脚本文件');
|
||||||
const [select, setSelect] = useState<string>();
|
const [select, setSelect] = useState<any>();
|
||||||
const [data, setData] = useState<any[]>([]);
|
const [data, setData] = useState<any[]>([]);
|
||||||
const [filterData, setFilterData] = useState<any[]>([]);
|
const [filterData, setFilterData] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
@ -73,8 +73,11 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (value: any, node: any) => {
|
const onSelect = (value: any, node: any) => {
|
||||||
|
if (node.key === select || !value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setValue('加载中...');
|
setValue('加载中...');
|
||||||
const newMode = LangMap[value.slice(-3)] || '';
|
const newMode = value ? LangMap[value.slice(-3)] : '';
|
||||||
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
|
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
|
||||||
setSelect(value);
|
setSelect(value);
|
||||||
setTitle(node.parent || node.value);
|
setTitle(node.parent || node.value);
|
||||||
|
@ -286,9 +289,9 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
treeData={filterData}
|
treeData={filterData}
|
||||||
showIcon={true}
|
showIcon={true}
|
||||||
height={height}
|
height={height}
|
||||||
|
selectedKeys={[select]}
|
||||||
showLine={{ showLeafIcon: true }}
|
showLine={{ showLeafIcon: true }}
|
||||||
onSelect={onTreeSelect}
|
onSelect={onTreeSelect}
|
||||||
defaultSelectedKeys={[data[0] && data[0].key]}
|
|
||||||
></Tree>
|
></Tree>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user