From 6efffad513a8f96455b7b7bd4b9ace168bcece01 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 28 Aug 2018 17:07:17 +0800 Subject: [PATCH] do not compile less in production --- src/components/SettingDrawer/index.js | 17 +++++++---------- src/components/SettingDrawer/index.less | 2 +- src/layouts/BasicLayout.js | 4 +++- src/locales/zh-CN.js | 4 ++-- src/models/setting.js | 4 ++++ 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/SettingDrawer/index.js b/src/components/SettingDrawer/index.js index 47e1b6c4..fb299e01 100644 --- a/src/components/SettingDrawer/index.js +++ b/src/components/SettingDrawer/index.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Select, message, Drawer, List, Switch, Divider, Icon, Button } from 'antd'; +import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert } from 'antd'; import { formatMessage } from 'umi/locale'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { connect } from 'dva'; @@ -215,18 +215,15 @@ class SettingDrawer extends PureComponent { text={JSON.stringify(setting)} onCopy={() => message.success(formatMessage({ id: 'app.setting.copyinfo' }))} > - -
- {formatMessage({ id: 'app.setting.production.hint' })} -
+ ); diff --git a/src/components/SettingDrawer/index.less b/src/components/SettingDrawer/index.less index 4c7a735c..1731d490 100644 --- a/src/components/SettingDrawer/index.less +++ b/src/components/SettingDrawer/index.less @@ -71,5 +71,5 @@ .productionHint { font-size: 12px; color: @text-color-secondary; - margin-top: 8px; + margin-top: 16px; } diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index ed4b09b0..148092c9 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -202,7 +202,9 @@ class BasicLayout extends React.PureComponent { )} - {this.state.rendering ? null : } + {this.state.rendering && process.env.NODE_ENV === 'production' ? null : ( // Do show SettingDrawer in production + + )} ); } diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 05107549..6f680b27 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -162,6 +162,6 @@ export default { 'app.setting.othersettings': '其他设置', 'app.setting.weakmode': '色弱模式', 'app.setting.copy': '拷贝设置', - 'app.setting.copyinfo': '拷贝成功,请到 src/defaultSetting.js 中替换', - 'app.setting.production.hint': '设置侧边栏只会出现在开发环境,请手动配置 src/defaultSetting.js', + 'app.setting.copyinfo': '拷贝成功,请到 src/defaultSetting.js 中替换默认配置', + 'app.setting.production.hint': '设置栏只用于开发环境预览,请拷贝后手动修改 src/defaultSetting.js', }; diff --git a/src/models/setting.js b/src/models/setting.js index 6f65cc03..26b7c876 100644 --- a/src/models/setting.js +++ b/src/models/setting.js @@ -3,6 +3,10 @@ import defaultSetting from '../defaultSetting'; let lessNodesAppended; const updateTheme = primaryColor => { + // Don't compile less in production! + if (process.env.NODE_ENV === 'production') { + return; + } // Determine if the component is remounted if (!primaryColor) { return; -- GitLab