Skip to content

Commit 0e6bba9

Browse files
authored
Merge pull request #945 from xieliuduo/dev-renderAuto
autoBoard first render farst
2 parents bf813c5 + fdfd098 commit 0e6bba9

File tree

8 files changed

+23
-18
lines changed

8 files changed

+23
-18
lines changed

frontend/src/app/hooks/useCacheWidthHeight.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { useEffect, useState } from 'react';
19+
import { useLayoutEffect, useState } from 'react';
2020
import useResizeObserver from './useResizeObserver';
2121

2222
export const useCacheWidthHeight = (
@@ -33,7 +33,7 @@ export const useCacheWidthHeight = (
3333
refreshMode: 'debounce',
3434
refreshRate: 20,
3535
});
36-
useEffect(() => {
36+
useLayoutEffect(() => {
3737
if (width > 0) {
3838
setCacheW(width);
3939
setCacheH(height);

frontend/src/app/hooks/useWidgetRowHeight.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ import {
2121
BASE_VIEW_WIDTH,
2222
MIN_ROW_HEIGHT,
2323
} from 'app/pages/DashBoardPage/constants';
24-
import { useMemo } from 'react';
25-
import { useCacheWidthHeight } from './useCacheWidthHeight';
24+
import { useLayoutEffect, useMemo, useState } from 'react';
25+
import useResizeObserver from './useResizeObserver';
2626

2727
export const useWidgetRowHeight = () => {
28-
const { ref, cacheW } = useCacheWidthHeight();
28+
const [cacheW, setCacheW] = useState(0);
29+
const { ref, width = 0 } = useResizeObserver<HTMLDivElement>();
30+
31+
useLayoutEffect(() => {
32+
if (width > 0) {
33+
setCacheW(width);
34+
}
35+
}, [width]);
2936
const widgetRowHeight = useMemo(() => {
3037
let dynamicHeight = (cacheW * BASE_ROW_HEIGHT) / BASE_VIEW_WIDTH;
3138
return Math.max(dynamicHeight, MIN_ROW_HEIGHT);

frontend/src/app/pages/DashBoardPage/components/WidgetCore/ButtonWidget/QueryWidget.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ export const QueryWidget: React.FC<CompProps> = () => {
4343
};
4444

4545
const Wrap = styled.div<FontConfig & { background: string }>`
46-
cursor: pointer;
47-
flex: 1;
4846
display: flex;
47+
flex: 1;
4948
align-items: center;
5049
justify-content: center;
5150
font: ${p =>
5251
`${p.fontStyle} ${p.fontWeight} ${p.fontSize}px ${p.fontFamily}`};
5352
color: ${p => p.color};
54-
53+
cursor: pointer;
5554
&:hover {
5655
background: ${p =>
5756
getLuminance(p.background) > 0.5

frontend/src/app/pages/DashBoardPage/components/WidgetCore/ButtonWidget/ResetWidget.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ export const ResetWidget: React.FC<CompProps> = () => {
4343
};
4444

4545
const Wrap = styled.div<FontConfig & { background: string }>`
46-
cursor: pointer;
47-
flex: 1;
4846
display: flex;
47+
flex: 1;
4948
align-items: center;
5049
justify-content: center;
5150
font: ${p =>
5251
`${p.fontStyle} ${p.fontWeight} ${p.fontSize}px ${p.fontFamily}`};
5352
color: ${p => p.color};
54-
53+
cursor: pointer;
5554
&:hover {
5655
background: ${p =>
5756
getLuminance(p.background) > 0.5

frontend/src/app/pages/DashBoardPage/components/WidgetCore/ContainerWidget/TabWidget/WidgetOfTab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ interface WrapProps {
8484
const Wrap = styled.div<WrapProps>`
8585
position: relative;
8686
box-sizing: border-box;
87-
width: 100%;
88-
height: 100%;
8987
display: flex;
9088
flex: 1;
89+
width: 100%;
90+
height: 100%;
9191
border: ${p => p.border};
9292
9393
& .widget-tool-bar {
@@ -104,8 +104,8 @@ const Wrap = styled.div<WrapProps>`
104104
`;
105105
const ItemContainer = styled.div`
106106
position: absolute;
107-
display: flex;
108107
z-index: 10;
108+
display: flex;
109109
width: 100%;
110110
height: 100%;
111111
`;

frontend/src/app/pages/DashBoardPage/components/WidgetCore/DataChartWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const ChartFrameBox = styled.div`
171171
overflow: hidden;
172172
`;
173173
const Wrap = styled.div`
174+
position: relative;
174175
display: flex;
175176
flex: 1;
176-
position: relative;
177177
`;

frontend/src/app/pages/DashBoardPage/pages/Board/AutoDashboard/AutoBoardCore.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const StyledContainer = styled(StyledBackground)`
310310
.empty {
311311
display: flex;
312312
flex: 1;
313-
justify-content: center;
314313
align-items: center;
314+
justify-content: center;
315315
}
316316
`;

frontend/src/app/pages/DashBoardPage/pages/Board/FreeDashboard/FreeBoardCore.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ const Wrap = styled.div`
134134
overflow-y: hidden;
135135
136136
.empty {
137-
height: 100%;
138137
display: flex;
139138
flex: 1;
140-
justify-content: center;
141139
align-items: center;
140+
justify-content: center;
141+
height: 100%;
142142
}
143143
}
144144
.grid-background::-webkit-scrollbar {

0 commit comments

Comments
 (0)