♻️ refactor: 重写token获取方式
This commit is contained in:
parent
99c4e81281
commit
c8ed9dc165
|
@ -16,10 +16,9 @@ export default class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const tokenString = this.props.location.search;
|
const { token, head } = this.getQuery(this.props.location.search);
|
||||||
const token = tokenString.substring(tokenString.indexOf('=') + 1);
|
|
||||||
/* 判断是否有token */
|
/* 判断是否有token */
|
||||||
if (tokenString && tokenString.indexOf('=') > -1) {
|
if (token) {
|
||||||
this.onSubmit(token);
|
this.onSubmit(token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +26,15 @@ export default class App extends Component {
|
||||||
this.toUnifiedLogin();
|
this.toUnifiedLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 解析url参数 */
|
||||||
|
getQuery = (url) =>
|
||||||
|
(url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(
|
||||||
|
(a, v) => (
|
||||||
|
(a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
/* 跳转统一登录平台 */
|
/* 跳转统一登录平台 */
|
||||||
toUnifiedLogin() {
|
toUnifiedLogin() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Loading…
Reference in New Issue