vdesign-ui 0.2.9 → 0.2.12
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/README.md +78 -78
- package/dist/components/actionbar/index.js +8 -8
- package/dist/components/actionbar/index.vue +39 -39
- package/dist/components/actionbar/style.less +44 -44
- package/dist/components/actionbar-cell/index.js +7 -7
- package/dist/components/actionbar-cell/index.vue +38 -38
- package/dist/components/actions/index.js +6 -6
- package/dist/components/actions/index.vue +76 -76
- package/dist/components/actions/style.less +109 -109
- package/dist/components/actions-cell/index.js +6 -6
- package/dist/components/actions-cell/index.vue +94 -94
- package/dist/components/actions-cell/style.less +38 -38
- package/dist/components/activityviews/index.js +8 -8
- package/dist/components/activityviews/index.vue +192 -192
- package/dist/components/activityviews/style.less +151 -151
- package/dist/components/badge/index.js +8 -8
- package/dist/components/badge/index.vue +49 -49
- package/dist/components/badge/style.less +54 -54
- package/dist/components/button/index.js +8 -8
- package/dist/components/button/index.vue +93 -93
- package/dist/components/button/style.less +558 -558
- package/dist/components/calendar/index-element.vue +84 -84
- package/dist/components/calendar/index.js +7 -7
- package/dist/components/calendar/index.vue +52 -52
- package/dist/components/calendar/style.less +138 -138
- package/dist/components/checkbox/index.js +8 -8
- package/dist/components/checkbox/index.vue +161 -161
- package/dist/components/checkbox/style.less +288 -288
- package/dist/components/checkbox-group/index.js +7 -7
- package/dist/components/checkbox-group/index.vue +69 -69
- package/dist/components/common/state/index.vue +33 -33
- package/dist/components/common/state/style.less +47 -47
- package/dist/components/data-list/index.js +10 -10
- package/dist/components/data-list/index.vue +19 -19
- package/dist/components/data-list/style.less +623 -623
- package/dist/components/datetime-picker/index.js +7 -7
- package/dist/components/datetime-picker/index.vue +37 -37
- package/dist/components/datetime-picker/style.less +23 -23
- package/dist/components/dialog/index.js +8 -8
- package/dist/components/dialog/index.vue +164 -164
- package/dist/components/dialog/overlay-manager.js +18 -18
- package/dist/components/dialog/style.less +138 -138
- package/dist/components/divider/index.js +8 -8
- package/dist/components/divider/index.vue +54 -54
- package/dist/components/divider/style.less +92 -92
- package/dist/components/dropdown/index.js +8 -8
- package/dist/components/dropdown/index.vue +218 -218
- package/dist/components/dropdown/style.less +432 -432
- package/dist/components/empty/index.js +8 -8
- package/dist/components/empty/index.vue +138 -138
- package/dist/components/empty/style.less +60 -60
- package/dist/components/footer/index.js +6 -6
- package/dist/components/footer/index.vue +33 -33
- package/dist/components/footer/style.less +20 -20
- package/dist/components/footnav/index.js +6 -6
- package/dist/components/footnav/index.vue +93 -93
- package/dist/components/footnav/style.less +22 -22
- package/dist/components/footnav-item/index.js +6 -6
- package/dist/components/footnav-item/index.vue +50 -50
- package/dist/components/footnav-item/style.less +39 -39
- package/dist/components/form/index.js +6 -6
- package/dist/components/form/index.vue +12 -12
- package/dist/components/headnav/index.js +6 -6
- package/dist/components/headnav/index.vue +185 -185
- package/dist/components/headnav/style.less +231 -231
- package/dist/components/icon/font/iconfont.css +163 -163
- package/dist/components/icon/font/iconfont.js +5 -5
- package/dist/components/icon/index.js +9 -9
- package/dist/components/icon/index.vue +96 -96
- package/dist/components/icon/style.less +44 -44
- package/dist/components/input/calcTextareaHeight.js +162 -162
- package/dist/components/input/index.js +8 -8
- package/dist/components/input/index.vue +345 -345
- package/dist/components/input/style.less +470 -470
- package/dist/components/list/index.js +8 -8
- package/dist/components/list/index.vue +152 -152
- package/dist/components/list/style.less +213 -213
- package/dist/components/loading/index.js +6 -6
- package/dist/components/loading/index.vue +68 -68
- package/dist/components/loading/style.less +53 -53
- package/dist/components/mixins/clickoutside.js +81 -81
- package/dist/components/mixins/languageMixin.js +41 -41
- package/dist/components/mixins/outlineConfigPlugin.js +45 -45
- package/dist/components/mixins/themeMixin.js +43 -43
- package/dist/components/noticebar/index.js +8 -8
- package/dist/components/noticebar/index.vue +258 -258
- package/dist/components/noticebar/style.less +328 -328
- package/dist/components/overlay/index.js +8 -8
- package/dist/components/overlay/index.vue +184 -184
- package/dist/components/overlay/style.less +23 -23
- package/dist/components/pagebreak/index.js +6 -6
- package/dist/components/pagebreak/index.vue +67 -67
- package/dist/components/pagebreak/style.less +41 -41
- package/dist/components/password/index.js +8 -8
- package/dist/components/password/index.vue +60 -60
- package/dist/components/popover/index.js +8 -8
- package/dist/components/popover/index.vue +100 -100
- package/dist/components/popover/style.less +346 -346
- package/dist/components/popover/vue-popover.vue +314 -314
- package/dist/components/popup/index.js +7 -7
- package/dist/components/popup/index.vue +243 -243
- package/dist/components/radio/index.js +8 -8
- package/dist/components/radio/index.vue +184 -184
- package/dist/components/radio/style.less +293 -293
- package/dist/components/radio-group/index.js +6 -6
- package/dist/components/radio-group/index.vue +58 -58
- package/dist/components/result/index.js +8 -8
- package/dist/components/result/index.vue +73 -73
- package/dist/components/result/style.less +43 -43
- package/dist/components/search/index.js +8 -8
- package/dist/components/search/index.vue +66 -66
- package/dist/components/selector/index.js +8 -8
- package/dist/components/selector/index.vue +161 -161
- package/dist/components/selector/style.less +484 -484
- package/dist/components/skeleton/index.js +6 -6
- package/dist/components/skeleton/index.vue +207 -206
- package/dist/components/skeleton/style.less +196 -196
- package/dist/components/slider/draggable.js +49 -49
- package/dist/components/slider/index.js +6 -6
- package/dist/components/slider/index.vue +167 -167
- package/dist/components/slider/style.less +99 -99
- package/dist/components/slider/utils.js +59 -59
- package/dist/components/step/index.js +7 -7
- package/dist/components/step/index.vue +48 -48
- package/dist/components/step/style.less +57 -57
- package/dist/components/step-item/index.js +7 -7
- package/dist/components/step-item/index.vue +126 -126
- package/dist/components/step-item/style.less +362 -362
- package/dist/components/stepper/index.js +8 -8
- package/dist/components/stepper/index.vue +146 -146
- package/dist/components/style/index.vue +42 -42
- package/dist/components/switch/index.js +8 -8
- package/dist/components/switch/index.vue +72 -72
- package/dist/components/switch/style.less +56 -56
- package/dist/components/tab/index.js +7 -7
- package/dist/components/tab/index.vue +94 -93
- package/dist/components/tabs/index.js +8 -8
- package/dist/components/tabs/index.vue +281 -271
- package/dist/components/tabs/style.less +408 -409
- package/dist/components/tag/index.js +6 -6
- package/dist/components/tag/index.vue +64 -64
- package/dist/components/tag/style.less +210 -210
- package/dist/components/title/index.js +8 -8
- package/dist/components/title/index.vue +99 -99
- package/dist/components/title/style.less +187 -187
- package/dist/components/toast/index.js +97 -86
- package/dist/components/toast/index.vue +49 -49
- package/dist/components/toast/style.less +57 -57
- package/dist/components/transition/index.js +8 -8
- package/dist/components/transition/index.vue +13 -13
- package/dist/components/transition/style.less +208 -208
- package/dist/components/upload/index.js +6 -6
- package/dist/components/upload/index.vue +106 -106
- package/dist/components/upload/style.less +147 -147
- package/dist/components/utils/assist.js +34 -34
- package/dist/components/utils/env.js +21 -21
- package/dist/locale/ar.js +97 -97
- package/dist/locale/en.js +97 -97
- package/dist/locale/zh.js +97 -97
- package/dist/token.css +2988 -2988
- package/dist/vdesign-ui.common.js +308 -8512
- package/dist/vdesign-ui.css +1 -1
- package/dist/vdesign-ui.umd.js +312 -8516
- package/dist/vdesign-ui.umd.min.js +2 -8
- package/package.json +113 -113
|
@@ -1,258 +1,258 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="[mode ? `${prefixCls}-${mode}` : '', type ? 'vd-noticebar-' + type : '', { 'vd-noticebar-action': action }]"
|
|
4
|
-
v-if="isShow">
|
|
5
|
-
<!-- 左侧图标 -->
|
|
6
|
-
<div v-if="customLeft || customIcon" :class="`${prefixCls}-${mode}__left`">
|
|
7
|
-
<template v-if="customLeft">
|
|
8
|
-
<slot name="left"></slot>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<template v-else-if="customIcon">
|
|
12
|
-
<vd-icon :name="customIcon" :svg="iconSvg"></vd-icon>
|
|
13
|
-
</template>
|
|
14
|
-
</div>
|
|
15
|
-
<!-- 内容区 -->
|
|
16
|
-
<div :class="[`${prefixCls}-${mode}__content`, multiRows && `${prefixCls}-${mode}__multi`]" ref="wrap">
|
|
17
|
-
<!-- scrollable -->
|
|
18
|
-
<div v-if="scrollable" :style="contentStyle"
|
|
19
|
-
:class="[(overflow && scrollable) && `${prefixCls}-${mode}__content--animate`]" ref="content">
|
|
20
|
-
<div v-if="customTitle || title" :class="`${prefixCls}-${mode}__message`">
|
|
21
|
-
<div :class="[`${prefixCls}-${mode}__message--title`]">
|
|
22
|
-
<template v-if="customTitle">
|
|
23
|
-
<slot name="title"></slot>
|
|
24
|
-
</template>
|
|
25
|
-
<template v-else>{{ title }}</template>
|
|
26
|
-
</div>
|
|
27
|
-
<div v-if="tag" :class="[tag && `${prefixCls}-${mode}__message--tag`, state ? 'vd-noticebar-' + state : '']">
|
|
28
|
-
{{
|
|
29
|
-
tag
|
|
30
|
-
}}</div>
|
|
31
|
-
</div>
|
|
32
|
-
<slot></slot>
|
|
33
|
-
</div>
|
|
34
|
-
<template v-else>
|
|
35
|
-
<div v-if="customTitle || title" :class="`${prefixCls}-${mode}__message`">
|
|
36
|
-
<div :class="[`${prefixCls}-${mode}__message--title`]">
|
|
37
|
-
<template v-if="customTitle">
|
|
38
|
-
<slot name="title"></slot>
|
|
39
|
-
</template>
|
|
40
|
-
<template v-else>{{ title }}</template>
|
|
41
|
-
</div>
|
|
42
|
-
<div v-if="tag" :class="[tag && `${prefixCls}-${mode}__message--tag`, state ? 'vd-noticebar-' + state : '']">
|
|
43
|
-
<vd-icon
|
|
44
|
-
:name="state === 'success' ? 'icon_show_finished' : state === 'tips' ? 'icon_show_doing' : state === 'warning' ? 'icon_show_failed' : 'icon_show_cancel'"></vd-icon>
|
|
45
|
-
{{ tag }}
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
<slot></slot>
|
|
49
|
-
</template>
|
|
50
|
-
</div>
|
|
51
|
-
<!-- 右侧操作区 -->
|
|
52
|
-
<div :class="`${prefixCls}-${mode}__right`">
|
|
53
|
-
<template v-if="customRight">
|
|
54
|
-
<slot name="right"></slot>
|
|
55
|
-
</template>
|
|
56
|
-
<!-- 操作区 -->
|
|
57
|
-
<div v-if="action" :class="`${prefixCls}-${mode}__button`">
|
|
58
|
-
<vd-button type="primary_text">{{ action }}</vd-button>
|
|
59
|
-
</div>
|
|
60
|
-
<!-- 可关闭 -->
|
|
61
|
-
<vd-icon v-if="closable" name="icon_btn_close" @click.native.stop="$_close"></vd-icon>
|
|
62
|
-
<!-- 可链接 -->
|
|
63
|
-
<vd-icon v-if="islink" name="icon_btn_next"></vd-icon>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</template>
|
|
67
|
-
|
|
68
|
-
<script>
|
|
69
|
-
import VdIcon from '../icon';
|
|
70
|
-
import VdButton from '../button';
|
|
71
|
-
import { inBrowser } from '../utils/env'
|
|
72
|
-
export default {
|
|
73
|
-
components: {
|
|
74
|
-
VdIcon,
|
|
75
|
-
VdButton,
|
|
76
|
-
},
|
|
77
|
-
name: 'vd-noticebar',
|
|
78
|
-
props: {
|
|
79
|
-
prefixCls: {
|
|
80
|
-
type: String,
|
|
81
|
-
default: 'vd-noticebar'
|
|
82
|
-
},
|
|
83
|
-
mode: {
|
|
84
|
-
type: String,
|
|
85
|
-
default: 'snackbar', // snackbar toast notify
|
|
86
|
-
},
|
|
87
|
-
type: {
|
|
88
|
-
type: String,
|
|
89
|
-
default: 'info', // info/warning/tips
|
|
90
|
-
},
|
|
91
|
-
scrollable: {
|
|
92
|
-
type: Boolean,
|
|
93
|
-
default: false,
|
|
94
|
-
},
|
|
95
|
-
closable: {
|
|
96
|
-
type: Boolean,
|
|
97
|
-
default: false,
|
|
98
|
-
},
|
|
99
|
-
islink: {
|
|
100
|
-
type: Boolean,
|
|
101
|
-
default: false
|
|
102
|
-
},
|
|
103
|
-
// notify
|
|
104
|
-
title: {
|
|
105
|
-
type: String,
|
|
106
|
-
default: '',
|
|
107
|
-
},
|
|
108
|
-
action: {
|
|
109
|
-
type: String,
|
|
110
|
-
default: '',
|
|
111
|
-
},
|
|
112
|
-
tag: {
|
|
113
|
-
type: String,
|
|
114
|
-
default: '',
|
|
115
|
-
},
|
|
116
|
-
state: {
|
|
117
|
-
type: String,
|
|
118
|
-
default: 'tips'
|
|
119
|
-
},
|
|
120
|
-
// 画蛇添足部分
|
|
121
|
-
icon: {
|
|
122
|
-
type: String,
|
|
123
|
-
default: '',
|
|
124
|
-
},
|
|
125
|
-
iconSvg: {
|
|
126
|
-
type: Boolean,
|
|
127
|
-
default: false,
|
|
128
|
-
},
|
|
129
|
-
multiRows: {
|
|
130
|
-
type: Boolean,
|
|
131
|
-
default: false,
|
|
132
|
-
},
|
|
133
|
-
speed: {
|
|
134
|
-
type: Number,
|
|
135
|
-
default: 50
|
|
136
|
-
},
|
|
137
|
-
defaultWidth: {
|
|
138
|
-
type: Number,
|
|
139
|
-
default: 375
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
data() {
|
|
144
|
-
return {
|
|
145
|
-
isShow: true,
|
|
146
|
-
overflow: false,
|
|
147
|
-
contentStyle: {
|
|
148
|
-
transitionDuration: '0s',
|
|
149
|
-
transform: 'translateX(0px)'
|
|
150
|
-
},
|
|
151
|
-
wrapWidth: 0,
|
|
152
|
-
contentWidth: 0,
|
|
153
|
-
time: 0,
|
|
154
|
-
timer: null,
|
|
155
|
-
convertSpeed: 1
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
computed: {
|
|
160
|
-
customIcon() {
|
|
161
|
-
let result
|
|
162
|
-
if (this.mode === 'toast') {
|
|
163
|
-
result = this.type === 'warning' ? 'icon_btn_clean' : 'icon_show_finished'
|
|
164
|
-
} else {
|
|
165
|
-
result = this.icon
|
|
166
|
-
}
|
|
167
|
-
return result
|
|
168
|
-
},
|
|
169
|
-
customLeft() {
|
|
170
|
-
return !!this.$slots.left
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
customRight() {
|
|
174
|
-
return !!this.$slots.right
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
customTitle() {
|
|
178
|
-
return !!this.$slots.title
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
updated() {
|
|
183
|
-
if (inBrowser) {
|
|
184
|
-
this.$_checkOverflow();
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
mounted() {
|
|
189
|
-
if (inBrowser) {
|
|
190
|
-
this.$_checkOverflow();
|
|
191
|
-
this.init();
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
methods: {
|
|
196
|
-
$_close() {
|
|
197
|
-
if (this.closable) {
|
|
198
|
-
this.isShow = false
|
|
199
|
-
}
|
|
200
|
-
this.$emit('close')
|
|
201
|
-
},
|
|
202
|
-
$_checkOverflow() {
|
|
203
|
-
if (!this.scrollable) {
|
|
204
|
-
return
|
|
205
|
-
}
|
|
206
|
-
const { wrap, content } = this.$refs
|
|
207
|
-
|
|
208
|
-
/* istanbul ignore if */
|
|
209
|
-
if (!wrap || !content) {
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const paddingLeft =
|
|
214
|
-
window
|
|
215
|
-
.getComputedStyle(content, null)
|
|
216
|
-
.getPropertyValue('padding')
|
|
217
|
-
.split(' ')[3] || '0px'
|
|
218
|
-
const left = +paddingLeft.match(/\d+/g)[0]
|
|
219
|
-
this.overflow = content.scrollWidth - left > Math.ceil(wrap.getBoundingClientRect().width)
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
init() {
|
|
223
|
-
if (!inBrowser) return; // 确保只在浏览器环境执行
|
|
224
|
-
const { wrap, content } = this.$refs
|
|
225
|
-
if (wrap && content) {
|
|
226
|
-
// const _width = window.innerWidth
|
|
227
|
-
// this.convertSpeed = _width / this.defaultWidth * this.speed // 根据分辨率转化成不同的速度
|
|
228
|
-
this.convertSpeed = 375 / this.defaultWidth * this.speed //_width / this.defaultWidth * this.speed // 根据分辨率转化成不同的速度
|
|
229
|
-
this.wrapWidth = wrap.offsetWidth
|
|
230
|
-
this.contentWidth = content.scrollWidth
|
|
231
|
-
console.log(content.scrollWidth);
|
|
232
|
-
this.startAnimate()
|
|
233
|
-
this.timer = setInterval(() => {
|
|
234
|
-
this.startAnimate()
|
|
235
|
-
}, this.time * 1000)
|
|
236
|
-
this.$once('hook:beforeDestroy', () => {
|
|
237
|
-
clearInterval(this.timer)
|
|
238
|
-
this.timer = null
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
startAnimate() {
|
|
243
|
-
this.contentStyle.transitionDuration = '0s'
|
|
244
|
-
this.contentStyle.transform = 'translateX(' + this.wrapWidth + 'px)'
|
|
245
|
-
this.time = (this.wrapWidth + this.contentWidth) / this.convertSpeed
|
|
246
|
-
setTimeout(() => {
|
|
247
|
-
this.contentStyle.transitionDuration = this.time + 's'
|
|
248
|
-
this.contentStyle.transform = 'translateX(-' + this.contentWidth + 'px)'
|
|
249
|
-
}, 200)
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
</script>
|
|
255
|
-
|
|
256
|
-
<style lang="less">
|
|
257
|
-
@import './style.less';
|
|
258
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[mode ? `${prefixCls}-${mode}` : '', type ? 'vd-noticebar-' + type : '', { 'vd-noticebar-action': action }]"
|
|
4
|
+
v-if="isShow">
|
|
5
|
+
<!-- 左侧图标 -->
|
|
6
|
+
<div v-if="customLeft || customIcon" :class="`${prefixCls}-${mode}__left`">
|
|
7
|
+
<template v-if="customLeft">
|
|
8
|
+
<slot name="left"></slot>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<template v-else-if="customIcon">
|
|
12
|
+
<vd-icon :name="customIcon" :svg="iconSvg"></vd-icon>
|
|
13
|
+
</template>
|
|
14
|
+
</div>
|
|
15
|
+
<!-- 内容区 -->
|
|
16
|
+
<div :class="[`${prefixCls}-${mode}__content`, multiRows && `${prefixCls}-${mode}__multi`]" ref="wrap">
|
|
17
|
+
<!-- scrollable -->
|
|
18
|
+
<div v-if="scrollable" :style="contentStyle"
|
|
19
|
+
:class="[(overflow && scrollable) && `${prefixCls}-${mode}__content--animate`]" ref="content">
|
|
20
|
+
<div v-if="customTitle || title" :class="`${prefixCls}-${mode}__message`">
|
|
21
|
+
<div :class="[`${prefixCls}-${mode}__message--title`]">
|
|
22
|
+
<template v-if="customTitle">
|
|
23
|
+
<slot name="title"></slot>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-else>{{ title }}</template>
|
|
26
|
+
</div>
|
|
27
|
+
<div v-if="tag" :class="[tag && `${prefixCls}-${mode}__message--tag`, state ? 'vd-noticebar-' + state : '']">
|
|
28
|
+
{{
|
|
29
|
+
tag
|
|
30
|
+
}}</div>
|
|
31
|
+
</div>
|
|
32
|
+
<slot></slot>
|
|
33
|
+
</div>
|
|
34
|
+
<template v-else>
|
|
35
|
+
<div v-if="customTitle || title" :class="`${prefixCls}-${mode}__message`">
|
|
36
|
+
<div :class="[`${prefixCls}-${mode}__message--title`]">
|
|
37
|
+
<template v-if="customTitle">
|
|
38
|
+
<slot name="title"></slot>
|
|
39
|
+
</template>
|
|
40
|
+
<template v-else>{{ title }}</template>
|
|
41
|
+
</div>
|
|
42
|
+
<div v-if="tag" :class="[tag && `${prefixCls}-${mode}__message--tag`, state ? 'vd-noticebar-' + state : '']">
|
|
43
|
+
<vd-icon
|
|
44
|
+
:name="state === 'success' ? 'icon_show_finished' : state === 'tips' ? 'icon_show_doing' : state === 'warning' ? 'icon_show_failed' : 'icon_show_cancel'"></vd-icon>
|
|
45
|
+
{{ tag }}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<slot></slot>
|
|
49
|
+
</template>
|
|
50
|
+
</div>
|
|
51
|
+
<!-- 右侧操作区 -->
|
|
52
|
+
<div :class="`${prefixCls}-${mode}__right`">
|
|
53
|
+
<template v-if="customRight">
|
|
54
|
+
<slot name="right"></slot>
|
|
55
|
+
</template>
|
|
56
|
+
<!-- 操作区 -->
|
|
57
|
+
<div v-if="action" :class="`${prefixCls}-${mode}__button`">
|
|
58
|
+
<vd-button type="primary_text">{{ action }}</vd-button>
|
|
59
|
+
</div>
|
|
60
|
+
<!-- 可关闭 -->
|
|
61
|
+
<vd-icon v-if="closable" name="icon_btn_close" @click.native.stop="$_close"></vd-icon>
|
|
62
|
+
<!-- 可链接 -->
|
|
63
|
+
<vd-icon v-if="islink" name="icon_btn_next"></vd-icon>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
import VdIcon from '../icon';
|
|
70
|
+
import VdButton from '../button';
|
|
71
|
+
import { inBrowser } from '../utils/env'
|
|
72
|
+
export default {
|
|
73
|
+
components: {
|
|
74
|
+
VdIcon,
|
|
75
|
+
VdButton,
|
|
76
|
+
},
|
|
77
|
+
name: 'vd-noticebar',
|
|
78
|
+
props: {
|
|
79
|
+
prefixCls: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: 'vd-noticebar'
|
|
82
|
+
},
|
|
83
|
+
mode: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: 'snackbar', // snackbar toast notify
|
|
86
|
+
},
|
|
87
|
+
type: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: 'info', // info/warning/tips
|
|
90
|
+
},
|
|
91
|
+
scrollable: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
closable: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false,
|
|
98
|
+
},
|
|
99
|
+
islink: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false
|
|
102
|
+
},
|
|
103
|
+
// notify
|
|
104
|
+
title: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: '',
|
|
107
|
+
},
|
|
108
|
+
action: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: '',
|
|
111
|
+
},
|
|
112
|
+
tag: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: '',
|
|
115
|
+
},
|
|
116
|
+
state: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: 'tips'
|
|
119
|
+
},
|
|
120
|
+
// 画蛇添足部分
|
|
121
|
+
icon: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: '',
|
|
124
|
+
},
|
|
125
|
+
iconSvg: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: false,
|
|
128
|
+
},
|
|
129
|
+
multiRows: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false,
|
|
132
|
+
},
|
|
133
|
+
speed: {
|
|
134
|
+
type: Number,
|
|
135
|
+
default: 50
|
|
136
|
+
},
|
|
137
|
+
defaultWidth: {
|
|
138
|
+
type: Number,
|
|
139
|
+
default: 375
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
data() {
|
|
144
|
+
return {
|
|
145
|
+
isShow: true,
|
|
146
|
+
overflow: false,
|
|
147
|
+
contentStyle: {
|
|
148
|
+
transitionDuration: '0s',
|
|
149
|
+
transform: 'translateX(0px)'
|
|
150
|
+
},
|
|
151
|
+
wrapWidth: 0,
|
|
152
|
+
contentWidth: 0,
|
|
153
|
+
time: 0,
|
|
154
|
+
timer: null,
|
|
155
|
+
convertSpeed: 1
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
computed: {
|
|
160
|
+
customIcon() {
|
|
161
|
+
let result
|
|
162
|
+
if (this.mode === 'toast') {
|
|
163
|
+
result = this.type === 'warning' ? 'icon_btn_clean' : 'icon_show_finished'
|
|
164
|
+
} else {
|
|
165
|
+
result = this.icon
|
|
166
|
+
}
|
|
167
|
+
return result
|
|
168
|
+
},
|
|
169
|
+
customLeft() {
|
|
170
|
+
return !!this.$slots.left
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
customRight() {
|
|
174
|
+
return !!this.$slots.right
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
customTitle() {
|
|
178
|
+
return !!this.$slots.title
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
updated() {
|
|
183
|
+
if (inBrowser) {
|
|
184
|
+
this.$_checkOverflow();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
mounted() {
|
|
189
|
+
if (inBrowser) {
|
|
190
|
+
this.$_checkOverflow();
|
|
191
|
+
this.init();
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
methods: {
|
|
196
|
+
$_close() {
|
|
197
|
+
if (this.closable) {
|
|
198
|
+
this.isShow = false
|
|
199
|
+
}
|
|
200
|
+
this.$emit('close')
|
|
201
|
+
},
|
|
202
|
+
$_checkOverflow() {
|
|
203
|
+
if (!this.scrollable) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
const { wrap, content } = this.$refs
|
|
207
|
+
|
|
208
|
+
/* istanbul ignore if */
|
|
209
|
+
if (!wrap || !content) {
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const paddingLeft =
|
|
214
|
+
window
|
|
215
|
+
.getComputedStyle(content, null)
|
|
216
|
+
.getPropertyValue('padding')
|
|
217
|
+
.split(' ')[3] || '0px'
|
|
218
|
+
const left = +paddingLeft.match(/\d+/g)[0]
|
|
219
|
+
this.overflow = content.scrollWidth - left > Math.ceil(wrap.getBoundingClientRect().width)
|
|
220
|
+
|
|
221
|
+
},
|
|
222
|
+
init() {
|
|
223
|
+
if (!inBrowser) return; // 确保只在浏览器环境执行
|
|
224
|
+
const { wrap, content } = this.$refs
|
|
225
|
+
if (wrap && content) {
|
|
226
|
+
// const _width = window.innerWidth
|
|
227
|
+
// this.convertSpeed = _width / this.defaultWidth * this.speed // 根据分辨率转化成不同的速度
|
|
228
|
+
this.convertSpeed = 375 / this.defaultWidth * this.speed //_width / this.defaultWidth * this.speed // 根据分辨率转化成不同的速度
|
|
229
|
+
this.wrapWidth = wrap.offsetWidth
|
|
230
|
+
this.contentWidth = content.scrollWidth
|
|
231
|
+
console.log(content.scrollWidth);
|
|
232
|
+
this.startAnimate()
|
|
233
|
+
this.timer = setInterval(() => {
|
|
234
|
+
this.startAnimate()
|
|
235
|
+
}, this.time * 1000)
|
|
236
|
+
this.$once('hook:beforeDestroy', () => {
|
|
237
|
+
clearInterval(this.timer)
|
|
238
|
+
this.timer = null
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
startAnimate() {
|
|
243
|
+
this.contentStyle.transitionDuration = '0s'
|
|
244
|
+
this.contentStyle.transform = 'translateX(' + this.wrapWidth + 'px)'
|
|
245
|
+
this.time = (this.wrapWidth + this.contentWidth) / this.convertSpeed
|
|
246
|
+
setTimeout(() => {
|
|
247
|
+
this.contentStyle.transitionDuration = this.time + 's'
|
|
248
|
+
this.contentStyle.transform = 'translateX(-' + this.contentWidth + 'px)'
|
|
249
|
+
}, 200)
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<style lang="less">
|
|
257
|
+
@import './style.less';
|
|
258
|
+
</style>
|