From 9f54a15ab8183fe1c7f3a381ae009c60e7e732d6 Mon Sep 17 00:00:00 2001 From: whyour Date: Mon, 29 Mar 2021 20:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dupstream=20gzip=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=EF=BC=8C=E5=89=8D=E7=AB=AF=E5=85=AC=E5=85=B1=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E9=87=87=E7=94=A8cdn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .umirc.ts | 21 ++++++++++++++++----- docker/front.conf | 2 +- src/utils/http.ts | 8 ++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.umirc.ts b/.umirc.ts index 1f033f8c..591fcc07 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -15,15 +15,26 @@ export default defineConfig({ changeOrigin: true, }, }, - chainWebpack(memo) { - memo.plugin('CompressionPlugin').use( + chainWebpack: (config) => { + config.plugin('compression-webpack-plugin').use( new CompressionPlugin({ - filename: '[path][base].gz', algorithm: 'gzip', - test: /\.js$|\.css$|\.html$/, + test: new RegExp('\\.(js|css)$'), threshold: 10240, - minRatio: 0.8, + minRatio: 0.6, }), ); }, + externals: { + react: 'window.React', + 'react-dom': 'window.ReactDOM', + codemirror: 'window.CodeMirror', + darkreader: 'window.DarkReader', + }, + scripts: [ + 'https://gw.alipayobjects.com/os/lib/react/16.13.1/umd/react.production.min.js', + 'https://gw.alipayobjects.com/os/lib/react-dom/16.13.1/umd/react-dom.production.min.js', + 'https://cdn.jsdelivr.net/npm/codemirror@5.60.0/lib/codemirror.min.js', + 'https://cdn.jsdelivr.net/npm/darkreader@4.9.27/darkreader.min.js', + ], }); diff --git a/docker/front.conf b/docker/front.conf index 29f439fb..837a64a7 100644 --- a/docker/front.conf +++ b/docker/front.conf @@ -18,7 +18,7 @@ server { gzip_vary on; gzip_comp_level 6; gzip_buffers 16 8k; - gzip_http_version 1.1; + gzip_http_version 1.0; location / { index index.html index.htm; diff --git a/src/utils/http.ts b/src/utils/http.ts index 27676a52..8b15baa8 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -5,10 +5,10 @@ import config from './config'; const time = Date.now(); const errorHandler = function (error: any) { if (error.response) { - const message = error.data - ? error.data.errors && error.data.errors.message - : error.response.statusText; - notification.error({ message }); + const message = error.data ? error.data.message : error.response.statusText; + if (error.response.status !== 401) { + notification.error({ message }); + } } else { console.log(error.message); }