登录后不能进入注册登录等页面

This commit is contained in:
caishi 2022-12-14 15:07:38 +08:00
parent 156b2fd5e3
commit 7588cab079
5 changed files with 13 additions and 2 deletions

View File

@ -24,6 +24,8 @@ import { SnackbarHOC } from 'educoder';
import { initAxiosInterceptors } from './AppConfig'
import { Provider } from 'react-redux';
import configureStore from './redux/stores/configureStore';
import cookie from 'react-cookies';
const store = configureStore();
window.marked = marked;
const theme = createMuiTheme({
@ -150,11 +152,16 @@ class App extends Component {
let pathname = window.location.pathname ? window.location.pathname.split('/')[1] : '';
pathname && this.getPathnameType(pathname);
const login = cookie.load("login");
let path = this.props.history.location.pathname;
if(login && (path === "/login" || path === "/register" ||path === "/resetPassword" )){
this.props.history.push(`/${login}`);
}
// 添加路由监听,决定组织还是个人
this.unlisten = this.props.history.listen((location,history) => {
// if(login && )
let newPathname = location.pathname.split('/')[1];
if (this.state.pathName !== newPathname) {
// this.setState({ pathType: '' });
newPathname && this.getPathnameType(newPathname);
}
});

View File

@ -2,6 +2,7 @@ import axios from 'axios';
import { requestProxy } from "./indexEduplus2RequestProxy";
import { broadcastChannelOnmessage, isDev, queryString } from 'educoder';
import { notification } from 'antd';
import cookie from 'react-cookies';
import './index.css';
@ -16,7 +17,7 @@ function locationurl(list) {
}
}
// TODO 开发期多个身份切换
let debugType = ""
let debugType = "";
if (isDev) {
const _search = window.location.search;
let parsed = {};

View File

@ -90,6 +90,7 @@ class NewHeader extends Component {
educoderloginysl = () => {
//退出账号时清除登录页面的下次自动登录(用户再次打开登录页面时下次自动登录框不勾选)
cookie.remove("autologin");
cookie.remove("login");
//退出账号
var url = `/accounts/logout.json`;
axios.get((url)).then((result) => {

View File

@ -400,6 +400,7 @@ class LoginDialog extends Component {
isRender: false
})
cookie.save("supplyphone",true);
cookie.save("login",response.data.login);
this.props.Modifyloginvalue(response.data);
this.props.gopage ? (window.location.href = this.props.gopage) : window.location.reload()
// window.location.reload();

View File

@ -48,6 +48,7 @@ function Login(props){
//
cookie.save('autologin',values.remember);
cookie.save('supplyphone',true);
cookie.save("login",response.data.login);
const searchParams = new URLSearchParams(search.substring(1));
const goPage = searchParams.get("go_page");