Skip to content

Commit 6d1f923

Browse files
bytemainRicbet
authored andcommitted
fix: hide bottom tab panel if no container (#3925)
1 parent 54bf519 commit 6d1f923

4 files changed

Lines changed: 49 additions & 16 deletions

File tree

packages/ai-native/src/browser/layout/ai-layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ export const AILayout = () => {
3333
/>
3434
<SplitPanel id='main-vertical' minResize={300} flexGrow={1} direction='top-to-bottom'>
3535
<SlotRenderer flex={2} flexGrow={1} minResize={200} slot='main' />
36-
<SlotRenderer flex={1} defaultSize={layout.bottom?.size} minResize={160} slot='bottom' isTabbar={true} />
36+
<SlotRenderer
37+
flex={1}
38+
defaultSize={layout.bottom?.currentId ? layout.bottom?.size : 24}
39+
minResize={160}
40+
slot='bottom'
41+
isTabbar={true}
42+
/>
3743
</SplitPanel>
3844
<SlotRenderer
3945
slot='right'

packages/core-browser/src/components/layout/default-layout.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@ import { SlotRenderer } from '../../react-providers/slot';
55
import { BoxPanel } from './box-panel';
66
import { SplitPanel } from './split-panel';
77

8+
export interface ILayoutConfigCache {
9+
[key: string]: { size: number; currentId: string };
10+
}
11+
812
export const getStorageValue = () => {
913
// 启动时渲染的颜色和尺寸,弱依赖
10-
let savedLayout: { [key: string]: { size: number; currentId: string } } = {};
14+
let savedLayout: ILayoutConfigCache = {};
1115
let savedColors: { [colorKey: string]: string } = {};
1216
try {
13-
savedLayout = JSON.parse(localStorage.getItem('layout') || '{}');
14-
savedColors = JSON.parse(localStorage.getItem('theme') || '{}');
17+
const layoutConfigStr = localStorage.getItem('layout');
18+
if (layoutConfigStr) {
19+
savedLayout = JSON.parse(layoutConfigStr);
20+
}
21+
22+
const themeConfigStr = localStorage.getItem('theme');
23+
if (themeConfigStr) {
24+
savedColors = JSON.parse(themeConfigStr);
25+
}
1526
} catch (err) {}
27+
1628
return {
1729
layout: savedLayout,
1830
colors: savedColors,
@@ -42,7 +54,13 @@ export function ToolbarActionBasedLayout(
4254
/>
4355
<SplitPanel id='main-vertical' minResize={300} flexGrow={1} direction='top-to-bottom'>
4456
<SlotRenderer flex={2} flexGrow={1} minResize={200} slot='main' />
45-
<SlotRenderer flex={1} defaultSize={layout.bottom?.size} minResize={160} slot='bottom' isTabbar={true} />
57+
<SlotRenderer
58+
flex={1}
59+
defaultSize={layout.bottom?.currentId ? layout.bottom?.size : 24}
60+
minResize={160}
61+
slot='bottom'
62+
isTabbar={true}
63+
/>
4664
</SplitPanel>
4765
<SlotRenderer
4866
slot='right'

packages/editor/src/browser/grid/grid.service.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import { Emitter, IDisposable, IEventBus, MaybeNull } from '@opensumi/ide-core-browser';
2-
import { makeRandomHexString } from '@opensumi/ide-core-common';
2+
import { DisposableStore, makeRandomHexString } from '@opensumi/ide-core-common';
33

44
import { Direction, IEditorGroup, IEditorGroupState } from '../../common';
55
import { GridResizeEvent } from '../types';
66

77
export const editorGridUid = new Set();
88

99
export class EditorGrid implements IDisposable {
10+
private _disposables = new DisposableStore();
11+
1012
public editorGroup: IGridEditorGroup | null = null;
1113

1214
public children: EditorGrid[] = [];
1315

1416
public splitDirection: SplitDirection | undefined;
1517

16-
protected readonly _onDidGridStateChange = new Emitter<void>();
18+
protected readonly _onDidGridStateChange = this._disposables.add(new Emitter<void>());
1719

1820
public readonly onDidGridStateChange = this._onDidGridStateChange.event;
1921

20-
protected readonly _onDidGridAndDesendantStateChange = new Emitter<void>();
22+
protected readonly _onDidGridAndDesendantStateChange = this._disposables.add(new Emitter<void>());
2123

2224
public readonly onDidGridAndDesendantStateChange = this._onDidGridAndDesendantStateChange.event;
2325

@@ -30,10 +32,12 @@ export class EditorGrid implements IDisposable {
3032
}
3133
this.uid = uid;
3234
editorGridUid.add(uid);
33-
this.onDidGridStateChange(() => {
34-
this._onDidGridAndDesendantStateChange.fire();
35-
this.parent?._onDidGridAndDesendantStateChange.fire();
36-
});
35+
this._disposables.add(
36+
this.onDidGridStateChange(() => {
37+
this._onDidGridAndDesendantStateChange.fire();
38+
this.parent?._onDidGridAndDesendantStateChange.fire();
39+
}),
40+
);
3741
}
3842

3943
setEditorGroup(editorGroup: IGridEditorGroup) {
@@ -106,6 +110,8 @@ export class EditorGrid implements IDisposable {
106110
} else {
107111
// 应该不会落入这里
108112
}
113+
114+
this._disposables.dispose();
109115
}
110116

111117
public replaceBy(target: EditorGrid) {

packages/editor/src/browser/workbench-editor.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,13 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
491491
state = this.openedResourceState.get<IEditorGridState>('grid', state);
492492
}
493493
this.topGrid = new EditorGrid();
494-
this.topGrid.onDidGridAndDesendantStateChange(() => {
495-
this._sortedEditorGroups = undefined;
496-
this._onDidEditorGroupsChanged.fire();
497-
});
494+
this.addDispose(this.topGrid);
495+
this.addDispose(
496+
this.topGrid.onDidGridAndDesendantStateChange(() => {
497+
this._sortedEditorGroups = undefined;
498+
this._onDidEditorGroupsChanged.fire();
499+
}),
500+
);
498501
const editorRestorePromises = [];
499502
const promise = this.topGrid
500503
.deserialize(state, () => this.createEditorGroup(), editorRestorePromises)

0 commit comments

Comments
 (0)