vdesign-ui 0.2.7 → 0.2.9
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/dist/components/empty/index.vue +4 -4
- package/dist/components/mixins/outlineConfigPlugin.js +45 -45
- package/dist/components/tab/index.vue +79 -38
- package/dist/components/tabs/index.vue +169 -70
- package/dist/components/tabs/style.less +298 -266
- package/dist/components/toast/index.js +47 -44
- package/dist/components/toast/style.less +3 -1
- package/dist/components/utils/env.js +20 -1
- package/dist/token.css +2948 -2948
- package/dist/vdesign-ui.common.js +374 -240
- package/dist/vdesign-ui.css +1 -1
- package/dist/vdesign-ui.umd.js +374 -240
- package/dist/vdesign-ui.umd.min.js +3 -3
- package/package.json +1 -1
|
@@ -2,82 +2,85 @@ import Vue from 'vue';
|
|
|
2
2
|
import ToastComponent from './index.vue';
|
|
3
3
|
import { inBrowser } from '../utils/env';
|
|
4
4
|
|
|
5
|
-
let
|
|
6
|
-
|
|
5
|
+
let queueResult = []
|
|
6
|
+
|
|
7
|
+
function getType(value) {
|
|
8
|
+
if (value !== value) return 'NaN';
|
|
9
|
+
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
class VdToast extends Vue.extend(ToastComponent) {
|
|
9
13
|
constructor(options) {
|
|
10
14
|
super();
|
|
11
|
-
|
|
12
15
|
this.vm = this.$mount();
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
this.timer = null
|
|
18
|
+
|
|
19
|
+
// 判断传入的 options 类型,并进行赋值
|
|
15
20
|
if (typeof options === 'string' || typeof options === 'number') {
|
|
16
21
|
this.message = options;
|
|
17
|
-
} else if (
|
|
22
|
+
} else if (getType(options) === 'object') {
|
|
23
|
+
this.message = options.message || '';
|
|
24
|
+
this.duration = options.duration || 1500;
|
|
18
25
|
Object.assign(this, options);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
this.init();
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
/**
|
|
32
|
+
* 初始化方法
|
|
33
|
+
*/
|
|
24
34
|
init() {
|
|
25
35
|
if (inBrowser) {
|
|
26
|
-
document.body.appendChild(this.vm.$el)
|
|
27
|
-
this.start()
|
|
36
|
+
document.body.appendChild(this.vm.$el)
|
|
37
|
+
this.start()
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
start() {
|
|
32
|
-
clearTimeout(timer)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
clearTimeout(this.timer)
|
|
43
|
+
/**
|
|
44
|
+
* 在挂载真实 DOM 树后显示过渡效果
|
|
45
|
+
*/
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
this.isShow = true
|
|
36
48
|
if (this.duration > 0) {
|
|
37
49
|
this.end();
|
|
38
50
|
}
|
|
39
|
-
},
|
|
51
|
+
}, 0)
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
end() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (inBrowser && document.body.contains(this.vm.$el)) {
|
|
50
|
-
document.body.removeChild(this.vm.$el);
|
|
51
|
-
}
|
|
52
|
-
}, 500);
|
|
53
|
-
}, this.duration);
|
|
54
|
-
}
|
|
55
|
+
/**
|
|
56
|
+
* 关闭过渡效果之后移除真实 DOM 树节点
|
|
57
|
+
*/
|
|
58
|
+
this.timer = setTimeout(() => {
|
|
59
|
+
this.clear()
|
|
60
|
+
}, this.duration)
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
clear() {
|
|
58
|
-
this.isShow = false
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
this.isShow = false
|
|
65
|
+
if (inBrowser && this.vm.$el) {
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
this.vm.$el.parentNode && this.vm.$el.parentNode.removeChild(this.vm.$el);
|
|
68
|
+
}, 500)
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// 添加静态方法,支持手动清除
|
|
75
|
-
showToast.clear = () => {
|
|
76
|
-
currentToast && currentToast.clear();
|
|
77
|
-
currentToast = null;
|
|
78
|
-
};
|
|
73
|
+
const Toast = (options) => {
|
|
74
|
+
const NewOption = new VdToast(options)
|
|
75
|
+
queueResult.push(NewOption)
|
|
76
|
+
return NewOption
|
|
77
|
+
}
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
Toast.clear = () => {
|
|
80
|
+
queueResult.forEach(toast => {
|
|
81
|
+
toast.clear()
|
|
82
|
+
})
|
|
83
|
+
queueResult = [];
|
|
84
|
+
}
|
|
82
85
|
|
|
83
|
-
export default
|
|
86
|
+
export default Toast
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
text-align: center;
|
|
12
12
|
z-index: 1000;
|
|
13
|
-
transition:
|
|
13
|
+
transition: all .3s linear;
|
|
14
14
|
opacity: 0;
|
|
15
|
+
visibility: hidden;
|
|
15
16
|
// token
|
|
16
17
|
min-width: var(--width-toast-small);
|
|
17
18
|
max-width: var(--width-toast-large);
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
|
|
25
26
|
&.vd-toast-show {
|
|
26
27
|
opacity: 1;
|
|
28
|
+
visibility: visible;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
&-icon {
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
|
|
2
3
|
export const inBrowser = typeof window !== 'undefined';
|
|
4
|
+
|
|
5
|
+
export const isServer = Vue.prototype.$isServer;
|
|
6
|
+
|
|
7
|
+
export function isObject(val) {
|
|
8
|
+
return val !== null && typeof val === 'object';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isInDocument(element) {
|
|
12
|
+
return document.body.contains(element);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function removeNode(el) {
|
|
16
|
+
const parent = el.parentNode;
|
|
17
|
+
|
|
18
|
+
if (parent) {
|
|
19
|
+
parent.removeChild(el);
|
|
20
|
+
}
|
|
21
|
+
}
|