Commit 4756f733 by 马贞晓

保存修改

1 parent ae0997f0
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `yarn build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
REACT_APP_API="http://www.baidu.com"
\ No newline at end of file
......@@ -5,8 +5,9 @@ const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const ignoredFiles = require('react-dev-utils/ignoredFiles');
const paths = require('./paths');
const path = require("path");
const fs = require('fs');
const webpackMock = require('webpack-api-mocker');
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
......@@ -57,7 +58,7 @@ module.exports = function(proxy, allowedHost) {
// updated. The WebpackDevServer client is included as an entry point
// in the Webpack development configuration. Note that only changes
// to CSS are currently hot reloaded. JS changes will refresh the browser.
hot: true,
hot: false,
// It is important to tell WebpackDevServer to use the same "root" path
// as we specified in the config. In development, we always serve from /.
publicPath: '/',
......@@ -83,6 +84,8 @@ module.exports = function(proxy, allowedHost) {
public: allowedHost,
proxy,
before(app, server) {
// console.log(path.join(__dirname,'../src/service/mock/index.js'))
if (fs.existsSync(paths.proxySetup)) {
// This registers user provided middleware for proxy reasons
require(paths.proxySetup)(app);
......@@ -99,6 +102,7 @@ module.exports = function(proxy, allowedHost) {
// it used the same host and port.
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
app.use(noopServiceWorkerMiddleware());
console.log(app);
},
};
};
......@@ -8,6 +8,7 @@
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"antd": "^3.25.1",
"axios": "^0.19.0",
"babel-eslint": "10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "8.0.6",
......@@ -61,6 +62,7 @@
"ts-pnp": "1.1.4",
"url-loader": "2.1.0",
"webpack": "4.41.0",
"webpack-api-mocker": "^1.7.6",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.1.1",
"workbox-webpack-plugin": "4.3.1"
......
......@@ -113,7 +113,7 @@ checkBrowsers(paths.appPath, isInteractive)
return console.log(err);
}
if (isInteractive) {
clearConsole();
// clearConsole();
}
// We used to support resolving modules according to `NODE_PATH`.
......
......@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import './less/index.less';
import App from './component/layout/App';
import * as serviceWorker from './serviceWorker';
import axios from "./service/index"
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
......
let url=(str)=>{
let _url = `${process.env.REACT_APP_API}${(/^\//ig).test(str)? '':'/'}${str}`;
return _url;
}
let success=(da)=>{
// debugger
if(!da){ return []}
let data=da;
if(data){
return data;
}else{
return Promise.reject(data);
}
return data;
}
let error=(e)=>{
// debugger
if (e.response){
let errors = e.response.data;
switch (e.response.status) {
case 401:
console.info("无获取数据权限");
break;
case 404:{
console.error(errors.message)
}break;
default :{
console.error(errors["exceptionMessage"]||errors["message"])
}break;
}
}else{
if(typeof e == "string"){
console.log(e);
}else if(e.message.includes("Network Error")){
console.log("网络较弱!")
}else if(e.message.includes('timeout')){
console.log('请求超时!');
}else{
console.log(e.message);
}
// debugger
}
return Promise.reject(e);
}
export {
url,success,error
}
\ No newline at end of file
import axios from "axios";
import {url,error,success} from "./config";
let config = {
// baseURL:process.env.VUE_APP_baseURL,// || process.env.apiUrl || ""
// timeout: 60 * 1000, // Timeout
// withCredentials: true, // Check cross-site Access-Control
headers: {
}
};
const _axios = axios.create(config);
_axios.interceptors.request.use(
function (config) {
// debugger
// Do something before request is sent
return config;
},
function (error) {
// Do something with request error
return Promise.reject(error);
}
);
// Add a response interceptor
_axios.interceptors.response.use(
function (response) {
// debugger;
// Do something with response data
if ("data" in response) {
// debugger;
return config.success(response.data)
}
// debugger;
console.log("非标准输出!")
return response;
},
function (error) {
// Do something with response error
return Promise.reject(error);
}
);
export default {
GET(target,params={}){
return _axios.get((target),{params})
},
POST(target,params={}){
return _axios.post((target),params)
}
}
// Plugin.install = function (Vue, options) {
// Vue.axios = _axios;
// window.axios = _axios;
// Object.defineProperties(Vue.prototype, {
// axios: {
// get() {
// return _axios;
// }
// },
// $axios: {
// get() {
// return _axios;
// }
// },
// });
// };
// Vue.use(Plugin)
// export default Plugin;
\ No newline at end of file
export default {
'GET /api': {
code:200,data:[],message:"ok"
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import React,{Component} from 'react';
import PropTypes from 'prop-types';
import{connect} from "react-redux";
import EVENT from "../../store/EVENT"
import $http from "../../service";
@connect((state)=>{
// debugger
let {layout,login} = state
......@@ -11,8 +12,11 @@ import EVENT from "../../store/EVENT"
componentDidMount(){
// debugger
console.log(this)
console.log($http)
$http.GET("/api")
.then(d=>{
debugger
})
}
/**
* @name 同步修改
......
......@@ -1742,6 +1742,13 @@ aws4@^1.8.0:
version "1.8.0"
resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
axios@^0.19.0:
version "0.19.0"
resolved "https://registry.npm.taobao.org/axios/download/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
dependencies:
follow-redirects "1.5.10"
is-buffer "^2.0.2"
axobject-query@^2.0.2:
version "2.0.2"
resolved "https://registry.npm.taobao.org/axobject-query/download/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9"
......@@ -2012,7 +2019,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
version "4.11.8"
resolved "https://registry.npm.taobao.org/bn.js/download/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
body-parser@1.19.0:
body-parser@1.19.0, body-parser@^1.19.0:
version "1.19.0"
resolved "https://registry.npm.taobao.org/body-parser/download/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
dependencies:
......@@ -2311,7 +2318,7 @@ chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.npm.taobao.org/chardet/download/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.4:
chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.4, chokidar@^2.1.5:
version "2.1.8"
resolved "https://registry.npm.taobao.org/chokidar/download/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
dependencies:
......@@ -2369,6 +2376,13 @@ clean-css@4.2.x:
dependencies:
source-map "~0.6.0"
clear-module@^3.2.0:
version "3.2.0"
resolved "https://registry.npm.taobao.org/clear-module/download/clear-module-3.2.0.tgz#cbffcb1a873869c3ef07fc8e036851970c7c7272"
dependencies:
parent-module "^1.0.1"
resolve-from "^4.0.0"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.npm.taobao.org/cli-cursor/download/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
......@@ -2474,6 +2488,10 @@ color@^3.0.0:
color-convert "^1.9.1"
color-string "^1.5.2"
colors-cli@^1.0.21:
version "1.0.26"
resolved "https://registry.npm.taobao.org/colors-cli/download/colors-cli-1.0.26.tgz#5368aec90c80364e6868c57224e74596963ef8ff"
combined-stream@^1.0.6, combined-stream@~1.0.6:
version "1.0.8"
resolved "https://registry.npm.taobao.org/combined-stream/download/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
......@@ -2956,6 +2974,12 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.
dependencies:
ms "2.0.0"
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
debug@^3.0.0, debug@^3.1.1, debug@^3.2.5, debug@^3.2.6:
version "3.2.6"
resolved "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
......@@ -3086,6 +3110,13 @@ detect-port-alt@1.1.6:
address "^1.0.1"
debug "^2.6.0"
detect-port@^1.3.0:
version "1.3.0"
resolved "https://registry.npm.taobao.org/detect-port/download/detect-port-1.3.0.tgz#d9c40e9accadd4df5cac6a782aefd014d573d1f1"
dependencies:
address "^1.0.1"
debug "^2.6.0"
diff-sequences@^24.9.0:
version "24.9.0"
resolved "https://registry.npm.taobao.org/diff-sequences/download/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
......@@ -3587,6 +3618,10 @@ etag@~1.8.1:
version "1.8.1"
resolved "https://registry.npm.taobao.org/etag/download/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
eventemitter3@^3.0.0:
version "3.1.2"
resolved "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
eventemitter3@^4.0.0:
version "4.0.0"
resolved "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-4.0.0.tgz#d65176163887ee59f386d64c82610b696a4a74eb"
......@@ -3655,7 +3690,7 @@ expect@^24.9.0:
jest-message-util "^24.9.0"
jest-regex-util "^24.9.0"
express@^4.16.2:
express@^4.16.2, express@^4.16.4:
version "4.17.1"
resolved "https://registry.npm.taobao.org/express/download/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
dependencies:
......@@ -3907,6 +3942,12 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"
follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
dependencies:
debug "=3.1.0"
follow-redirects@^1.0.0:
version "1.9.0"
resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.9.0.tgz?cache=0&sync_timestamp=1567775546836&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.9.0.tgz#8d5bcdc65b7108fe1508649c79c12d732dcedb4f"
......@@ -4413,6 +4454,14 @@ http-proxy-middleware@^0.19.1:
lodash "^4.17.11"
micromatch "^3.1.10"
http-proxy@1.17.0:
version "1.17.0"
resolved "https://registry.npm.taobao.org/http-proxy/download/http-proxy-1.17.0.tgz#7ad38494658f84605e2f6db4436df410f4e5be9a"
dependencies:
eventemitter3 "^3.0.0"
follow-redirects "^1.0.0"
requires-port "^1.0.0"
http-proxy@^1.17.0:
version "1.18.0"
resolved "https://registry.npm.taobao.org/http-proxy/download/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a"
......@@ -4668,6 +4717,10 @@ is-buffer@^1.0.2, is-buffer@^1.1.5:
version "1.1.6"
resolved "https://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz?cache=0&sync_timestamp=1569904999656&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-buffer%2Fdownload%2Fis-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
is-buffer@^2.0.2:
version "2.0.4"
resolved "https://registry.npm.taobao.org/is-buffer/download/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623"
is-callable@^1.1.4:
version "1.1.4"
resolved "https://registry.npm.taobao.org/is-callable/download/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"
......@@ -5570,6 +5623,10 @@ loader-utils@1.2.3, loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.
emojis-list "^2.0.0"
json5 "^1.0.1"
local-ip-url@^1.0.1:
version "1.0.2"
resolved "https://registry.npm.taobao.org/local-ip-url/download/local-ip-url-1.0.2.tgz#8755dab6aaaa46154c371acc3b1db29b810a8f39"
locate-path@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/locate-path/download/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
......@@ -6447,7 +6504,7 @@ param-case@2.1.x:
dependencies:
no-case "^2.2.0"
parent-module@^1.0.0:
parent-module@^1.0.0, parent-module@^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/parent-module/download/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
dependencies:
......@@ -6537,6 +6594,10 @@ path-to-regexp@^1.7.0:
dependencies:
isarray "0.0.1"
path-to-regexp@^3.0.0:
version "3.2.0"
resolved "https://registry.npm.taobao.org/path-to-regexp/download/path-to-regexp-3.2.0.tgz#fa7877ecbc495c601907562222453c43cc204a5f"
path-type@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/path-type/download/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
......@@ -9457,6 +9518,20 @@ webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.npm.taobao.org/webidl-conversions/download/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
webpack-api-mocker@^1.7.6:
version "1.7.6"
resolved "https://registry.npm.taobao.org/webpack-api-mocker/download/webpack-api-mocker-1.7.6.tgz#040f28e9c01925775327c2b062ab503c99c7b5fb"
dependencies:
body-parser "^1.19.0"
chokidar "^2.1.5"
clear-module "^3.2.0"
colors-cli "^1.0.21"
detect-port "^1.3.0"
express "^4.16.4"
http-proxy "1.17.0"
local-ip-url "^1.0.1"
path-to-regexp "^3.0.0"
webpack-dev-middleware@^3.5.1:
version "3.7.2"
resolved "https://registry.npm.taobao.org/webpack-dev-middleware/download/webpack-dev-middleware-3.7.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwebpack-dev-middleware%2Fdownload%2Fwebpack-dev-middleware-3.7.2.tgz#0019c3db716e3fa5cecbf64f2ab88a74bab331f3"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!