Commit 67c53bd0 by 陈英杰

合并分支 'dev' 到 'master'

Dev



查看合并请求 !161
parents 36156dde 76f09010
...@@ -10,15 +10,15 @@ import qs from 'qs'; ...@@ -10,15 +10,15 @@ import qs from 'qs';
import axios from 'axios'; import axios from 'axios';
import Layer from '@/plugins/Layer/index'; import Layer from '@/plugins/Layer/index';
import md5 from 'js-md5'; import md5 from 'js-md5';
import LRU from 'lru-cache' // import LRU from 'lru-cache'
const Cookie = process.client ? require('js-cookie') : {}; const Cookie = process.client ? require('js-cookie') : {};
const Sentry = process.client ? require('@sentry/browser') : require('@sentry/node'); const Sentry = process.client ? require('@sentry/browser') : require('@sentry/node');
// 给api加200ms缓存 // 给api加200ms缓存
const CACHED = new LRU({ // const CACHED = new LRU({
max: 1000, // max: 1000,
maxAge: 200 // maxAge: 200
}) // })
const DEF_DOMAIM = process.client const DEF_DOMAIM = process.client
? process.env.DEF_DOMAIM + (window.location.protocol.split(':')[0] === 'https' ? process.env.HTTPS_PORT : process.env.HTTP_PORT) ? process.env.DEF_DOMAIM + (window.location.protocol.split(':')[0] === 'https' ? process.env.HTTPS_PORT : process.env.HTTP_PORT)
...@@ -42,12 +42,12 @@ service.interceptors.request.use( ...@@ -42,12 +42,12 @@ service.interceptors.request.use(
Cookie.get('token') || Cookie.get('BCC_PROGRAM_USER_LOGIN_TOKEN') || ''; Cookie.get('token') || Cookie.get('BCC_PROGRAM_USER_LOGIN_TOKEN') || '';
} else { } else {
// 服务端api缓存 // 服务端api缓存
const { params = {}, headers = {} } = config // const { params = {}, headers = {} } = config
const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers)) // const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers))
// 缓存命中 // // 缓存命中
if (CACHED.has(key)) { // if (CACHED.has(key)) {
return Promise.resolve(CACHED.get(key)) // return Promise.resolve(CACHED.get(key))
} // }
} }
const noMsg = config.headers['noMsg'] || ''; const noMsg = config.headers['noMsg'] || '';
if (config.headers.hasOwnProperty('noMsg')) { if (config.headers.hasOwnProperty('noMsg')) {
...@@ -66,11 +66,11 @@ service.interceptors.response.use( ...@@ -66,11 +66,11 @@ service.interceptors.response.use(
const { status, data, config } = res; const { status, data, config } = res;
if (status === 200) { if (status === 200) {
const { code, errorCode, errorMessage } = data; const { code, errorCode, errorMessage } = data;
if (!process.client) { // if (!process.client) {
const { params = {}, headers = {} } = config // const { params = {}, headers = {} } = config
const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers)) // const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers))
CACHED.set(key, data) // CACHED.set(key, data)
} // }
if ((code !== 200 || errorCode !== 0) && code !== 0) { if ((code !== 200 || errorCode !== 0) && code !== 0) {
Sentry.captureException( Sentry.captureException(
new Error(`${status};${JSON.stringify(data)};${JSON.stringify(config)}`) new Error(`${status};${JSON.stringify(data)};${JSON.stringify(config)}`)
......
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 sign in to comment