web-component-gallery 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
- import {toggleTheme} from "@zougt/theme-css-extract-webpack-plugin/dist/toggleTheme"
2
-
3
1
  import message from 'ant-design-vue/es/message'
4
2
 
5
3
  const watchTheme = {
@@ -40,7 +38,7 @@ export default {
40
38
  ToggleTheme(theme)
41
39
  }
42
40
  /** 子项目需挂载监听主题变化自动执行切换 */
43
- isHas && Vue.mixin(watchTheme)
41
+ isHas && Vue.mixin(watchTheme)
44
42
 
45
43
  /** 切换当前主题 */
46
44
  function ToggleTheme(scopeName) {
@@ -59,29 +57,36 @@ export default {
59
57
 
60
58
  /** 切换主题资源 */
61
59
  function ToggleThemeSource(scopeName) {
62
- /** 获取初始配置项 */
63
- // env.themeConfig 来源 vue.config.js define (webpack的DefinePlugin)
64
- const themeConfig = env.themeConfig
65
- /** 主题配置
66
- * @scopeName 名称
67
- * @multipleScopeVars 主题项
68
- * @extract 是否提取
69
- * @publicPath 资源输出路径
70
- * @outputDir 提取的 css 文件存放目录
71
- */
72
- toggleTheme({
73
- scopeName: `theme-${scopeName}`,
74
- multipleScopeVars: themeConfig.multipleScopeVars,
75
- extract: themeConfig.extract,
76
- publicPath: themeConfig.publicPath,
77
- outputDir: themeConfig.extractCssOutputDir
78
- })
79
-
80
- /** 加载主题对应样式文件 */
81
- // const requireLess = require.context('@/theme/styles', false, /\.less$/)
82
- // requireLess(`./${scopeName}.less`)
83
- let themeLink = document.getElementById('theme-stylesheet')
84
- themeLink.href = `${process.env.BASE_URL}static/style/${scopeName}.css`
60
+ try {
61
+ const { toggleTheme } = require('@zougt/theme-css-extract-webpack-plugin/dist/toggleTheme')
62
+ /** 获取初始配置项 */
63
+ // env.themeConfig 来源 vue.config.js define (webpack的DefinePlugin)
64
+ const themeConfig = env.themeConfig || {}
65
+ /** 主题配置
66
+ * @scopeName 名称
67
+ * @multipleScopeVars 主题项
68
+ * @extract 是否提取
69
+ * @publicPath 资源输出路径
70
+ * @outputDir 提取的 css 文件存放目录
71
+ */
72
+ toggleTheme({
73
+ scopeName: `theme-${scopeName}`,
74
+ multipleScopeVars: themeConfig.multipleScopeVars,
75
+ extract: themeConfig.extract,
76
+ publicPath: themeConfig.publicPath,
77
+ outputDir: themeConfig.extractCssOutputDir
78
+ })
79
+
80
+ /** 加载主题对应样式文件 */
81
+ // const requireLess = require.context('@/theme/styles', false, /\.less$/)
82
+ // requireLess(`./${scopeName}.less`)
83
+ let themeLink = document.getElementById('theme-stylesheet')
84
+ themeLink.href = `${process.env.BASE_URL}static/style/${scopeName}.css`
85
+ } catch(err) {
86
+ // message.error('主题资源加载失败')
87
+ console.error('换肤控件错误:', err)
88
+ throw err
89
+ }
85
90
  }
86
91
 
87
92
  }
@@ -3,5 +3,5 @@
3
3
 
4
4
  .dateTime {
5
5
  font-size: @font-size-lg;
6
- .flex-layout(@flexGap: 0 14px);
7
- }
6
+ .flex-layout(@flexGap: 0 @padding-xs);
7
+ }
@@ -0,0 +1,32 @@
1
+ import { Icon } from 'ant-design-vue/es'
2
+
3
+ const IconFont = {
4
+ name: 'IconFont',
5
+ props: {
6
+ scriptUrl: {
7
+ type: String,
8
+ default: '//at.alicdn.com/t/c/font_4641025_tdg12oa0nfq.js'
9
+ },
10
+ type: {
11
+ type: String,
12
+ required: true
13
+ }
14
+ },
15
+ computed: {
16
+ iconType() {
17
+ return Icon.createFromIconfontCN({
18
+ scriptUrl: this.scriptUrl
19
+ })
20
+ }
21
+ },
22
+ render() {
23
+ const IconComponent = this.iconType
24
+ return <IconComponent {...{ attrs: this.$attrs }} on={{ ...this.$listeners }} />
25
+ }
26
+ }
27
+
28
+ IconFont.install = function (Vue) {
29
+ Vue.component('IconFont', IconFont)
30
+ }
31
+
32
+ export default IconFont
@@ -0,0 +1 @@
1
+ require('./index.less');
File without changes
package/lib/index.js CHANGED
@@ -26,6 +26,8 @@ import Button from './button'
26
26
  import DescriptionsList from './descriptions-list'
27
27
  // no-data
28
28
  import { NoData, NoDataDirective } from './no-data'
29
+ // icon-font
30
+ import IconFont from './icon-font'
29
31
 
30
32
  // 新增指令导入 / 导出
31
33
  export const Directives = {
@@ -48,7 +50,8 @@ const components = {
48
50
  AmapDraw,
49
51
  AmapComp,
50
52
  Button,
51
- NoData
53
+ NoData,
54
+ IconFont
52
55
  }
53
56
 
54
57
  const install = function (Vue) {
@@ -78,7 +81,8 @@ export {
78
81
  AmapDraw,
79
82
  AmapComp,
80
83
  Button,
81
- NoData
84
+ NoData,
85
+ IconFont
82
86
  }
83
87
 
84
88
  export default {
@@ -1,5 +1,6 @@
1
1
  import PropTypes from 'ant-design-vue/es/_util/vue-types'
2
- import Modal from 'ant-design-vue/es/modal'
2
+ import { Modal } from 'ant-design-vue/es'
3
+ import IconFont from '../icon-font'
3
4
 
4
5
  const ModalProps = {
5
6
  mode: PropTypes.string.def('small'),
@@ -7,40 +8,73 @@ const ModalProps = {
7
8
  visible: PropTypes.bool.def(false),
8
9
  cancelHandle: PropTypes.func,
9
10
  attrs: PropTypes.object.def({})
10
- }
11
+ }
11
12
 
12
13
  const ModalComp = {
13
14
  name: 'WModal',
14
- props: ModalProps,
15
- functional: true,
16
- render(h, content) {
17
-
18
- const { props, children } = content
19
-
20
- const attrs = Object.assign({
15
+ props: ModalProps,
16
+ data() {
17
+ return {
18
+ modalModes: ['small', 'middle', 'large', 'max'],
19
+ internalMode: this.mode
20
+ }
21
+ },
22
+ watch: {
23
+ mode(newVal) {
24
+ this.internalMode = newVal
25
+ }
26
+ },
27
+ methods: {
28
+ handleBlank() {
29
+ window.open(this.$attrs.blankUrl, '_blank')
30
+ },
31
+ handleConvert() {
32
+ const currentIndex = this.modalModes.indexOf(this.internalMode)
33
+ const isLastMode = currentIndex === this.modalModes.length - 1
34
+ this.internalMode = isLastMode ? this.mode : this.modalModes[currentIndex + 1]
35
+ }
36
+ },
37
+ render() {
38
+ const {$attrs, visible} = this
39
+ const modalProps = {
21
40
  width: null,
22
41
  footer: null,
23
42
  keyboard: false,
24
- maskClosable: false
25
- }, props.attrs)
26
-
27
- delete props.attrs
28
-
29
- props.mode == 'screen' && delete props.title
43
+ maskClosable: false,
44
+ ...$attrs,
45
+ visible,
46
+ wrapClassName: `AntModal__${this.internalMode} ${$attrs.class || ''}`.trim()
47
+ }
30
48
 
31
49
  return (
32
50
  <Modal
33
- {...{ props, attrs, on: { cancel: props.cancelHandle } }}
34
- wrapClassName={`AntModal__${props.mode}`}
51
+ {...{ props: modalProps }}
52
+ on={{
53
+ cancel: this.cancelHandle,
54
+ ...this.$listeners
55
+ }}
35
56
  >
36
- { children }
57
+ {this.mode !== 'screen' && (
58
+ <div slot="title" class="AntModal__Title">
59
+ <span>{this.title}</span>
60
+ <div class="AntModal__Title__Blank">
61
+ <IconFont
62
+ type="icon-modal_convert"
63
+ on={{ click: this.handleConvert }}
64
+ />
65
+ {
66
+ $attrs.blankUrl &&
67
+ <IconFont
68
+ type="icon-modal_blank"
69
+ on={{ click: this.handleBlank }}
70
+ />
71
+ }
72
+ </div>
73
+ </div>
74
+ )}
75
+ {this.$slots.default}
37
76
  </Modal>
38
77
  )
39
-
40
- },
41
- mounted() {
42
- },
43
- methods: {
44
78
  }
45
79
  }
46
80
 
@@ -48,4 +82,4 @@ ModalComp.install = function (Vue) {
48
82
  Vue.component('ModalComp', ModalComp)
49
83
  }
50
84
 
51
- export default ModalComp
85
+ export default ModalComp
@@ -1,40 +1,53 @@
1
1
  @import '~ant-design-vue/lib/style/themes/default.less';
2
2
  @import '../../style/mixins.less';
3
3
 
4
- .AntModal__small {
5
- .ant-modal {
6
- .layout( 712px, 640px );
4
+ .AntModal {
5
+ &__small {
6
+ .ant-modal {
7
+ .layout( 712px, 640px );
8
+ }
7
9
  }
8
- }
9
-
10
- .AntModal__middle {
11
- .ant-modal {
12
- .layout( 1104px, 848px );
10
+ &__middle {
11
+ .ant-modal {
12
+ .layout( 1104px, 848px );
13
+ }
13
14
  }
14
- }
15
-
16
- .AntModal__large {
17
- .ant-modal {
18
- .layout( 1600px, 848px );
15
+ &__large {
16
+ .ant-modal {
17
+ .layout( 1600px, 848px );
18
+ }
19
19
  }
20
- }
21
-
22
- .AntModal__max {
23
- .ant-modal {
24
- top: 0;
25
- .layout();
20
+ &__max {
21
+ .ant-modal {
22
+ top: 0;
23
+ .layout();
24
+ }
26
25
  }
27
- }
26
+ &__screen {
27
+ .ant-modal {
28
+ top: 0;
29
+ padding: 0;
30
+ .layout();
31
+
32
+ &-body {
33
+ padding: 0;
34
+ }
35
+ }
36
+ }
37
+ &__Title {
38
+ .flex-layout();
28
39
 
29
- .AntModal__screen {
30
- .ant-modal {
31
- top: 0;
32
- padding: 0;
33
- .layout();
40
+ &__Blank {
41
+ flex: 1;
42
+ text-align: right;
43
+ margin-right: @padding-lg;
34
44
 
35
- &-body {
36
- padding: 0;
37
- }
45
+ .anticon {
46
+ cursor: pointer;
47
+ &:hover { color: @primary-color; }
48
+ &:first-child { margin-right: @padding-sm; }
49
+ }
50
+ }
38
51
  }
39
52
  }
40
53
 
@@ -45,5 +58,5 @@
45
58
  }
46
59
  &-body {
47
60
  flex: 1;
48
- }
61
+ }
49
62
  }
@@ -12,11 +12,8 @@
12
12
 
13
13
  <script>
14
14
 
15
- import { Icon, Empty } from 'ant-design-vue'
16
-
17
- const IconFont = Icon.createFromIconfontCN({
18
- scriptUrl: '//at.alicdn.com/t/c/font_4641025_6uucxf9fvta.js'
19
- })
15
+ import IconFont from '../icon-font'
16
+ import { Empty } from 'ant-design-vue'
20
17
 
21
18
  export default {
22
19
  name: 'NoData',
@@ -51,11 +51,8 @@
51
51
 
52
52
  <script>
53
53
 
54
- import { Table, Pagination, Icon } from 'ant-design-vue/es'
55
-
56
- const IconFont = Icon.createFromIconfontCN({
57
- scriptUrl: '//at.alicdn.com/t/c/font_4640977_auv55jur50b.js'
58
- })
54
+ import IconFont from '../icon-font'
55
+ import { Table, Pagination } from 'ant-design-vue/es'
59
56
 
60
57
  export default {
61
58
  components: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [