diff --git a/src/pages/setting/index.tsx b/src/pages/setting/index.tsx index 03a8e035e09..9ba993d50c2 100644 --- a/src/pages/setting/index.tsx +++ b/src/pages/setting/index.tsx @@ -32,8 +32,8 @@ import About from './about'; import { useOutletContext } from '@umijs/max'; import { SharedContext } from '@/layouts'; import './index.less'; -import CodeMirror from '@uiw/react-codemirror'; import useResizeObserver from '@react-hook/resize-observer'; +import SystemLog from './systemLog'; const { Text } = Typography; const isDemoEnv = window.__ENV__DeployEnv === 'demo'; @@ -347,22 +347,7 @@ const Setting = () => { { key: 'syslog', label: intl.get('系统日志'), - children: ( - { - setTimeout(() => { - view.scrollDOM.scrollTo({ - top: view.scrollDOM.scrollHeight, - behavior: 'smooth', - }); - }, 300); - }} - readOnly={true} - theme={theme.includes('dark') ? 'dark' : 'light'} - /> - ), + children: , }, { key: 'login', diff --git a/src/pages/setting/systemLog.tsx b/src/pages/setting/systemLog.tsx new file mode 100644 index 00000000000..575217578e9 --- /dev/null +++ b/src/pages/setting/systemLog.tsx @@ -0,0 +1,58 @@ +import React, { useRef } from 'react'; +import CodeMirror from '@uiw/react-codemirror'; +import { Button } from 'antd'; +import { + VerticalAlignBottomOutlined, + VerticalAlignTopOutlined, +} from '@ant-design/icons'; + +const SystemLog = ({ data, height, theme }: any) => { + const editorRef = useRef(null); + + const scrollTo = (position: 'start' | 'end') => { + editorRef.current.scrollDOM.scrollTo({ + top: position === 'start' ? 0 : editorRef.current.scrollDOM.scrollHeight, + }); + }; + + return ( +
+ { + editorRef.current = view; + }} + readOnly={true} + theme={theme.includes('dark') ? 'dark' : 'light'} + /> +
+
+
+ ); +}; + +export default SystemLog;