diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 2a79c2f..37e2634 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -33,7 +33,7 @@ let requestlogout = false; // const location111 = useLocation(); const LayoutContainer = props => { const { - dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, + dispatch,actions, msg, user, copyright, children, sections, clientWidth, clientHeight, location, match, routes, history, socket, apiRoot } = props const [collapsed, setCollapsed] = useState(false) @@ -206,13 +206,15 @@ const LayoutContainer = props => { const getUserInfoByToken = () => { if (requestUser) { requestUser = false; - RouteRequest.get(RouteTable.getDomain).then(res => { - console.log(res); - let token = Cookie.get('pepToken', { domain: res.root }); + console.log(RouteTable.apiRoot); + RouteRequest.get(RouteTable.apiRoot).then(res => { + let token = Cookie.get('pepToken', { domain: res.domain }); + console.log(token); dispatch(login({ token })).then(res => { + console.log(res); if (res.type == 'LOGIN_SUCCESS') { const data = res.payload?.user || {} - dispatch(push('/businessManagement/pmReport/reserveItemsReporting')); + history.push('/businessManagement/pmReport/reserveItemsReporting') localStorage.setItem('poms_open_sider', JSON.stringify(["pmReport"])) localStorage.setItem('poms_selected_sider', JSON.stringify(["businessManagement"])) localStorage.setItem('word', JSON.stringify('')) //系统登录代码时候存的,不清楚意义 diff --git a/web/client/src/sections/auth/actions/auth.js b/web/client/src/sections/auth/actions/auth.js index 14d2f8d..18a1e59 100644 --- a/web/client/src/sections/auth/actions/auth.js +++ b/web/client/src/sections/auth/actions/auth.js @@ -25,7 +25,7 @@ export function login ({ username, password, token }) { return dispatch => { dispatch({ type: REQUEST_LOGIN }); - if (!username || !password) { + if ((!username || !password) && !token) { dispatch({ type: LOGIN_ERROR, payload: { error: '请输入账号名和密码' } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 0b57966..cad4b9b 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -29,6 +29,5 @@ export const RouteTable = { apiRoot: "/api/root", fileUpload: "/_upload/new", cleanUpUploadTrash: "/_upload/cleanup", - getServiceUrl: '/_service/url', - getDomain: '/domain', + getServiceUrl: '/_service/url' }; diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index 5f31761..326d914 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -20,11 +20,12 @@ module.exports = { entry: function (app, router, opts) { const getApiRoot = async function (ctx) { - const { apiUrl } = opts; + const { apiUrl,domain } = opts; ctx.status = 200; ctx.body = { root: apiUrl, + domain:domain }; };