diff --git a/src/app.tsx b/src/app.tsx deleted file mode 100644 index eeab9b2e..00000000 --- a/src/app.tsx +++ /dev/null @@ -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]} - 控制面板`; - } -} diff --git a/src/layouts/defaultProps.tsx b/src/layouts/defaultProps.tsx index dd205676..2ed49178 100644 --- a/src/layouts/defaultProps.tsx +++ b/src/layouts/defaultProps.tsx @@ -62,9 +62,6 @@ export default { }, ], }, - location: { - pathname: '/', - }, navTheme: 'light', fixSiderbar: true, contentWidth: 'Fixed', diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index a56146b5..8a4ec698 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -56,9 +56,6 @@ export default function (props: any) { history.push('/login'); } vhCheck(); - - // patch custome layout title as react node [object, object] - document.title = '控制面板'; }, []); useEffect(() => { @@ -135,7 +132,12 @@ export default function (props: any) { }, ]; }} - pageTitleRender={() => '控制面板'} + pageTitleRender={(props, pageName, info) => { + if (info) { + return `${info.pageName} - 控制面板`; + } + return '控制面板'; + }} {...defaultProps} > {React.Children.map(props.children, (child) => { diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index 0c017769..5e5fc270 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -42,7 +42,7 @@ const LangMap: any = { const Script = ({ headerStyle, isPhone, theme }: any) => { const [title, setTitle] = useState('请选择脚本文件'); const [value, setValue] = useState('请选择脚本文件'); - const [select, setSelect] = useState(); + const [select, setSelect] = useState(); const [data, setData] = useState([]); const [filterData, setFilterData] = useState([]); const [loading, setLoading] = useState(false); @@ -73,8 +73,11 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { }; const onSelect = (value: any, node: any) => { + if (node.key === select || !value) { + return; + } setValue('加载中...'); - const newMode = LangMap[value.slice(-3)] || ''; + const newMode = value ? LangMap[value.slice(-3)] : ''; setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode); setSelect(value); setTitle(node.parent || node.value); @@ -286,9 +289,9 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { treeData={filterData} showIcon={true} height={height} + selectedKeys={[select]} showLine={{ showLeafIcon: true }} onSelect={onTreeSelect} - defaultSelectedKeys={[data[0] && data[0].key]} >