Skip to content

Commit 4fd1889

Browse files
KevenYoungveedrin
authored andcommitted
globalKey 以 dtid_ 开头时,全局弹窗提示修改
2 parents 6ab8a6d + aa1e670 commit 4fd1889

File tree

7 files changed

+114
-36
lines changed

7 files changed

+114
-36
lines changed

app/dashboard/i18n/en_US/global.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@
7171
"noMessage": "No Messages yet",
7272
"quit": "Quit",
7373
"quiting": "Quiting",
74-
"period": "."
74+
"period": ".",
75+
"globalTip1": "The system has detected that your username has not been modified.",
76+
"globalTip2": "Please go to [ Tencent Cloud Dev Platform > Personal Settings ] and then log in again.",
77+
"gotoModify": "Go to edit"
7578
}

app/dashboard/i18n/zh_CN/global.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@
7171
"noMessage": "没有私信",
7272
"quit": "退出",
7373
"quiting": "退出中",
74-
"period": ""
74+
"period": "",
75+
"globalTip1": "系统检测到您的用户名尚未修改。",
76+
"globalTip2": "请先进入 [ 腾讯云开发者平台 > 个人设置 ] 修改后再重新登录使用。",
77+
"gotoModify": "前往修改"
7578
}

app/dashboard/view/home/Home.js

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { NavLink, Link, Switch, Route, Redirect } from 'react-router-dom';
55
import './home.css';
66
import cloudstudio from '../../static/cloudstudio.svg';
77

8-
import api from '../../api';
9-
import i18n from '../../utils/i18n';
8+
import Mask from './mask';
109
import Stripe from '../../share/stripe';
1110
import Bell from '../bell';
1211
import Profile from './profile';
@@ -17,15 +16,27 @@ import Plugin from '../plugin';
1716
import Setting from '../setting';
1817
import About from '../about';
1918

