1
admin
2026-01-27 88916464ff5c3be9f677aca273d0cc8c2a6700dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
//node_modules\@ant-design-vue\pro-layout\es\components\SettingDrawer
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
 
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
 
import './index.less';
import omit from 'omit.js';
import PropTypes from 'ant-design-vue/es/_util/vue-types';
import 'ant-design-vue/es/divider/style';
import Divider from 'ant-design-vue/es/divider';
import 'ant-design-vue/es/drawer/style';
import Drawer from 'ant-design-vue/es/drawer';
import 'ant-design-vue/es/list/style';
import List from 'ant-design-vue/es/list';
import 'ant-design-vue/es/switch/style';
import Switch from 'ant-design-vue/es/switch';
import 'ant-design-vue/es/button/style';
import Button from 'ant-design-vue/es/button';
import 'ant-design-vue/es/icon/style';
import Icon from 'ant-design-vue/es/icon';
import 'ant-design-vue/es/alert/style';
import Alert from 'ant-design-vue/es/alert';
import antPortal from 'ant-design-vue/es/_util/portalDirective';
import 'ant-design-vue/es/message/style';
import message from 'ant-design-vue/es/message';
import BlockCheckbox from './BlockCheckbox';
import ThemeColor from './ThemeColor';
import LayoutSetting, { renderLayoutSettingItem } from './LayoutChange';
import { updateTheme, updateColorWeak } from '../../utils/dynamicTheme';
import { contentWidthCheck, genStringToTheme } from '../../utils/util';
import CopyToClipboard from 'vue-copy-to-clipboard';
var baseClassName = 'ant-pro-setting-drawer';
var BodyProps = {
  title: PropTypes.string.def('')
};
var Body = {
  props: BodyProps,
  render: function render(h) {
    var title = this.title;
    return h("div", {
      style: {
        marginBottom: 24
      }
    }, [h("h3", {
      "class": "".concat(baseClassName, "-title")
    }, [title]), this.$slots["default"]]);
  }
};
 
var defaultI18nRender = function defaultI18nRender(t) {
  return t;
};
 
var getThemeList = function getThemeList(i18nRender) {
  var list = window.umi_plugin_ant_themeVar || [];
  var themeList = [{
    key: 'light',
    url: 'https://gw.alipayobjects.com/zos/antfincdn/NQ%24zoisaD2/jpRkZQMyYRryryPNtyIC.svg',
    title: i18nRender('app.setting.pagestyle.light')
  }, {
    key: 'dark',
    url: 'https://gw.alipayobjects.com/zos/antfincdn/XwFOFbLkSM/LCkqqYNmvBEbokSDscrm.svg',
    title: i18nRender('app.setting.pagestyle.dark')
  }];
  var darkColorList = [{
    key: '#1890ff',
    color: '#1890ff',
    theme: 'dark'
  }];
  var lightColorList = [{
    key: '#1890ff',
    color: '#1890ff',
    theme: 'dark'
  }];
 
  if (list.find(function (item) {
    return item.theme === 'dark';
  })) {
    themeList.push({
      // disable click
      disable: true,
      key: 'realDark',
      url: 'https://gw.alipayobjects.com/zos/antfincdn/hmKaLQvmY2/LCkqqYNmvBEbokSDscrm.svg',
      title: i18nRender('app.setting.pagestyle.realdark')
    });
  } // insert  theme color List
 
 
  list.forEach(function (item) {
    var color = (item.modifyVars || {})['@primary-color'];
 
    if (item.theme === 'dark' && color) {
      darkColorList.push(_objectSpread({
        color: color
      }, item));
    }
 
    if (!item.theme || item.theme === 'light') {
      lightColorList.push(_objectSpread({
        color: color
      }, item));
    }
  });
  return {
    colorList: {
      dark: darkColorList,
      light: lightColorList
    },
    themeList: themeList
  };
};
 
var handleChangeSetting = function handleChangeSetting(key, value, hideMessageLoading) {
  if (key === 'primaryColor') {
    // 更新主色调
    updateTheme(value);
  }
 
  if (key === 'colorWeak') {
    updateColorWeak(value);
  }
};
 
var genCopySettingJson = function genCopySettingJson(settings) {
  return JSON.stringify(omit(_objectSpread({}, settings, {
    primaryColor: genStringToTheme(settings.primaryColor)
  }), ['colorWeak']), null, 2);
};
 
