Unverified Commit 7bb0aaef authored by yqwoe's avatar yqwoe Committed by GitHub

fix: 数据开发编辑器屏幕适配问题 (#2440)

* feat: use-service hooks * fix: 快捷键问题;编辑器主题切换问题;编辑 器全屏;数据库字段长度; * fix:提交 .mvn * fix:提交 .idea * fix:提交 .gitignore * fix:提交 maven-wrapper.jar * fix:提交 .gitignore * fix:编辑器屏幕适配问题 * fix:编辑器屏幕适配问题 * fix:控制台树形折叠/展开逻辑
parent 2382e5c3
...@@ -44,12 +44,26 @@ export interface ProcessStep extends DataNode { ...@@ -44,12 +44,26 @@ export interface ProcessStep extends DataNode {
time: number; time: number;
log: string; log: string;
lastUpdateStep: ProcessStep; lastUpdateStep: ProcessStep;
children: ProcessStep[];
} }
const buildExpandKeys = (node: ProcessStep) => {
const keys: Key[] = [];
keys.push(node.key);
if (node.children.length > 0) {
node.children.forEach((item: ProcessStep) => {
keys.push(...buildExpandKeys(item));
});
}
return keys;
};
const ConsoleContent = (props: ConsoleProps) => { const ConsoleContent = (props: ConsoleProps) => {
const { tab } = props; const { tab } = props;
const [selectNode, setSelectNode] = useState<ProcessStep>(); const [selectNode, setSelectNode] = useState<ProcessStep>();
const [processNode, setProcessNode] = useState<ProcessStep>(); const [processNode, setProcessNode] = useState<ProcessStep>();
const [expandedKeys, setExpandedKeys] = useState<Key[]>([]);
const process = `FlinkSubmit/${tab.params.taskId}`; const process = `FlinkSubmit/${tab.params.taskId}`;
const topic = `${SSE_TOPIC.PROCESS_CONSOLE}/${process}`; const topic = `${SSE_TOPIC.PROCESS_CONSOLE}/${process}`;
...@@ -105,6 +119,16 @@ const ConsoleContent = (props: ConsoleProps) => { ...@@ -105,6 +119,16 @@ const ConsoleContent = (props: ConsoleProps) => {
); );
}; };
useEffect(() => {
if (processNode) {
setExpandedKeys(buildExpandKeys(processNode));
}
}, [processNode]);
const handleExpand = (expandedKeys: Key[]) => {
setExpandedKeys(expandedKeys);
};
return ( return (
<div style={{ overflow: 'hidden' }}> <div style={{ overflow: 'hidden' }}>
<MovableSidebar <MovableSidebar
...@@ -125,9 +149,8 @@ const ConsoleContent = (props: ConsoleProps) => { ...@@ -125,9 +149,8 @@ const ConsoleContent = (props: ConsoleProps) => {
titleRender={renderTitle} titleRender={renderTitle}
onSelect={onSelect} onSelect={onSelect}
treeData={[processNode]} treeData={[processNode]}
expandAction={'doubleClick'} expandedKeys={expandedKeys}
defaultExpandParent onExpand={handleExpand}
defaultExpandAll
/> />
) : ( ) : (
<Empty /> <Empty />
......
...@@ -41,13 +41,15 @@ import { useEditor } from '@/hooks/useEditor'; ...@@ -41,13 +41,15 @@ import { useEditor } from '@/hooks/useEditor';
export type EditorProps = { export type EditorProps = {
taskId: number; taskId: number;
height?: number;
}; };
const CodeEditor: React.FC<EditorProps & any> = (props) => { const CodeEditor: React.FC<EditorProps & any> = (props) => {
const { const {
taskId, taskId,
tabs: { panes, activeKey }, tabs: { panes, activeKey },
dispatch dispatch,
height,
} = props; } = props;
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
...@@ -96,7 +98,7 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => { ...@@ -96,7 +98,7 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
return ( return (
<Spin spinning={loading} delay={600}> <Spin spinning={loading} delay={600}>
<div style={{ width: '100%', height: fullscreen ? 'calc(100vh - 50px)' : '33vh' }}> <div style={{ width: '100%', height: fullscreen ? 'calc(100vh - 50px)' : height }}>
<DiffModal <DiffModal
diffs={diff} diffs={diff}
open={isModalOpen} open={isModalOpen}
...@@ -162,8 +164,8 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => { ...@@ -162,8 +164,8 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
<div <div
style={{ style={{
position: 'absolute', position: 'absolute',
top: 0, top: 20,
right: 150 right: '7%'
}} }}
> >
{fullscreen ? ( {fullscreen ? (
......
...@@ -51,8 +51,7 @@ const MiddleContainer = (props: any) => { ...@@ -51,8 +51,7 @@ const MiddleContainer = (props: any) => {
} = props; } = props;
const themeValue = useThemeValue(); const themeValue = useThemeValue();
const { fullscreen } = useEditor();
const {fullscreen} = useEditor();
const [contextMenuPosition, setContextMenuPosition] = useState({}); const [contextMenuPosition, setContextMenuPosition] = useState({});
const [contextMenuVisible, setContextMenuVisible] = useState(false); const [contextMenuVisible, setContextMenuVisible] = useState(false);
...@@ -224,7 +223,18 @@ const MiddleContainer = (props: any) => { ...@@ -224,7 +223,18 @@ const MiddleContainer = (props: any) => {
} }
const v = item.params; const v = item.params;
return <Editor taskId={v.taskId} />; return (
<Editor
taskId={v.taskId}
height={
activeKey === item.key
? fullscreen
? document.body.clientHeight
: props.centerContentHeight - 40
: 0
}
/>
);
} }
if (isMetadataTabsItemType(item)) { if (isMetadataTabsItemType(item)) {
...@@ -252,7 +262,15 @@ const MiddleContainer = (props: any) => { ...@@ -252,7 +262,15 @@ const MiddleContainer = (props: any) => {
</Space> </Space>
), ),
children: ( children: (
<ContentScroll height={activeKey === item.key ? fullscreen ? document.body.clientHeight : props.centerContentHeight - 35 : 0}> <ContentScroll
height={
activeKey === item.key
? fullscreen
? document.body.clientHeight
: props.centerContentHeight - 40
: 0
}
>
{renderContent()} {renderContent()}
</ContentScroll> </ContentScroll>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment