1- import React , { useState } from 'react' ;
1+ import React from 'react' ;
22import styles from './index.less' ;
33import classnames from 'classnames' ;
44// import i18n from '@/i18n';
55import { Popover } from 'antd' ;
66import Iconfont from '@/components/Iconfont' ;
77import { extendConfig } from '../config' ;
88
9- // import { useWorkspaceStore } from '@/pages/main/workspace/store';
9+ import { setCurrentWorkspaceExtend } from '@/pages/main/workspace/store/common' ;
10+ import { useWorkspaceStore } from '@/pages/main/workspace/store' ;
1011
1112interface IToolbar {
1213 code : string ;
@@ -21,14 +22,18 @@ interface IProps {
2122
2223export default ( props :IProps ) => {
2324 const { className } = props ;
24- const [ activeExtend , setActiveExtend ] = useState < IToolbar | null > ( null ) ;
25+ const { currentWorkspaceExtend } = useWorkspaceStore ( ( state ) => {
26+ return {
27+ currentWorkspaceExtend : state . currentWorkspaceExtend ,
28+ } ;
29+ } ) ;
2530
2631 const changeExtend = ( item : IToolbar ) => {
27- if ( activeExtend ?. code === item . code ) {
28- setActiveExtend ( null ) ;
32+ if ( currentWorkspaceExtend === item . code ) {
33+ setCurrentWorkspaceExtend ( null ) ;
2934 return ;
3035 }
31- setActiveExtend ( item ) ;
36+ setCurrentWorkspaceExtend ( item . code ) ;
3237 } ;
3338
3439 return (
@@ -37,7 +42,7 @@ export default (props:IProps) => {
3742 return (
3843 < Popover mouseEnterDelay = { 0.8 } key = { index } placement = "left" content = { item . title } >
3944 < div className = { styles . rightBarFront } onClick = { changeExtend . bind ( null , item ) } >
40- < Iconfont code = { item . icon } box size = { 18 } active = { activeExtend ?. code === item . code } />
45+ < Iconfont code = { item . icon } box size = { 18 } active = { currentWorkspaceExtend === item . code } />
4146 </ div >
4247 </ Popover >
4348 ) ;
0 commit comments