export var settings = {
  theme: PropTypes.oneOf(['dark', 'light', 'realDark']),
  primaryColor: PropTypes.string,
  layout: PropTypes.oneOf(['sidemenu', 'topmenu']),
  colorWeak: PropTypes.bool,
  contentWidth: PropTypes.oneOf(['Fluid', 'Fixed']).def('Fluid'),
  // 替换兼容 PropTypes.oneOf(['Fluid', 'Fixed']).def('Fluid')
  // contentWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).def('Fluid'),
  fixedHeader: PropTypes.bool,
  fixSiderbar: PropTypes.bool,
  hideHintAlert: PropTypes.bool.def(false),
  hideCopyButton: PropTypes.bool.def(false)
};
export var SettingDrawerProps = {
  getContainer: PropTypes.func,
  settings: PropTypes.objectOf(settings),
  i18nRender: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]).def(false)
};
var SettingDrawer = {
  name: 'SettingDrawer',
  props: SettingDrawerProps,
  inject: ['locale'],
  data: function data() {
    return {
      show: false
    };
  },
  render: function render(h) {
    var _this = this;
 
    var setShow = this.setShow,
        getContainer = this.getContainer,
        settings = this.settings;
    var _settings$theme = settings.theme,
        theme = _settings$theme === void 0 ? 'dark' : _settings$theme,
        _settings$primaryColo = settings.primaryColor,
        primaryColor = _settings$primaryColo === void 0 ? 'daybreak' : _settings$primaryColo,
        _settings$layout = settings.layout,
        layout = _settings$layout === void 0 ? 'sidemenu' : _settings$layout,
        _settings$fixedHeader = settings.fixedHeader,
        fixedHeader = _settings$fixedHeader === void 0 ? false : _settings$fixedHeader,
        _settings$fixSiderbar = settings.fixSiderbar,
        fixSiderbar = _settings$fixSiderbar === void 0 ? false : _settings$fixSiderbar,
        contentWidth = settings.contentWidth,
        hideHintAlert = settings.hideHintAlert,
        hideCopyButton = settings.hideCopyButton,
        colorWeak = settings.colorWeak;
    var i18n = this.$props.i18nRender || this.locale || defaultI18nRender;
    var themeList = getThemeList(i18n);
    var isTopMenu = layout === 'topmenu';
    var iconStyle = {
      color: '#fff',
      fontSize: 20
    };
 
    var changeSetting = function changeSetting(type, value) {
      _this.$emit('change', {
        type: type,
        value: value
      });
 
      handleChangeSetting(type, value, false);
    };
 
    return h(Drawer, {
      attrs: {
        visible: this.show,
        width: 300,
        placement: "right",
        getContainer: getContainer
        /*handle={
          <div class="ant-pro-setting-drawer-handle" onClick={() => setShow(!this.show)}>
            {this.show
              ? (<Icon type="close" style={iconStyle} />)
              : (<Icon type="setting" style={iconStyle} />)
            }
          </div>
        }*/
 
      },
      on: {
        "close": function close() {
          return setShow(false);
        }
      },
      style: {
        zIndex: 999
      }
    }, [h("template", {
      slot: "handle"
    }, [h("div", {
      "class": "".concat(baseClassName, "-handle"),
      on: {
        "click": function click() {
          return setShow(!_this.show);
        }
      }
    }, [this.show ? h(Icon, {
      attrs: {
        type: "close"
      },
      style: iconStyle
    }) : h(Icon, {
      attrs: {
        type: "setting"
      },
      style: iconStyle
    })])]), h("div", {
      "class": "".concat(baseClassName, "-content")
    }, [h(Body, {
      attrs: {
        title: i18n('app.setting.pagestyle')
      }
    }, [h(BlockCheckbox, {
      attrs: {
        i18nRender: i18n,
        list: themeList.themeList,
        value: theme
      },
      on: {
        "change": function change(val) {
          changeSetting('theme', val);
        }
      }
    })]), h(ThemeColor, {
      attrs: {
        i18nRender: i18n,
        title: i18n('app.setting.themecolor'),
        value: primaryColor,
        colors: themeList.colorList[theme === 'realDark' ? 'dark' : 'light']
      },
      on: {
        "change": function change(color) {
          changeSetting('primaryColor', color, null);
        }
      }
    }), h(Divider), h(Body, {
      attrs: {
        title: i18n('app.setting.navigationmode')
      }
    }, [h(BlockCheckbox, {
      attrs: {
        i18nRender: i18n,
        value: layout
      },
      on: {
        "change": function change(value) {
          changeSetting('layout', value, null);
        }
      }
    })]), h(LayoutSetting, {
      attrs: {
        i18nRender: i18n,
        contentWidth: contentWidth,
        fixedHeader: fixedHeader,
        fixSiderbar: isTopMenu ? false : fixSiderbar,
        layout: layout
      },
      on: {
        "change": function change(_ref) {
          var type = _ref.type,
              value = _ref.value;
          changeSetting(type, value);
        }
      }
    }), h(Divider), h(Body, {
      attrs: {
        title: i18n('app.setting.othersettings')
      }
    }, [h(List, {
      attrs: {
        split: false,
        renderItem: function renderItem(item) {
          return renderLayoutSettingItem(h, item);
        },
        dataSource: [{
          title: i18n('app.setting.weakmode'),
          action: h(Switch, {
            attrs: {
              size: "small",
              checked: !!colorWeak
            },
            on: {
              "change": function change(checked) {
                return changeSetting('colorWeak', checked);
              }
            }
          })
        }]
      }
    })]), hideHintAlert && hideCopyButton ? null : h(Divider), hideHintAlert ? null : h(Alert, {
      attrs: {
        type: "warning",
        message: i18n('app.setting.production.hint'),
        icon: h(Icon, {
          attrs: {
            type: 'notification'
            
          }
        }),
        showIcon: false
      },
      style: {
        marginBottom: '16px',
        display:'none'
      }
    }), hideCopyButton ? null : h(CopyToClipboard, {
      attrs: {
        text: genCopySettingJson(settings)
      },
      on: {
        "copy": function copy() {
          localStorage.setItem('theme_save',JSON.stringify(settings));
          return message.success(i18n('app.setting.copyinfo'));
        }
      }
    }, [h(Button, {
      attrs: {
        block: true
      }
    }, [h(Icon, {
      attrs: {
        type: 'save'
      }
    }), i18n('app.setting.copy')])]), h("div", {
      "class": "".concat(baseClassName, "-content-footer")
    }, [this.$slots["default"]])])]);
  },
  methods: {
    setShow: function setShow(flag) {
      this.show = flag;
    }
  }
};
 
SettingDrawer.install = function (Vue) {
  Vue.use(antPortal);
  Vue.component(SettingDrawer.name, SettingDrawer);
};
 
export default SettingDrawer;