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

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

上级 db242ba7
......@@ -97,7 +97,8 @@ export default {
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: '', label: '无' }
],
dateOptions: [
{ value: 'yyyy-MM-dd', label: 'yyyy-MM-dd' },
......
<template>
<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>
</template>
......
......@@ -44,7 +44,7 @@ export default {
},
formatDate() {
const weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss'
let timeFormat = this.element.formatInfo.timeFormat
const showWeek = this.element.formatInfo.showWeek
const showDate = this.element.formatInfo.showDate
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
......
<template>
<div id="clock" :style="{'--varBg': varBg}">
<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>
</template>
......@@ -66,7 +66,7 @@ export default {
},
updateTime() {
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 showDate = this.element.formatInfo.showDate
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
......@@ -75,8 +75,12 @@ export default {
nowDate = cd.format(dateFormat)
}
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
}
}
......
......@@ -65,7 +65,7 @@ export default {
this.timer = setInterval(this.canvass, 500)
},
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 showWeek = this.element.formatInfo.showWeek
const showDate = this.element.formatInfo.showDate
......@@ -110,8 +110,10 @@ export default {
} else {
englishWeek = 'Saturday'
}
const simpleTime = time.format(timeFormat)
let simpleTime = ''
if (timeFormat) {
simpleTime = time.format(timeFormat)
}
let nowDate = ''
if (showDate && dateFormat) {
nowDate = time.format(dateFormat)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论