Prechádzať zdrojové kódy

do not compile less in production

afc163 7 rokov pred
rodič
commit
6efffad513

+ 7 - 10
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' }))}
           >
-            <Button
-              style={{
-                width: 224,
-              }}
-            >
-              <Icon type="copy" />
+            <Button block icon="copy">
               {formatMessage({ id: 'app.setting.copy' })}
             </Button>
           </CopyToClipboard>
-          <div className={styles.productionHint}>
-            {formatMessage({ id: 'app.setting.production.hint' })}
-          </div>
+          <Alert
+            type="warning"
+            className={styles.productionHint}
+            message={formatMessage({ id: 'app.setting.production.hint' })}
+          />
         </div>
       </Drawer>
     );

+ 1 - 1
src/components/SettingDrawer/index.less

@@ -71,5 +71,5 @@
 .productionHint {
   font-size: 12px;
   color: @text-color-secondary;
-  margin-top: 8px;
+  margin-top: 16px;
 }

+ 3 - 1
src/layouts/BasicLayout.js

@@ -202,7 +202,9 @@ class BasicLayout extends React.PureComponent {
             )}
           </ContainerQuery>
         </DocumentTitle>
-        {this.state.rendering ? null : <SettingDrawer />}
+        {this.state.rendering && process.env.NODE_ENV === 'production' ? null : ( // Do show SettingDrawer in production
+          <SettingDrawer />
+        )}
       </React.Fragment>
     );
   }

+ 2 - 2
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',
 };

+ 4 - 0
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;