19+
import api from '../../api';
20+
import i18n from '../../utils/i18n';
21+
2022
class Home extends Component {
21-
state = {
22-
isBellOn: false,
23-
isProfileOn: false,
23+
constructor(props) {
24+
super(props);
25+
this.state = {
26+
loaded: false,
27+
isMaskOn: true,
28+
isBellOn: false,
29+
isProfileOn: false,
30+
};
31+
this.fetchUserProfile();
2432
}
2533

2634
render() {
27-
const { isBellOn, isProfileOn } = this.state;
35+
const { loaded, isMaskOn, isBellOn, isProfileOn } = this.state;
2836
const { isMbarOn, wsCount, hideMbar } = this.props;
37+
if (loaded && isMaskOn) {
38+
return <Mask />;
39+
}
2940
return (
3041
<div id="dash-container" onClick={this.turnOffPanel}>
3142
<div className="dash-mbar">
@@ -54,20 +65,22 @@ class Home extends Component {
5465
<NavLink className="nav-item" activeClassName="active" to="/dashboard/plugin">{i18n('global.plugin')}</NavLink>
5566
<NavLink className="nav-item" activeClassName="active" to="/dashboard/setting">{i18n('global.setting')}</NavLink>
5667
</div>
57-
<Bell on={isBellOn} togglePanel={this.toggleBellPanel} />
58-
<Profile on={isProfileOn} togglePanel={this.toggleProfilePanel} />
68+
{!isMaskOn && <Bell on={isBellOn} togglePanel={this.toggleBellPanel} />}
69+
{!isMaskOn && <Profile on={isProfileOn} togglePanel={this.toggleProfilePanel} />}
5970
</div>
6071
<div className="dash-main">
6172
<Banner />
6273
<div className="dash-view">
63-
<Switch>
64-
<Route exact path="/dashboard/workspace" component={Workspace}></Route>
65-
<Route exact path="/dashboard/workspace/create" component={Create}></Route>
66-
<Route path="/dashboard/plugin" component={Plugin}></Route>
67-
<Route exact path="/dashboard/setting" component={Setting}></Route>
68-
<Route exact path="/dashboard/about" component={About}></Route>
69-
<Redirect to="/dashboard/workspace" />
70-
</Switch>
74+
{!isMaskOn && (
75+
<Switch>
76+
<Route exact path="/dashboard/workspace" component={Workspace}></Route>
77+
<Route exact path="/dashboard/workspace/create" component={Create}></Route>
78+
<Route path="/dashboard/plugin" component={Plugin}></Route>
79+
<Route exact path="/dashboard/setting" component={Setting}></Route>
80+
<Route exact path="/dashboard/about" component={About}></Route>
81+
<Redirect to="/dashboard/workspace" />
82+
</Switch>
83+
)}
7184
</div>
7285
</div>
7386
</div>
@@ -95,8 +108,6 @@ class Home extends Component {
95108
state: (historyState && historyState.state) ? historyState.state : undefined,
96109
}, '*');
97110
gtag('config', 'UA-65952334-9', {'page_path': window.location.pathname});
98-
// 获取工作空间数量信息
99-
this.fetchWorkspaceCount();
100111
// 缩放页面时,关闭 mbar
101112
window.addEventListener('resize', () => {
102113
const { isMbarOn } = this.props;
@@ -106,7 +117,24 @@ class Home extends Component {
106117
});
107118
}
108119

109-
fetchWorkspaceCount() {
120+
fetchUserProfile = () => {
121+
api.getUserProfile().then(res => {
122+
this.setState({ loaded: true });
123+
if (res.code === 0) {
124+
if (!/^dtid_[a-z0-9]+/i.test(res.data.global_key)) {
125+
this.props.logIn(res.data);
126+
this.setState({ isMaskOn: false });
127+
// 获取工作空间数量信息
128+
this.fetchWorkspaceCount();
129+
}
130+
} else {
131+
window.top.postMessage({ path: '/intro' }, '*');
132+
window.location.href = '/intro';
133+
}
134+
});
135+
}
136+
137+
fetchWorkspaceCount = () => {
110138
const { storeWorkspace } = this.props;
111139
// 获取工作空间
112140
// 获取创建工作空间数量限制
@@ -165,9 +193,8 @@ const mapState = (state) => {
165193

166194
const mapDispatch = (dispatch) => {
167195
return {
168-
storeWorkspace: (payload) => {
169-
dispatch({ type: 'STORE_WORKSPACE', payload })
170-
},
196+
logIn: (payload) => dispatch({ type: 'USER_LOG_IN', payload }),
197+
storeWorkspace: (payload) => dispatch({ type: 'STORE_WORKSPACE', payload }),
171198
hideMbar: () => dispatch({ type: 'SWITCH_MBAR_TO_OFF' }),
172199
}
173200
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
3+
import './mask.css';
4+
5+
import i18n from '../../../utils/i18n';
6+
7+
const Mask = () => {
8+
return (
9+
<div className="dash-global-mask">
10+
<div className="panel">
11+
<div className="line">{i18n('global.globalTip1')}</div>
12+
<div className="line">{i18n('global.globalTip2')}</div>
13+
<div className="control">
14+
<a href="https://dev.tencent.com/user/account" target="_blank" rel="noopener noreferrer">
15+
<button className="com-button primary">{i18n('global.gotoModify')}</button>
16+
</a>
17+
</div>
18+
</div>
19+
</div>
20+
);
21+
}
22+
23+
export default Mask;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Mask from './Mask';
2+
3+
export default Mask;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.dash-global-mask {
2+
width: 100%;
3+
height: 100%;
4+
background-color: rgba(0, 0, 0, .6);
5+
position: fixed;
6+
top: 0;
7+
left: 0;
8+
z-index: 100;
9+
}
10+
.dash-global-mask .panel {
11+
width: 465px;
12+
padding: 20px;
13+
border-radius: 5px;
14+
font-size: 14px;
15+
color: #ccc;
16+
background-color: #333;
17+
position: absolute;
18+
top: 40%;
19+
left: calc(50% - 210px);
20+
}
21+
.dash-global-mask .panel .line {
22+
padding-bottom: 5px;
23+
}
24+
.dash-global-mask .panel .control {
25+
padding-top: 20px;
26+
text-align: center;
27+
}
28+
.dash-global-mask .panel button {
29+
width: 90px;
30+
height: 35px;
31+
}

app/dashboard/view/home/profile/Profile.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ class Profile extends Component {
3434
);
3535
}
3636

37-
componentDidMount() {
38-
api.getUserProfile().then(res => {
39-
if (res.code === 0) {
40-
this.props.logIn(res.data);
41-
} else {
42-
window.top.postMessage({ path: '/intro' }, '*');
43-
window.location.href = '/intro';
44-
}
45-
});
46-
}
47-
4837
handleLogout = () => {
4938
api.logout().then(res => {
5039
if (res.code === 0) {
@@ -66,7 +55,6 @@ const mapState = (state) => {
6655

6756
const mapDispatch = (dispatch) => {
6857
return {
69-
logIn: (payload) => dispatch({ type: 'USER_LOG_IN', payload }),
7058
logOut: () => dispatch({ type: 'USER_LOG_OUT' }),
7159
}
7260
}

0 commit comments

Comments
 (0)