Skip to content

Commit 350573d

Browse files
committed
feat: add toast type
1 parent 827fc3b commit 350573d

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/components/panel/animation.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ export default {
142142
// 检查是否存在未命名动画,避免重复添加
143143
if (this.$store.state.animation.some(val => val.name === '')) {
144144
window.$communicator.$emit('notify', {
145-
info: '还有未命名动画,请先命名',
146-
type: false
145+
info: '还有未命名动画,请先命名'
147146
})
148147
return
149148
}
@@ -176,8 +175,7 @@ export default {
176175
this.currentAnimation.name = ''
177176
})
178177
window.$communicator.$emit('notify', {
179-
info: '动画名称必须以英文开头',
180-
type: false
178+
info: '动画名称必须以英文开头'
181179
})
182180
}
183181
@@ -186,8 +184,7 @@ export default {
186184
this.currentAnimation.name = value.replace(/\W/g, '')
187185
})
188186
window.$communicator.$emit('notify', {
189-
info: '请勿使用英文和数字以外的字符',
190-
type: false
187+
info: '请勿使用英文和数字以外的字符'
191188
})
192189
}
193190
},

src/components/slider.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- based on muse-ui -->
22
<!-- http://www.muse-ui.org/#/slider -->
3-
<!-- TODO: use input range -->
3+
<!-- TODO: use input range instead -->
44
<template>
55
<div :class="{'mu-lisder-wrapper': tuning}">
66
<div class="mu-slider" :class="sliderClass"

src/components/toast.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<transition name="drop">
3-
<div class="toast" v-show="show">{{ info }}</div>
3+
<div class="toast" :class="klass" v-show="show">{{ info }}</div>
44
</transition>
55
</template>
66

@@ -9,10 +9,19 @@ export default {
99
data () {
1010
return {
1111
info: '',
12-
type: true,
12+
type: 'warning',
1313
show: false
1414
}
1515
},
16+
computed: {
17+
klass () {
18+
return {
19+
'toast-success': this.type === 'success',
20+
'toast-warning': this.type === 'warning',
21+
'toast-error': this.type === 'error'
22+
}
23+
}
24+
},
1625
mounted () {
1726
window.$communicator.$on('notify', (option) => {
1827
this.notify(option.info, option.type)
@@ -22,8 +31,7 @@ export default {
2231
notify (info, type) {
2332
if (this.show) return
2433
this.info = info || 'Success!'
25-
// FIXME: type = "success" or "warning"
26-
this.type = type || true
34+
if (type) this.type = type
2735
this.show = true
2836
setTimeout(() => {
2937
this.show = false

src/store/mutation.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ export default {
103103
state.counter += 1
104104
} else {
105105
window.$communicator.$emit('notify', {
106-
info: '只有命名容器才能复制,请先命名',
107-
type: false
106+
info: '只有命名容器才能复制,请先命名'
108107
})
109108
}
110109
}

0 commit comments

Comments
 (0)