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 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('')) //

2
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: '请输入账号名和密码' }

3
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'
};

3
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
};
};

Loading…
Cancel
Save