dpzvc-ui 1.2.1 → 1.2.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dpzvc-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Vue组件库",
5
5
  "main": "dist/dpzvc.js",
6
6
  "module": "dist/dpzvc.esm.js",
@@ -47,6 +47,7 @@
47
47
  "babel-runtime": "^6.26.0",
48
48
  "cross-env": "^3.1.4",
49
49
  "css-loader": "^6.11.0",
50
+ "del": "^8.0.1",
50
51
  "eslint": "^3.12.2",
51
52
  "eslint-plugin-html": "^1.7.0",
52
53
  "exif-js": "^2.2.1",
@@ -92,4 +93,4 @@
92
93
  "directories": {
93
94
  "example": "example"
94
95
  }
95
- }
96
+ }
@@ -1,153 +1,88 @@
1
1
  /**
2
- * Created by admin on 2017/6/22.
2
+ * Indicator - Vue 2.7 CLI 适配版
3
3
  */
4
- import Indicator from './Indicator'
5
- import {camelcaseToHyphen} from '../../utils/util'
6
- import Vue from 'vue'
7
- let instance;
8
-
9
- Indicator.newInstance = properties => {
10
-
11
- let _props = properties || {};
12
-
13
- let props = '';
14
-
15
- Object.keys(_props).forEach(prop => {
16
-
17
- props += ' :' + camelcaseToHyphen(prop) + '=' + prop
18
- })
19
-
20
- const div = document.createElement('div');
21
-
22
- document.body.appendChild(div);
23
-
24
- let indicator = new Vue({
25
- el: div,
26
- template: `<Indicator ${props} v-model="visible" ></Indicator>`,
27
- components: {
28
- Indicator
29
- },
30
- data: Object.assign(_props, {
31
- visible: false,
32
- size: 45,
33
- type: 'snake',
34
- color: '#ffffff',
35
- text: '加载中...',
36
- onRemove:function(){}
37
-
38
- }),
39
- methods: {
40
- remove() {
41
- this.$children[0].visible = false;
42
- setTimeout(() => {
43
- this.destroy();
44
- }, 300)
45
- },
46
- destroy(){
47
4
 
48
- this.$destroy();
49
-
50
- // if (!this.$el) return;
51
- document.body.removeChild(this.$el);
52
- this.onRemove()
53
- }
54
- }
55
- }).$children[0];
56
-
57
-
58
- return {
59
- open(options){
60
-
61
- indicator.$parent.visible = true;
62
- indicator.$parent.onRemove = options.onRemove;
63
-
64
-
65
- if ('size' in options) {
66
- indicator.$parent.size = options.size;
67
- }
68
-
69
- if ('type' in options) {
70
- indicator.$parent.type = options.type;
71
- }
72
-
73
- if ('color' in options) {
74
- indicator.$parent.color = options.color;
75
- }
5
+ import Vue from 'vue'
6
+ import Indicator from './Indicator.vue'
76
7
 
77
- if ('text' in options) {
78
- indicator.$parent.text = options.text;
79
- }
8
+ let instance = null
80
9
 
81
- },
10
+ function createInstance(props = {}) {
11
+ const IndicatorConstructor = Vue.extend(Indicator)
82
12
 
83
- remove(){
13
+ const vm = new IndicatorConstructor({
14
+ propsData: {
15
+ size: 45,
16
+ type: 'snake',
17
+ color: '#ffffff',
18
+ text: '加载中...',
19
+ ...props
20
+ }
21
+ })
84
22
 
85
- indicator.visible = false;
23
+ vm.$mount()
24
+ document.body.appendChild(vm.$el)
86
25
 
87
- indicator.$parent.remove()
26
+ vm.visible = false
88
27
 
89
- },
90
- component: indicator
91
- }
92
- };
28
+ vm.$on('remove', () => {
29
+ destroyInstance()
30
+ })
93
31
 
32
+ return vm
33
+ }
94
34
 
