提交 d890222d authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 时间组件增加时间格式'无'

上级 db242ba7
...@@ -97,7 +97,8 @@ export default { ...@@ -97,7 +97,8 @@ export default {
timeOptions: [ timeOptions: [
{ value: 'hh:mm:ss', label: 'hh:mm:ss' }, { value: 'hh:mm:ss', label: 'hh:mm:ss' },
{ value: 'hh时mm分ss秒', label: 'hh时mm分ss秒' } { value: 'hh时mm分ss秒', label: 'hh时mm分ss秒' },
{ value: '', label: '无' }
], ],
dateOptions: [ dateOptions: [
{ value: 'yyyy-MM-dd', label: 'yyyy-MM-dd' }, { value: 'yyyy-MM-dd', label: 'yyyy-MM-dd' },
......
<template> <template>
<div style="height: 100%"> <div style="height: 100%">
<time-default v-if="element.formatInfo.openMode === '0'" :ref="element.id" :element="element" /> <time-default v-if="element.formatInfo.openMode === '0'" :ref="element.id" :element="element" />
<time-elec v-if="element.formatInfo.openMode === '1'" :ref="element.id" :element="element" /> <time-elec v-if="element.formatInfo.openMode === '1'" :ref="element.id" :element="element" />
<time-simple v-if="element.formatInfo.openMode === '2'" :ref="element.id" :element="element" /> <time-simple v-if="element.formatInfo.openMode === '2'" :ref="element.id" :element="element" />
<time-complex v-if="element.formatInfo.openMode === '3'" :ref="element.id" :element="element" /> <time-complex v-if="element.formatInfo.openMode === '3'" :ref="element.id" :element="element" />
</div> </div>
</template> </template>
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
}, },
formatDate() { formatDate() {
const weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'] const weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss' let timeFormat = this.element.formatInfo.timeFormat
const showWeek = this.element.formatInfo.showWeek const showWeek = this.element.formatInfo.showWeek
const showDate = this.element.formatInfo.showDate const showDate = this.element.formatInfo.showDate
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd' const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
......
<template> <template>
<div id="clock" :style="{'--varBg': varBg}"> <div id="clock" :style="{'--varBg': varBg}">
<p class="date">{{ date }}</p> <p class="date">{{ date }}</p>
<p class="time" :style="{'fontSize': (parseInt(element.style.fontSize) * 3) + 'px'}">{{ time }}</p> <p v-if="time" class="time" :style="{'fontSize': (parseInt(element.style.fontSize) * 3) + 'px'}">{{ time }}</p>
</div> </div>
</template> </template>
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
}, },
updateTime() { updateTime() {
var cd = new Date() var cd = new Date()
const timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss' const timeFormat = this.element.formatInfo.timeFormat
const showWeek = this.element.formatInfo.showWeek const showWeek = this.element.formatInfo.showWeek
const showDate = this.element.formatInfo.showDate const showDate = this.element.formatInfo.showDate
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd' const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
...@@ -75,8 +75,12 @@ export default { ...@@ -75,8 +75,12 @@ export default {
nowDate = cd.format(dateFormat) nowDate = cd.format(dateFormat)
} }
const nowWeek = this.week[cd.getDay()] const nowWeek = this.week[cd.getDay()]
if (timeFormat) {
this.time = cd.format(timeFormat)
} else {
this.time = null
}
this.time = cd.format(timeFormat)
this.date = showWeek ? (nowDate + ' ' + nowWeek) : nowDate this.date = showWeek ? (nowDate + ' ' + nowWeek) : nowDate
} }
} }
......
...@@ -65,7 +65,7 @@ export default { ...@@ -65,7 +65,7 @@ export default {
this.timer = setInterval(this.canvass, 500) this.timer = setInterval(this.canvass, 500)
}, },
canvass() { canvass() {
const timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss' const timeFormat = this.element.formatInfo.timeFormat
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd' const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
const showWeek = this.element.formatInfo.showWeek const showWeek = this.element.formatInfo.showWeek
const showDate = this.element.formatInfo.showDate const showDate = this.element.formatInfo.showDate
...@@ -110,8 +110,10 @@ export default { ...@@ -110,8 +110,10 @@ export default {
} else { } else {
englishWeek = 'Saturday' englishWeek = 'Saturday'
} }
let simpleTime = ''
const simpleTime = time.format(timeFormat) if (timeFormat) {
simpleTime = time.format(timeFormat)
}
let nowDate = '' let nowDate = ''
if (showDate && dateFormat) { if (showDate && dateFormat) {
nowDate = time.format(dateFormat) nowDate = time.format(dateFormat)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论