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); }