vdesign-ui 0.2.7 → 0.2.8
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 +18 -3
- package/dist/components/tabs/index.vue +10 -2
- package/dist/components/tabs/style.less +6 -0
- package/dist/components/toast/index.js +38 -45
- 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 +170 -138
- package/dist/vdesign-ui.css +1 -1
- package/dist/vdesign-ui.umd.js +170 -138
- package/dist/vdesign-ui.umd.min.js +3 -3
- package/package.json +1 -1
|
@@ -27,10 +27,10 @@ export default {
|
|
|
27
27
|
image: {
|
|
28
28
|
type: String,
|
|
29
29
|
default: 'nodata', // 默认类型
|
|
30
|
-
validator(value) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
30
|
+
// validator(value) {
|
|
31
|
+
// // 只接受以下类型值
|
|
32
|
+
// return ['nodata', 'network', 'notfound','noposition','nomargin','nocoupons','nosearch','nonotice','noorders','noocomments'].includes(value);
|
|
33
|
+
// }
|
|
34
34
|
},
|
|
35
35
|
description: String,
|
|
36
36
|
size: {
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// outlineConfigPlugin.js
|
|
2
|
-
import { inBrowser } from '../utils/env'
|
|
3
|
-
// __debug=1&__debug_vdesign_token=1
|
|
4
|
-
const OutlineConfig = {
|
|
5
|
-
install(Vue, options = {}) {
|
|
6
|
-
const outlineConfig = Vue.observable({
|
|
7
|
-
outlineEnabled: options.outlineEnabled ||false,
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
Vue.prototype.$outlineConfig = outlineConfig;
|
|
11
|
-
|
|
12
|
-
Vue.mixin({
|
|
13
|
-
created() {
|
|
14
|
-
if (inBrowser) {
|
|
15
|
-
this.$outlineConfig.outlineEnabled = this.shouldEnableOutline()
|
|
16
|
-
this.$watch('$outlineConfig.outlineEnabled', (newValue) => {
|
|
17
|
-
document.documentElement.style.setProperty('--outline-visible', newValue ? '1px' : '0');
|
|
18
|
-
}, { immediate: true });
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
methods:{
|
|
22
|
-
shouldEnableOutline() {
|
|
23
|
-
if (!inBrowser) {
|
|
24
|
-
// 如果是在服务端渲染,返回默认值 false
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
// 获取URL的查询参数部分
|
|
28
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
29
|
-
// 对于哈希模式,也解析哈希中的查询字符串
|
|
30
|
-
const hashParams = window.location.hash.split('?')[1] ? new URLSearchParams(window.location.hash.split('?')[1]) : null;
|
|
31
|
-
|
|
32
|
-
// 检查查询参数或哈希中的参数
|
|
33
|
-
const debug = searchParams.has('__debug') || (hashParams && hashParams.has('__debug')) ? searchParams.get('__debug') === '1' || (hashParams && hashParams.get('__debug') === '1') : false;
|
|
34
|
-
const vdesignToken = searchParams.has('__debug_vdesign_token') || (hashParams && hashParams.has('__debug_vdesign_token')) ? searchParams.get('__debug_vdesign_token') === '1' || (hashParams && hashParams.get('__debug_vdesign_token') === '1') : false;
|
|
35
|
-
|
|
36
|
-
return debug && vdesignToken;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export default OutlineConfig;
|
|
1
|
+
// outlineConfigPlugin.js
|
|
2
|
+
import { inBrowser } from '../utils/env'
|
|
3
|
+
// __debug=1&__debug_vdesign_token=1
|
|
4
|
+
const OutlineConfig = {
|
|
5
|
+
install(Vue, options = {}) {
|
|
6
|
+
const outlineConfig = Vue.observable({
|
|
7
|
+
outlineEnabled: options.outlineEnabled ||false,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
Vue.prototype.$outlineConfig = outlineConfig;
|
|
11
|
+
|
|
12
|
+
Vue.mixin({
|
|
13
|
+
created() {
|
|
14
|
+
if (inBrowser) {
|
|
15
|
+
this.$outlineConfig.outlineEnabled = this.shouldEnableOutline()
|
|
16
|
+
this.$watch('$outlineConfig.outlineEnabled', (newValue) => {
|
|
17
|
+
document.documentElement.style.setProperty('--outline-visible', newValue ? '1px' : '0');
|
|
18
|
+
}, { immediate: true });
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
methods:{
|
|
22
|
+
shouldEnableOutline() {
|
|
23
|
+
if (!inBrowser) {
|
|
24
|
+
// 如果是在服务端渲染,返回默认值 false
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
// 获取URL的查询参数部分
|
|
28
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
29
|
+
// 对于哈希模式,也解析哈希中的查询字符串
|
|
30
|
+
const hashParams = window.location.hash.split('?')[1] ? new URLSearchParams(window.location.hash.split('?')[1]) : null;
|
|
31
|
+
|
|
32
|
+
// 检查查询参数或哈希中的参数
|
|
33
|
+
const debug = searchParams.has('__debug') || (hashParams && hashParams.has('__debug')) ? searchParams.get('__debug') === '1' || (hashParams && hashParams.get('__debug') === '1') : false;
|
|
34
|
+
const vdesignToken = searchParams.has('__debug_vdesign_token') || (hashParams && hashParams.has('__debug_vdesign_token')) ? searchParams.get('__debug_vdesign_token') === '1' || (hashParams && hashParams.get('__debug_vdesign_token') === '1') : false;
|
|
35
|
+
|
|
36
|
+
return debug && vdesignToken;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export default OutlineConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="tabClasses">
|
|
3
|
-
<slot />
|
|
3
|
+
<slot v-if="shouldRender" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
@@ -11,7 +11,6 @@ export default {
|
|
|
11
11
|
name: [String, Number],
|
|
12
12
|
title: {
|
|
13
13
|
type: String,
|
|
14
|
-
required: true,
|
|
15
14
|
},
|
|
16
15
|
arrow: {
|
|
17
16
|
type: Boolean,
|
|
@@ -20,10 +19,15 @@ export default {
|
|
|
20
19
|
},
|
|
21
20
|
data() {
|
|
22
21
|
return {
|
|
22
|
+
isRendered: false,
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
25
|
watch: {
|
|
26
|
-
|
|
26
|
+
isActive(newVal) {
|
|
27
|
+
if (newVal && !this.isRendered) {
|
|
28
|
+
this.isRendered = true;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
27
31
|
},
|
|
28
32
|
computed: {
|
|
29
33
|
isActive() {
|
|
@@ -40,6 +44,17 @@ export default {
|
|
|
40
44
|
? this.name
|
|
41
45
|
: this.$parent.tabs.indexOf(this);
|
|
42
46
|
},
|
|
47
|
+
shouldRender() {
|
|
48
|
+
if (this.$parent.lazyRender) {
|
|
49
|
+
return this.isRendered || this.isActive;
|
|
50
|
+
} else {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
computedTitle() {
|
|
55
|
+
// Since the title slot is now handled by vd-tabs, we return the title prop
|
|
56
|
+
return this.title;
|
|
57
|
+
},
|
|
43
58
|
},
|
|
44
59
|
created() {
|
|
45
60
|
this.$parent.registerTab(this);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="vd-tabs">
|
|
2
|
+
<div class="vd-tabs" :class="stickyClasses">
|
|
3
3
|
<div class="vd-tabs__wrap" :class="menuClasses" ref="tabsWrap">
|
|
4
|
-
<div :class="[barType,scrollspy]" ref="tabsContainer">
|
|
4
|
+
<div class="vd-tabs__nav" :class="[barType,scrollspy]" ref="tabsContainer">
|
|
5
5
|
<div v-for="(item, index) in navList" :key="index" :class="[tabClasses(item), lineClasses]" @click="handleChange(index)">
|
|
6
6
|
<span class="vd-tabs-text-cell" :class="ellipsisClasses">
|
|
7
7
|
{{ item.title }}
|
|
@@ -45,6 +45,8 @@ export default {
|
|
|
45
45
|
actBorder: Boolean,
|
|
46
46
|
backgroundColor: Boolean,
|
|
47
47
|
divider: Boolean,
|
|
48
|
+
sticky: Boolean,
|
|
49
|
+
lazyRender: Boolean,
|
|
48
50
|
},
|
|
49
51
|
data() {
|
|
50
52
|
return {
|
|
@@ -98,6 +100,11 @@ export default {
|
|
|
98
100
|
[`${prefixCls}-${this.tabsType}-bar`]: this.tabsType,
|
|
99
101
|
};
|
|
100
102
|
},
|
|
103
|
+
stickyClasses() {
|
|
104
|
+
return {
|
|
105
|
+
[`${prefixCls}--sticky`]: this.sticky,
|
|
106
|
+
};
|
|
107
|
+
},
|
|
101
108
|
},
|
|
102
109
|
methods: {
|
|
103
110
|
// 当菜单按钮被点击时触发事件
|
|
@@ -136,6 +143,7 @@ export default {
|
|
|
136
143
|
// 如果当前没有选中的标签且导航列表不为空,则将第一个标签设为当前值
|
|
137
144
|
if (!this.currentValue && this.navList.length) {
|
|
138
145
|
this.currentValue = this.navList[0].name;
|
|
146
|
+
this.$emit("input", this.currentValue);
|
|
139
147
|
}
|
|
140
148
|
},
|
|
141
149
|
handleChange(index) {
|
|
@@ -2,82 +2,75 @@ import Vue from 'vue';
|
|
|
2
2
|
import ToastComponent from './index.vue';
|
|
3
3
|
import { inBrowser } from '../utils/env';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
function getType(value) {
|
|
7
|
+
if (value !== value) return 'NaN';
|
|
8
|
+
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
9
|
+
}
|
|
7
10
|
|
|
8
11
|
class VdToast extends Vue.extend(ToastComponent) {
|
|
9
12
|
constructor(options) {
|
|
10
13
|
super();
|
|
11
|
-
|
|
12
14
|
this.vm = this.$mount();
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
this.timer = null
|
|
17
|
+
|
|
18
|
+
// 判断传入的 options 类型,并进行赋值
|
|
15
19
|
if (typeof options === 'string' || typeof options === 'number') {
|
|
16
20
|
this.message = options;
|
|
17
|
-
} else if (
|
|
21
|
+
} else if (getType(options) === 'object') {
|
|
22
|
+
this.message = options.message || '';
|
|
23
|
+
this.duration = options.duration || 1500;
|
|
18
24
|
Object.assign(this, options);
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
this.init();
|
|
22
28
|
}
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* 初始化方法
|
|
32
|
+
*/
|
|
24
33
|
init() {
|
|
25
34
|
if (inBrowser) {
|
|
26
|
-
document.body.appendChild(this.vm.$el)
|
|
27
|
-
this.start()
|
|
35
|
+
document.body.appendChild(this.vm.$el)
|
|
36
|
+
this.start()
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
start() {
|
|
32
|
-
clearTimeout(timer);
|
|
33
|
-
timer = setTimeout(() => {
|
|
34
|
-
this.isShow = true;
|
|
35
40
|
|
|
41
|
+
start() {
|
|
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
|
|
|
54
|
+
|
|
42
55
|
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
|
-
}
|
|
56
|
+
/**
|
|
57
|
+
* 关闭过渡效果之后移除真实 DOM 树节点
|
|
58
|
+
*/
|
|
59
|
+
this.timer = setTimeout(() => {
|
|
60
|
+
this.clear()
|
|
61
|
+
}, this.duration)
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
clear() {
|
|
58
|
-
this.isShow = false
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
this.isShow = false
|
|
66
|
+
if (inBrowser && this.vm.$el) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
this.vm.$el.parentNode.removeChild(this.vm.$el);
|
|
69
|
+
}, 500)
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
const showToast = options => {
|
|
69
|
-
currentToast && currentToast.clear(); // 清除现有的 toast
|
|
70
|
-
currentToast = new VdToast(options); // 创建新的 toast 实例
|
|
71
|
-
return currentToast;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// 添加静态方法,支持手动清除
|
|
75
|
-
showToast.clear = () => {
|
|
76
|
-
currentToast && currentToast.clear();
|
|
77
|
-
currentToast = null;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// 在 Vue 的原型上挂载,方便全局调用
|
|
81
|
-
Vue.prototype.$VdToast = showToast;
|
|
74
|
+
const Toast = options => new VdToast(options)
|
|
82
75
|
|
|
83
|
-
export default
|
|
76
|
+
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
|
+
}
|