From b60c5305c493d4f347abb716feb429ad4fb49654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Sep 2018 00:47:10 +0800 Subject: [PATCH] Turn off caching by default --- src/utils/request.js | 8 +++++++- src/utils/utils.js | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/request.js b/src/utils/request.js index fc1810be..4faaae74 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,6 +2,7 @@ import fetch from 'dva/fetch'; import { notification } from 'antd'; import router from 'umi/router'; import hash from 'hash.js'; +import { isAntdPro } from './utils'; const codeMessage = { 200: '服务器成功返回请求的数据。', @@ -62,7 +63,12 @@ const cachedSave = (response, hashcode) => { * @param {object} [options] The options we want to pass to "fetch" * @return {object} An object containing either "data" or "err" */ -export default function request(url, options = {}) { +export default function request( + url, + options = { + expirys: isAntdPro(), + } +) { /** * Produce fingerprints based on url and parameters * Maybe url has the same parameters diff --git a/src/utils/utils.js b/src/utils/utils.js index c5e5fb86..fdb32a7f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -207,3 +207,7 @@ export function formatWan(val) { } return result; } + +export function isAntdPro() { + return window.location.hostname === 'preview.pro.ant.design'; +} -- GitLab