web-component-gallery 2.0.31 → 2.0.32

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,13 +1,8 @@
1
1
  import Modal from 'ant-design-vue/es/modal'
2
- import { Browse } from '../lib'
3
-
4
- const defaultComponents = {
5
- Browse
6
- }
7
-
8
- export default Vue => {
9
- function dialog(component, componentProps, modalProps) {
2
+ export default (Vue) => {
3
+ function dialog (component, componentProps, modalProps) {
10
4
  const _vm = this
5
+ modalProps = modalProps || {}
11
6
  if (!_vm || !_vm._isVue) {
12
7
  return
13
8
  }
@@ -16,7 +11,7 @@ export default Vue => {
16
11
  dialogDiv = document.createElement('div')
17
12
  dialogDiv.setAttribute('type', 'dialog')
18
13
  document.body.appendChild(dialogDiv)
19
- }
14
+ }
20
15
 
21
16
  const handle = function (checkFunction, afterHandel) {
22
17
  if (checkFunction instanceof Function) {
@@ -35,20 +30,20 @@ export default Vue => {
35
30
  }
36
31
 
37
32
  const dialogInstance = new Vue({
38
- data() {
33
+ data () {
39
34
  return {
40
35
  visible: true
41
36
  }
42
37
  },
43
38
  router: _vm.$router,
44
39
  store: _vm.$store,
45
- mounted() {
46
- this.$on('close', () => {
40
+ mounted () {
41
+ this.$on('close', (v) => {
47
42
  this.handleClose()
48
43
  })
49
44
  },
50
45
  methods: {
51
- handleClose() {
46
+ handleClose () {
52
47
  handle(this.$refs._component.onCancel, () => {
53
48
  this.visible = false
54
49
  this.$refs._component.$emit('close')
@@ -56,7 +51,7 @@ export default Vue => {
56
51
  dialogInstance.$destroy()
57
52
  })
58
53
  },
59
- handleOk() {
54
+ handleOk () {
60
55
  handle(this.$refs._component.onOK || this.$refs._component.onOk, () => {
61
56
  this.visible = false
62
57
  this.$refs._component.$emit('close')
@@ -71,57 +66,41 @@ export default Vue => {
71
66
  if (modalModel) {
72
67
  delete modalProps.model
73
68
  }
74
- const ModalProps = Object.assign({}, (modalModel && { model: modalModel }) || {}, {
75
- attrs: Object.assign(
76
- {},
77
- {
78
- ...(modalProps.attrs || modalProps)
79
- },
80
- {
81
- visible: this.visible
82
- }
83
- ),
84
- on: Object.assign(
85
- {},
86
- {
87
- ...(modalProps.on || modalProps)
69
+ const ModalProps = Object.assign({}, modalModel && { model: modalModel } || {}, {
70
+ attrs: Object.assign({}, {
71
+ ...(modalProps.attrs || modalProps)
72
+ }, {
73
+ visible: this.visible
74
+ }),
75
+ on: Object.assign({}, {
76
+ ...(modalProps.on || modalProps)
77
+ }, {
78
+ ok: () => {
79
+ that.handleOk()
88
80
  },
89
- {
90
- ok: () => {
91
- that.handleOk()
92
- },
93
- cancel: () => {
94
- that.handleClose()
95
- }
81
+ cancel: () => {
82
+ that.handleClose()
96
83
  }
97
- )
84
+ })
98
85
  })
99
86
 
100
87
  const componentModel = componentProps && componentProps.model
101
88
  if (componentModel) {
102
89
  delete componentProps.model
103
90
  }
104
- const ComponentProps = Object.assign({}, (componentModel && { model: componentModel }) || {}, {
91
+ const ComponentProps = Object.assign({}, componentModel && { model: componentModel } || {}, {
105
92
  ref: '_component',
106
- attrs: Object.assign(
107
- {},
108
- {
109
- ...((componentProps && componentProps.attrs) || componentProps)
110
- }
111
- ),
112
- on: Object.assign(
113
- {},
114
- {
115
- ...((componentProps && componentProps.on) || componentProps)
116
- }
117
- )
93
+ attrs: Object.assign({}, {
94
+ ...((componentProps && componentProps.attrs) || componentProps)
95
+ }),
96
+ on: Object.assign({}, {
97
+ ...((componentProps && componentProps.on) || componentProps)
98
+ })
118
99
  })
119
100
 
120
- const componentContent = typeof component === 'string' ? defaultComponents[ component ] : component
121
-
122
- return h(Modal, ModalProps, [h(componentContent, ComponentProps)])
101
+ return h(Modal, ModalProps, [h(component, ComponentProps)])
123
102
  }
124
- }).$mount(dialogDiv)
103
+ }).$mount(dialogDiv)
125
104
  }
126
105
 
127
106
  Object.defineProperty(Vue.prototype, '$dialog', {
@@ -131,4 +110,4 @@ export default Vue => {
131
110
  }
132
111
  }
133
112
  })
134
- }
113
+ }
@@ -60,7 +60,9 @@ function renderContent(h, url, images) {
60
60
 
61
61
  const attrs = {
62
62
  src: url,
63
- ...(astrictH && { style: `width: auto; height: ${astrictH}px; objectFit: contain;` })
63
+ style: astrictH
64
+ ? `width: auto; height: ${astrictH}px; objectFit: contain;`
65
+ : 'width: 100%; height: 100%;'
64
66
  }
65
67
 
66
68
  if (CustomTag === 'iframe') attrs['controls'] = true
@@ -120,21 +120,12 @@ export default {
120
120
  return
121
121
  }
122
122
 
123
- this.$dialog(
124
- 'Browse',
125
- { data: { url } },
126
- {
127
- title: '预览文件',
128
- width: 1104,
129
- height: 848,
130
- centered: true,
131
- maskClosable: false,
132
- footer: false,
133
- bodyStyle: {
134
- height: 'calc( 100% - 54px )'
135
- }
136
- }
137
- )
123
+ // 仅适用于子项目调起
124
+ this.$postM({
125
+ type: 'customModal',
126
+ name: 'browse',
127
+ params: {data: this.modalValue.find(item => item.uid === uid)}
128
+ })
138
129
  },
139
130
 
140
131
  handleFileChange({ file, fileList }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [