diff --git a/packages/gi-assets-basic/src/components/RichContainer/Component.tsx b/packages/gi-assets-basic/src/components/RichContainer/Component.tsx index 316952ed5..16c06da07 100644 --- a/packages/gi-assets-basic/src/components/RichContainer/Component.tsx +++ b/packages/gi-assets-basic/src/components/RichContainer/Component.tsx @@ -9,7 +9,8 @@ import Toolbar from './Toolbar'; import './index.less'; const URL_SEARCH_KEY = 'ActiveAssetID'; -const MIN_WIDTH = 336; +const MIN_WIDTH = 350; +const MAX_WIDTH = 720; const visibleStyle: React.CSSProperties = { visibility: 'visible', width: '100%', @@ -27,7 +28,7 @@ export interface RichContainerState { viewMode: string; } const getDefaultSideWidth = () => { - const defaultWidth = localStorage.getItem('GI_RICH_CONTAINER_SIDE_WIDTH') || '330'; + const defaultWidth = localStorage.getItem('GI_RICH_CONTAINER_SIDE_WIDTH') || '350'; return Number(defaultWidth); }; const RichContainer = props => { @@ -36,7 +37,7 @@ const RichContainer = props => { const { HAS_GRAPH, GISDK_ID } = context; const Containers = useContainer(context); const [state, setState] = React.useState({ - activeKey: localStorage.getItem(URL_SEARCH_KEY) || 'LanguageQuery', + activeKey: localStorage.getItem(URL_SEARCH_KEY) || 'ConfigQuery', viewMode: 'GISDK_CANVAS', }); const { activeKey, viewMode } = state; @@ -58,7 +59,14 @@ const RichContainer = props => { useEffect(() => { if (isExpanded) { const defaultWidth = getDefaultSideWidth(); - setWidth(defaultWidth >= MIN_WIDTH ? defaultWidth : MIN_WIDTH); + const checkAreaWidth = defaultWidth <= MAX_WIDTH && defaultWidth >= MIN_WIDTH; + if (checkAreaWidth) { + setWidth(defaultWidth); + } else if (defaultWidth >= MAX_WIDTH) { + setWidth(MAX_WIDTH); + } else if (defaultWidth <= MIN_WIDTH) { + setWidth(MIN_WIDTH); + } } else setWidth(0); }, [isExpanded]); @@ -131,7 +139,14 @@ const RichContainer = props => { const onResizeStop = (e, direction, ref, d) => { setWidth(prev => { const currentWidth = prev + d.width; - const realWidth = currentWidth >= MIN_WIDTH ? currentWidth : MIN_WIDTH; + let realWidth = currentWidth; + if (currentWidth >= MAX_WIDTH) { + realWidth = MAX_WIDTH; + } else if (currentWidth <= MIN_WIDTH) { + realWidth = MIN_WIDTH; + } else if (currentWidth <= MAX_WIDTH && currentWidth >= MIN_WIDTH) { + realWidth = currentWidth; + } localStorage.setItem('GI_RICH_CONTAINER_SIDE_WIDTH', realWidth); return realWidth; }); @@ -143,8 +158,10 @@ const RichContainer = props => { value: 'GISDK_CANVAS', label: ( - - {$i18n.get({ id: 'basic.components.RichContainer.Component.GraphView', dm: '图谱视图' })} + + + {$i18n.get({ id: 'basic.components.RichContainer.Component.GraphView', dm: '图谱视图' })} + ), }, @@ -177,7 +194,7 @@ const RichContainer = props => {