Browse Source

免密

master
wenlele 2 years ago
parent
commit
a11656b101
  1. 12
      web/client/src/layout/containers/layout/index.jsx
  2. 2
      web/client/src/sections/auth/actions/auth.js
  3. 3
      web/client/src/utils/webapi.js
  4. 3
      web/routes/attachment/index.js

12
web/client/src/layout/containers/layout/index.jsx

@ -33,7 +33,7 @@ let requestlogout = false;
// const location111 = useLocation(); // const location111 = useLocation();
const LayoutContainer = props => { const LayoutContainer = props => {
const { const {
dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, dispatch,actions, msg, user, copyright, children, sections, clientWidth, clientHeight,
location, match, routes, history, socket, apiRoot location, match, routes, history, socket, apiRoot
} = props } = props
const [collapsed, setCollapsed] = useState(false) const [collapsed, setCollapsed] = useState(false)
@ -206,13 +206,15 @@ const LayoutContainer = props => {
const getUserInfoByToken = () => { const getUserInfoByToken = () => {
if (requestUser) { if (requestUser) {
requestUser = false; requestUser = false;
RouteRequest.get(RouteTable.getDomain).then(res => { console.log(RouteTable.apiRoot);
console.log(res); RouteRequest.get(RouteTable.apiRoot).then(res => {
let token = Cookie.get('pepToken', { domain: res.root }); let token = Cookie.get('pepToken', { domain: res.domain });
console.log(token);
dispatch(login({ token })).then(res => { dispatch(login({ token })).then(res => {
console.log(res);
if (res.type == 'LOGIN_SUCCESS') { if (res.type == 'LOGIN_SUCCESS') {
const data = res.payload?.user || {} 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_open_sider', JSON.stringify(["pmReport"]))
localStorage.setItem('poms_selected_sider', JSON.stringify(["businessManagement"])) localStorage.setItem('poms_selected_sider', JSON.stringify(["businessManagement"]))
localStorage.setItem('word', JSON.stringify('')) // localStorage.setItem('word', JSON.stringify('')) //

2
web/client/src/sections/auth/actions/auth.js

@ -25,7 +25,7 @@ export function login ({ username, password, token }) {
return dispatch => { return dispatch => {
dispatch({ type: REQUEST_LOGIN }); dispatch({ type: REQUEST_LOGIN });
if (!username || !password) { if ((!username || !password) && !token) {
dispatch({ dispatch({
type: LOGIN_ERROR, type: LOGIN_ERROR,
payload: { error: '请输入账号名和密码' } payload: { error: '请输入账号名和密码' }

3
web/client/src/utils/webapi.js

@ -29,6 +29,5 @@ export const RouteTable = {
apiRoot: "/api/root", apiRoot: "/api/root",
fileUpload: "/_upload/new", fileUpload: "/_upload/new",
cleanUpUploadTrash: "/_upload/cleanup", cleanUpUploadTrash: "/_upload/cleanup",
getServiceUrl: '/_service/url', getServiceUrl: '/_service/url'
getDomain: '/domain',
}; };

3
web/routes/attachment/index.js

@ -20,11 +20,12 @@ module.exports = {
entry: function (app, router, opts) { entry: function (app, router, opts) {
const getApiRoot = async function (ctx) { const getApiRoot = async function (ctx) {
const { apiUrl } = opts; const { apiUrl,domain } = opts;
ctx.status = 200; ctx.status = 200;
ctx.body = { ctx.body = {
root: apiUrl, root: apiUrl,
domain:domain
}; };
}; };

Loading…
Cancel
Save