2018-02-15 05:36:42 +02:00
|
|
|
<template>
|
|
|
|
<div class="mkw-tips">
|
2018-11-05 18:40:11 +02:00
|
|
|
<p ref="tip"><fa :icon="['far', 'lightbulb']"/><span v-html="tip"></span></p>
|
2018-02-15 05:36:42 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import * as anime from 'animejs';
|
2018-02-24 17:18:09 +02:00
|
|
|
import define from '../../../common/define-widget';
|
2018-11-08 20:44:35 +02:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-15 05:36:42 +02:00
|
|
|
|
|
|
|
export default define({
|
|
|
|
name: 'tips'
|
|
|
|
}).extend({
|
2018-11-08 20:44:35 +02:00
|
|
|
i18n: i18n('common/views/widgets/tips.vue'),
|
|
|
|
|
2018-02-15 05:36:42 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-09 07:13:40 +02:00
|
|
|
tips: [],
|
2018-02-15 05:36:42 +02:00
|
|
|
tip: null,
|
|
|
|
clock: null
|
|
|
|
};
|
|
|
|
},
|
2018-11-09 07:13:40 +02:00
|
|
|
created() {
|
|
|
|
this.tips = [
|
|
|
|
this.$t('tips-line1'),
|
|
|
|
this.$t('tips-line2'),
|
|
|
|
this.$t('tips-line3'),
|
|
|
|
this.$t('tips-line4'),
|
|
|
|
this.$t('tips-line5'),
|
|
|
|
this.$t('tips-line6'),
|
|
|
|
this.$t('tips-line7'),
|
|
|
|
this.$t('tips-line8'),
|
|
|
|
this.$t('tips-line9'),
|
|
|
|
this.$t('tips-line10'),
|
|
|
|
this.$t('tips-line11'),
|
|
|
|
this.$t('tips-line13'),
|
|
|
|
this.$t('tips-line14'),
|
|
|
|
this.$t('tips-line17'),
|
|
|
|
this.$t('tips-line19'),
|
|
|
|
this.$t('tips-line20'),
|
|
|
|
this.$t('tips-line21'),
|
|
|
|
this.$t('tips-line23'),
|
|
|
|
this.$t('tips-line24'),
|
|
|
|
this.$t('tips-line25')
|
|
|
|
];
|
|
|
|
},
|
2018-02-15 05:36:42 +02:00
|
|
|
mounted() {
|
2018-02-18 11:40:24 +02:00
|
|
|
this.$nextTick(() => {
|
2018-02-15 05:36:42 +02:00
|
|
|
this.set();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.clock = setInterval(this.change, 20000);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
clearInterval(this.clock);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
set() {
|
2018-11-09 07:13:40 +02:00
|
|
|
this.tip = this.tips[Math.floor(Math.random() * this.tips.length)];
|
2018-02-15 05:36:42 +02:00
|
|
|
},
|
|
|
|
change() {
|
|
|
|
anime({
|
|
|
|
targets: this.$refs.tip,
|
|
|
|
opacity: 0,
|
|
|
|
duration: 500,
|
|
|
|
easing: 'linear',
|
|
|
|
complete: this.set
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
anime({
|
|
|
|
targets: this.$refs.tip,
|
|
|
|
opacity: 1,
|
|
|
|
duration: 500,
|
|
|
|
easing: 'linear'
|
|
|
|
});
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.mkw-tips
|
|
|
|
overflow visible !important
|
|
|
|
|
|
|
|
> p
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0 12px
|
|
|
|
text-align center
|
|
|
|
font-size 0.7em
|
|
|
|
color #999
|
|
|
|
|
2018-11-05 18:40:11 +02:00
|
|
|
> [data-icon]
|
2018-02-15 05:36:42 +02:00
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
kbd
|
|
|
|
display inline
|
|
|
|
padding 0 6px
|
|
|
|
margin 0 2px
|
|
|
|
font-size 1em
|
|
|
|
font-family inherit
|
|
|
|
border solid 1px #999
|
|
|
|
border-radius 2px
|
|
|
|
|
|
|
|
</style>
|