Commit 3c1eb4ed authored by 熊成伟's avatar 熊成伟

debug

parent 8b58f3d1
Pipeline #16414 failed with stages
in 34 seconds
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import {WhiteSpace, WingBlank} from "antd-mobile"; import {Toast, WhiteSpace, WingBlank} from "antd-mobile";
// import axiosRequest from '../../utils/request'; // import axiosRequest from '../../utils/request';
import TopSearch from '../../components/TopSearch' import TopSearch from '../../components/TopSearch'
import WorkCard from '../../components/Card/WorkCard'; import WorkCard from '../../components/Card/WorkCard';
import Skeleton from '../../components/Skeleton' import Skeleton from '../../components/Skeleton'
import Document from 'react-document-title' import Document from 'react-document-title'
import Empty from '../Empty' import Empty from '../Empty'
import queryString from "query-string";
const Work = (props) => { const Work = (props) => {
const [start, setStart] = useState(true); const [start, setStart] = useState(true);
...@@ -15,14 +16,21 @@ const Work = (props) => { ...@@ -15,14 +16,21 @@ const Work = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
useEffect(() => { useEffect(() => {
loadOperates(); new Promise((resolve => {
const query = queryString.parse(props.location.search);
const keys = Object.keys(query);
keys.length > 0 && query.token && localStorage.setItem('token', query.token);
resolve()
})).then(() => {
loadOperates();
})
}, []); }, []);
const loadOperates = () => { const loadOperates = () => {
setLoading(true); setLoading(true);
setTimeout(() => { setTimeout(() => {
setLoading(false) setLoading(false)
}, 1000) }, 1000);
const res = localStorage.getItem("menu"); const res = localStorage.getItem("menu");
setStart(false); setStart(false);
const result = JSON.parse(res) const result = JSON.parse(res)
......
...@@ -31,9 +31,8 @@ export const createAPI = (baseURL) => { ...@@ -31,9 +31,8 @@ export const createAPI = (baseURL) => {
return (conf = {}) => { return (conf = {}) => {
let opts = conf.opts || {}; let opts = conf.opts || {};
let urlParams = ''; let urlParams = '';
// console.log(conf);
let headers = { ...defaultHeaders, ...opts.headers }; let headers = { ...defaultHeaders, ...opts.headers, token: conf.token};
if (conf.opts) { if (conf.opts) {
urlParams = "?"; urlParams = "?";
urlParams += qs.stringify(conf.opts) urlParams += qs.stringify(conf.opts)
......
...@@ -27,11 +27,13 @@ const loadingCounter = () => { ...@@ -27,11 +27,13 @@ const loadingCounter = () => {
let loadingCount = loadingCounter(); let loadingCount = loadingCounter();
async function axiosRequest(option = {}) { async function axiosRequest(option = {}) {
const token = localStorage.getItem("token");
loadingCount.startLoading(); loadingCount.startLoading();
const res = await instance({ const res = await instance({
method: option.method || 'get', method: option.method || 'get',
url: option.url, url: option.url,
opts: option.body || null, opts: option.body || null,
token: token
}); });
loadingCount.endLoading(); loadingCount.endLoading();
return res; return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment