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 {
time: number;
log: string;
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 { tab } = props;
const [selectNode, setSelectNode] = useState<ProcessStep>();
const [processNode, setProcessNode] = useState<ProcessStep>();
const [expandedKeys, setExpandedKeys] = useState<Key[]>([]);
const process = `FlinkSubmit/${tab.params.taskId}`;
const topic = `${SSE_TOPIC.PROCESS_CONSOLE}/${process}`;
......@@ -105,6 +119,16 @@ const ConsoleContent = (props: ConsoleProps) => {
);
};
useEffect(() => {
if (processNode) {
setExpandedKeys(buildExpandKeys(processNode));
}
}, [processNode]);
const handleExpand = (expandedKeys: Key[]) => {
setExpandedKeys(expandedKeys);
};
return (
<div style={{ overflow: 'hidden' }}>
<MovableSidebar
......@@ -125,9 +149,8 @@ const ConsoleContent = (props: ConsoleProps) => {
titleRender={renderTitle}
onSelect={onSelect}
treeData={[processNode]}
expandAction={'doubleClick'}
defaultExpandParent
defaultExpandAll
expandedKeys={expandedKeys}
onExpand={handleExpand}
/>
) : (
<Empty />
......
......@@ -41,13 +41,15 @@ import { useEditor } from '@/hooks/useEditor';
export type EditorProps = {
taskId: number;
height?: number;
};
const CodeEditor: React.FC<EditorProps & any> = (props) => {
const {
taskId,
tabs: { panes, activeKey },
dispatch
dispatch,
height,
} = props;
const [isModalOpen, setIsModalOpen] = useState(false);
......@@ -96,7 +98,7 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
return (
<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
diffs={diff}
open={isModalOpen}
......@@ -162,8 +164,8 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
<div
style={{
position: 'absolute',
top: 0,
right: 150
top: 20,
right: '7%'
}}
>
{fullscreen ? (
......
......@@ -51,8 +51,7 @@ const MiddleContainer = (props: any) => {
} = props;
const themeValue = useThemeValue();
const {fullscreen} = useEditor();
const { fullscreen } = useEditor();
const [contextMenuPosition, setContextMenuPosition] = useState({});
const [contextMenuVisible, setContextMenuVisible] = useState(false);
......@@ -224,7 +223,18 @@ const MiddleContainer = (props: any) => {
}
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)) {
......@@ -252,7 +262,15 @@ const MiddleContainer = (props: any) => {
</Space>
),
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()}
</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