95
- function confirm(options) {
96
- instance = instance || Indicator.newInstance({
97
- size: 45,
98
- color: '#ffffff',
99
- text: '正在加载...',
100
- type: 'snake'
101
- });
35
+ function destroyInstance() {
36
+ if (!instance) return
37
+ instance.$destroy()
38
+ if (instance.$el && instance.$el.parentNode) {
39
+ instance.$el.parentNode.removeChild(instance.$el)
40
+ }
41
+ instance = null
42
+ }
102
43
 
103
- options.onRemove = function () {
104
- instance = null;
105
- }
44
+ function open(options = {}) {
45
+ if (!instance) {
46
+ instance = createInstance(options)
47
+ }
106
48
 
107
- instance.open(options)
49
+ Object.keys(options).forEach(key => {
50
+ instance.$props[key] = options[key]
51
+ })
108
52
 
53
+ instance.visible = true
109
54
  }
110
55
 
56
+ function close() {
57
+ if (!instance) return
58
+ instance.visible = false
59
+ destroyInstance()
60
+ }
111
61
 
112
- Indicator.blade = function (props = {}) {
62
+ /* ================== 对外 API ================== */
113
63
 
114
- props.type = 'blade';
115
- return confirm(props)
116
- }
64
+ Indicator.open = open
117
65
 
66
+ Indicator.remove = close
118
67
 
119
68
  Indicator.snake = function (props = {}) {
69
+ props.type = 'snake'
70
+ open(props)
71
+ }
120
72
 
121
- props.type = 'snake';
122
- return confirm(props)
73
+ Indicator.blade = function (props = {}) {
74
+ props.type = 'blade'
75
+ open(props)
123
76
  }
124
77
 
125
78
  Indicator.circle = function (props = {}) {
126
-
127
- props.type = 'fading-circle';
128
- return confirm(props)
79
+ props.type = 'fading-circle'
80
+ open(props)
129
81
  }
130
82
 
131
83
  Indicator.bounce = function (props = {}) {
132
-
133
- props.type = 'double-bounce';
134
- return confirm(props)
84
+ props.type = 'double-bounce'
85
+ open(props)
135
86
  }
136
87
 
137
- Indicator.remove = function () {
138
-
139
-
140
- if (!instance) return false;
141
-
142
- instance = instance || Indicator.newInstance({
143
- size: 45,
144
- color: '#ffffff',
145
- text: '正在加载...',
146
- type: 'snake'
147
- })
148
-
149
- instance.remove()
150
- }
151
-
152
-
153
- export default Indicator
88
+ export default Indicator
@@ -1,52 +1,43 @@
1
1
  /**
2
- * Created by admin on 2017/5/8.
2
+ * messageGroup.js
3
+ * 兼容 Vue 2.7 runtime-only 构建
3
4
  */
4
5
 
5
- import MessageGroup from './messageGroup.vue'
6
6
  import Vue from 'vue';
7
- import {camelcaseToHyphen} from '../../utils/util'
8
-
9
- MessageGroup.newInstance = function (props) {
10
-
11
- let _props = props || {};
12
-
13
- let _prop = '';
14
- Object.keys(_props).forEach((prop) => {
15
-
16
- _prop += ' :' + camelcaseToHyphen(prop) + '=' + prop
17
- });
18
-
19
- let div = document.createElement('div');
20
-
21
- document.body.appendChild(div);
22
-
23
- let message = new Vue({
24
- el: div,
25
- data: _props,
26
- template:`<Message-group ${_prop} ></Message-group>`,
27
- components: {MessageGroup},
28
- }).$children[0];
29
-
30
-
31
- return {
32
-
33
- add(props){
34
- message.add(props)
35
- },
36
- remove(props) {
37
-
38
- message.remove(props)
39
- },
40
- component: message,
41
- destroy(){
42
- message.closeAll();
43
-
44
- setTimeout(()=>{
45
- document.body.removeChild(document.getElementsByClassName('dpzvc-message')[0].parentElement)
46
- },500)
47
-
48
- }
7
+ import MessageGroup from './messageGroup.vue'; // 你的 Vue 组件
8
+ import { camelcaseToHyphen } from '../../utils/util';
9
+
10
+ MessageGroup.newInstance = function (props = {}) {
11
+ const div = document.createElement('div');
12
+ document.body.appendChild(div);
13
+
14
+ // 使用 render 函数代替 template,兼容 runtime-only
15
+ const messageVm = new Vue({
16
+ data() {
17
+ return { ...props };
18
+ },
19
+ render(h) {
20
+ return h(MessageGroup, { props });
21
+ }
22
+ }).$mount(div);
23
+
24
+ const instance = messageVm.$children[0]; // 确保实例存在
25
+
26
+ return {
27
+ add(options) {
28
+ if (instance) instance.add(options);
29
+ },
30
+ remove(options) {
31
+ if (instance) instance.remove(options);
32
+ },
33
+ component: instance,
34
+ destroy() {
35
+ if (instance) instance.closeAll();
36
+ setTimeout(() => {
37
+ if (div.parentNode) div.parentNode.removeChild(div);
38
+ }, 500);
49
39
  }
50
- }
40
+ };
41
+ };
51
42
 
52
- export default MessageGroup;
43
+ export default MessageGroup;
@@ -1,161 +1,114 @@
1
1
  /**
2
- * Created by admin on 2017/3/30.
2
+ * confirm.js - 适配 Vue 2.7 runtime-only
3
3
  */
4
- import Modal from './modal.vue'
5
- import VButton from '../button'
6
- import Vue from 'vue'
7
-
8
- import { camelcaseToHyphen } from '../../utils/util'
4
+ import Vue from 'vue';
5
+ import Modal from './modal.vue';
6
+ import VButton from '../button';
7
+ import { camelcaseToHyphen } from '../../utils/util';
9
8
 
10
9
  const prefixCls = 'dpzvc-modal';
11
10
 
12
- Modal.newInstance = properties =>{
13
-
14
- let _props = properties || {};
15
-
16
- let props = '';
17
-
18
- Object.keys(_props).forEach( prop =>{
19
-
20
- props += ' :'+camelcaseToHyphen(prop) + '=' + prop
21
- })
22
-
23
- const div = document.createElement('div');
24
-
25
- document.body.appendChild(div);
26
-
27
- const modal = new Vue({
28
- el:div,
29
- template:`<Modal ${props} v-model="visible" :width="width" >
30
- <div class="${prefixCls}-header-inner ellipse-fir" v-html="title" slot="header"></div>
31
- <div class="${prefixCls}-body-inner" v-html="body" slot="body"></div>
32
- <template slot="footer">
33
- <v-button type="primary" :radius="false" @click="cancle" v-if="showCancle">{{cancleText}}</v-button>
34
- <v-button type="normal" :radius="false" @click="ok" :loading="buttonLoading">{{okText}}</v-button>
35
- </template>
36
- </Modal>`,
37
- components:{
38
- Modal,
39
- VButton
40
- },
41
- data:Object.assign(_props,{
42
- visible:false,
43
- width:'70%',
44
- body:'',
45
- title:'',
46
- okText:'确定',
47
- cancleText:'取消',
48
- loading:false,
49
- buttonLoading:false,
50
- showCancle:true,
51
- showHead:true,
52
- onOk:function(){},
53
- onCancle:function(){},
54
- onRemove:function(){}
55
- }),
56
- methods:{
57
- cancle(){
58
- this.$children[0].visible = false;
59
- this.onCancle();
60
- this.remove()
61
-
62
- },
63
- ok(){
64
- console.log('asd')
65
- if (this.loading) {
66
- this.buttonLoading = true;
67
- this.$children[0].buttonLoading = true;
68
- } else {
69
- this.visible = false;
70
- this.remove();
71
- }
72
-
73
- this.onOk()
74
- },
75
- remove(){
76
- this.$children[0].visible = false;
77
- setTimeout(()=>{
78
- this.destroy();
79
- },300)
80
- },
81
- destroy(){
82
-
83
- this.$destroy();
84
- document.body.removeChild(this.$el);
85
- this.onRemove()
86
- },
87
-
88
-
89
- },
90
- }).$children[0];
91
-
92
-
93
-
94
- return {
95
-
96
- show(props){
97
-
98
-
99
-
100
- // if ('width' in props) {
101
- // modal.$parent.width = props.width
102
- // }
103
- //
104
- // if ('title' in props) {
105
- // modal.$parent.title = props.title
106
- // }
107
- //
108
- // if ('showHead' in props) {
109
- // modal.$parent.showHead = props.showHead
110
- // }
111
- //
112
- // if ('okText' in props) {
113
- // modal.$parent.okText = props.okText
114
- // }
115
- //
116
- // if ('cancleText' in props) {
117
- // modal.$parent.cancleText = props.cancleText
118
- // }
119
- //
120
- //
121
- // if ('onCancle' in props) {
122
- // modal.$parent.onCancle = props.onCancle
123
- // }
124
- //
125
- // if ('onOk' in props) {
126
- // modal.$parent.onOk = props.onOk
127
- // }
128
- //
129
- // if ('loading' in props) {
130
- // modal.$parent.loading = props.loading
131
- // }
132
- //
133
- // if ('body' in props) {
134
- // modal.$parent.body = props.body
135
- // }
136
-
137
- Object.keys(props).forEach((item)=>{
138
- modal.$parent[item] = props[item]
139
- })
140
-
141
- modal.$parent.showCancle = props.showCancle;
142
- modal.$parent.onRemove = props.onRemove;
143
- modal.visible = true;
144
-
145
-
146
- },
147
- remove () {
148
-
149
- modal.visible = false;
150
- modal.$parent.buttonLoading = false;
151
- modal.$parent.remove();
152
-
11
+ Modal.newInstance = function(properties = {}) {
12
+ // 创建一个新的 Vue 构造函数
13
+ const ModalConstructor = Vue.extend({
14
+ components: { Modal, VButton },
15
+ data() {
16
+ return Object.assign({
17
+ visible: false,
18
+ width: '70%',
19
+ body: '',
20
+ title: '',
21
+ okText: '确定',
22
+ cancleText: '取消',
23
+ loading: false,
24
+ buttonLoading: false,
25
+ showCancle: true,
26
+ showHead: true,
27
+ onOk: () => {},
28
+ onCancle: () => {},
29
+ onRemove: () => {}
30
+ }, properties);
31
+ },
32
+ render(h) {
33
+ const footer = [
34
+ this.showCancle
35
+ ? h('v-button', {
36
+ props: { type: 'primary', radius: false },
37
+ on: { click: this.cancle }
38
+ }, this.cancleText)
39
+ : null,
40
+ h('v-button', {
41
+ props: { type: 'normal', radius: false, loading: this.buttonLoading },
42
+ on: { click: this.ok }
43
+ }, this.okText)
44
+ ];
45
+
46
+ return h(Modal, {
47
+ props: {
48
+ value: this.visible,
49
+ width: this.width,
50
+ showHead: this.showHead,
51
+ footerHide: false
153
52
  },
154
- component:modal
155
-
53
+ on: {
54
+ 'on-ok': this.ok,
55
+ 'on-cancle': this.cancle
56
+ }
57
+ }, [
58
+ h('div', { slot: 'header', domProps: { innerHTML: this.title }, class: `${prefixCls}-header-inner ellipse-fir` }),
59
+ h('div', { slot: 'body', domProps: { innerHTML: this.body }, class: `${prefixCls}-body-inner` }),
60
+ h('template', { slot: 'footer' }, footer)
61
+ ]);
62
+ },
63
+ methods: {
64
+ cancle() {
65
+ this.visible = false;
66
+ this.onCancle();
67
+ this.remove();
68
+ },
69
+ ok() {
70
+ if (this.loading) {
71
+ this.buttonLoading = true;
72
+ } else {
73
+ this.visible = false;
74
+ this.remove();
75
+ }
76
+ this.onOk();
77
+ },
78
+ remove() {
79
+ this.visible = false;
80
+ setTimeout(() => this.destroy(), 300);
81
+ },
82
+ destroy() {
83
+ this.$destroy();
84
+ if (this.$el && this.$el.parentNode) {
85
+ this.$el.parentNode.removeChild(this.$el);
86
+ }
87
+ this.onRemove();
88
+ }
156
89
  }
157
- };
158
-
159
-
90
+ });
91
+
92
+ // 实例化并挂载到 DOM
93
+ const div = document.createElement('div');
94
+ document.body.appendChild(div);
95
+ const instance = new ModalConstructor().$mount(div);
96
+
97
+ return {
98
+ show(props = {}) {
99
+ Object.keys(props).forEach(key => {
100
+ if (key in instance) {
101
+ instance[key] = props[key];
102
+ }
103
+ });
104
+ instance.visible = true;
105
+ },
106
+ remove() {
107
+ instance.remove();
108
+ },
109
+ component: instance
110
+ };
111
+ };
112
+
113
+ export default Modal;
160
114
 
161
- export default Modal