|
|
|
@ -38,7 +38,6 @@ export class Main extends React.Component< |
|
|
|
|
//
|
|
|
|
|
cookies:Cookies; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
//菜单
|
|
|
|
|
menu:Menu; |
|
|
|
@ -52,12 +51,17 @@ export class Main extends React.Component< |
|
|
|
|
open:boolean; |
|
|
|
|
}, |
|
|
|
|
//用户身份
|
|
|
|
|
userType?:string; |
|
|
|
|
userType:string; |
|
|
|
|
//用户时间币
|
|
|
|
|
timeScore:number; |
|
|
|
|
//用户id
|
|
|
|
|
userId:string; |
|
|
|
|
//显示欢迎信息
|
|
|
|
|
result:boolean; |
|
|
|
|
} |
|
|
|
|
>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<any>) { |
|
|
|
|
super(props); |
|
|
|
|
//默认菜单
|
|
|
|
@ -71,7 +75,9 @@ export class Main extends React.Component< |
|
|
|
|
//我的菜单
|
|
|
|
|
my:{menuName: "",content:null,open:false}, |
|
|
|
|
result:Boolean(this.props.cookies.get(welcome_cookie)), |
|
|
|
|
userType:this.props.cookies.get(user_type_cookie) |
|
|
|
|
userType:this.props.cookies.get(user_type_cookie), |
|
|
|
|
userId:this.props.cookies.get(user_cookie), |
|
|
|
|
timeScore:this.props.cookies.get(time_score) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -137,17 +143,19 @@ export class Main extends React.Component< |
|
|
|
|
switch (dialogType) { |
|
|
|
|
case DialogType.friend: |
|
|
|
|
this.setState({ |
|
|
|
|
my:{menuName:dialogType,content:<MyFriend user={this.props.cookies.get(user_cookie)}/>,open:true} |
|
|
|
|
my:{menuName:dialogType,content:<MyFriend user={this.state.userId}/>,open:true} |
|
|
|
|
}) |
|
|
|
|
break; |
|
|
|
|
case DialogType.leaveWord: |
|
|
|
|
this.setState({ |
|
|
|
|
my:{menuName:dialogType,content:<MyLeaveWord user={this.props.cookies.get(user_cookie)}/>,open:true} |
|
|
|
|
my:{menuName:dialogType,content:<MyLeaveWord user={this.state.userId}/>,open:true} |
|
|
|
|
}) |
|
|
|
|
break; |
|
|
|
|
case DialogType.message: |
|
|
|
|
this.setState({ |
|
|
|
|
my:{menuName:dialogType,content:<MyMessage cookies={this.props.cookies} user={this.props.cookies.get(user_cookie)}/>,open:true} |
|
|
|
|
my:{menuName:dialogType,content:<MyMessage refreshFun={(value:User)=> { |
|
|
|
|
this.refreshInfo(value) |
|
|
|
|
}} cookies={this.props.cookies} user={this.state.userId}/>,open:true} |
|
|
|
|
}) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -172,11 +180,11 @@ export class Main extends React.Component< |
|
|
|
|
|
|
|
|
|
<Dropdown> |
|
|
|
|
<Dropdown.Toggle variant="secondary" id="dropdown-basic"> |
|
|
|
|
{this.props.cookies.get(user_cookie)} |
|
|
|
|
{this.state.userId} |
|
|
|
|
</Dropdown.Toggle> |
|
|
|
|
|
|
|
|
|
<Dropdown.Menu> |
|
|
|
|
<Dropdown.Item>时间币:<span className="text-center text-info">{this.props.cookies.get(time_score)}</span></Dropdown.Item> |
|
|
|
|
<Dropdown.Item>时间币:<span className="text-center text-info">{this.state.timeScore}</span></Dropdown.Item> |
|
|
|
|
{[DialogType.friend,DialogType.leaveWord,DialogType.message].map((type:DialogType,index:number)=><Dropdown.Item disabled={this.state.my.open} key={"dropdown"+index} onClick={()=>this.openDialog(type)}>{type}</Dropdown.Item>)} |
|
|
|
|
<Dropdown.Item onClick={()=>this.props.logout()}>注销登录</Dropdown.Item> |
|
|
|
|
</Dropdown.Menu> |
|
|
|
@ -191,7 +199,7 @@ export class Main extends React.Component< |
|
|
|
|
</Nav> |
|
|
|
|
</Navbar> |
|
|
|
|
|
|
|
|
|
<MyDialog content={<h1 className="text-info text-center">欢迎用户{this.props.cookies.get(user_cookie)}登录本系统</h1>} open={this.state.result} titleId="login-tip" menuName="登录提示" onClose={()=>{ |
|
|
|
|
<MyDialog content={<h1 className="text-info text-center">欢迎用户{this.state.userId}登录本系统</h1>} open={this.state.result} titleId="login-tip" menuName="登录提示" onClose={()=>{ |
|
|
|
|
this.setState({result:false}) |
|
|
|
|
this.props.cookies.remove(welcome_cookie) |
|
|
|
|
}}/> |
|
|
|
@ -200,4 +208,18 @@ export class Main extends React.Component< |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新用户信息 |
|
|
|
|
* @param value |
|
|
|
|
*/ |
|
|
|
|
private refreshInfo(value:any) { |
|
|
|
|
if('userType' in value) { |
|
|
|
|
this.props.cookies.set(user_type_cookie, value.userType) |
|
|
|
|
} |
|
|
|
|
if('timeScore' in value){ |
|
|
|
|
this.props.cookies.set(time_score,value.timeScore) |
|
|
|
|
} |
|
|
|
|
this.setState(value) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|