增加日期相关的 filter 和更新一些菜单的显示

Former-commit-id: bacfe4e86ce0599752cc74916bb9547add6b0725 [formerly bacfe4e86ce0599752cc74916bb9547add6b0725 [formerly bacfe4e86ce0599752cc74916bb9547add6b0725 [formerly bacfe4e86ce0599752cc74916bb9547add6b0725 [formerly f5ed703f2aefb46bd7a6dd7dbb6d141cd43dec08 [formerly b679a8fecf5a7d908d20d57b1098d9c4708574c3]]]]]
Former-commit-id: 36c9337dc53258282bc83ed7b52a88c617a75a66
Former-commit-id: b418eed9356e5de890b70a8ccaa93ee1abbd30bf
Former-commit-id: e06310cdc83cd1c614e523f33558d2cb303ca81f [formerly 20341d1ed3372bfe16f777a177710894ca29f378]
Former-commit-id: 1795ddf1c595363c49c3d6530e2a552aa7906edd
Former-commit-id: 38c0384164faa36103bc9ee5d881cdacf367bbb4
Former-commit-id: 0a13e600fb5a8add5a282304dc2f26d35e711572
Former-commit-id: 5845a0b7620bd23f145b02cbe0427eb351792e6a
Former-commit-id: a8aeed67fd895c549600e636cf16094197c1891a
This commit is contained in:
liyang
2018-12-16 12:25:41 +08:00
parent 5e16818f73
commit e20159debc
18 changed files with 385 additions and 8 deletions

View File

@@ -0,0 +1,77 @@
<template>
<div class="d2-mb-10">
<el-button-group>
<el-button
v-for="(label, index) in labelList"
:key="index"
:class="buttonClass(index)"
size="mini"
type="primary"
@click="handleClip(label)">
{{label}}
</el-button>
</el-button-group>
<d2-icon name="arrow-right" class="code-and-result--arrow-right"/>
{{value}}
</div>
</template>
<script>
import clipboard from 'clipboard-polyfill'
export default {
props: {
label: {
default: ''
},
value: {
default: ''
}
},
computed: {
labelList () {
return this.label.split('|')
}
},
methods: {
buttonClass (index) {
if (index === 0) {
return 'code-and-result--button__first'
} else if (index === this.labelList.length - 1) {
return 'code-and-result--button__last'
} else {
return 'code-and-result--button'
}
},
handleClip (value) {
clipboard.writeText(value)
this.$notify({
title: '成功',
message: `${value} 已经复制到剪贴板`,
type: 'success'
})
}
}
}
</script>
<style lang="scss" scoped>
.code-and-result--button {
padding-left: 5px;
padding-right: 5px;
}
.code-and-result--button__first {
padding-right: 5px;
padding-left: 10px;
}
.code-and-result--button__last {
padding-left: 5px;
padding-right: 10px;
}
.code-and-result--arrow-right {
color: $color-info;
margin: 0px 20px;
}
.code-and-result--value {
line-height: 32px;
}
</style>

View File

@@ -0,0 +1,41 @@
<template>
<div>
<h1 class="code-title">{{title}}</h1>
<h2 class="code-title--sub">{{subTitle}}</h2>
</div>
</template>
<script>
export default {
props: {
title: {
type: String,
default: ''
},
subTitle: {
type: String,
default: ''
}
}
}
</script>
<style lang="scss" scoped>
.code-title {
margin: 0px;
font-size: 24px;
font-weight: bold;
color: $color-text-main;
margin: 10px 0;
&:first-child {
margin-top: 0px;
}
}
.code-title--sub {
margin: 0px;
font-size: 12px;
font-weight: normal;
color: $color-text-sub;
margin: 10px 0;
}
</style>

View File

@@ -0,0 +1,95 @@
<template>
<d2-container>
<div slot="header" flex="main:justify">
<el-date-picker size="small" type="datetime" v-model="value" placeholder="选择一个日期"/>
<el-button size="small" type="primary">value = {{value}}</el-button>
</div>
<code-title title="获取" sub-title="获取日期的指定部分"/>
<code-and-result label="value|day_year" :value="value|day_year"/>
<code-and-result label="value|day_month" :value="value|day_month"/>
<code-and-result label="value|day_date" :value="value|day_date"/>
<code-and-result label="value|day_day" :value="value|day_day"/>
<code-and-result label="value|day_hour" :value="value|day_hour"/>
<code-and-result label="value|day_minute" :value="value|day_minute"/>
<code-and-result label="value|day_second" :value="value|day_second"/>
<code-and-result label="value|day_millisecond" :value="value|day_millisecond"/>
<code-title title="设置" sub-title="设置日期指定部分的值"/>
<code-and-result label="value|day_set('year', 2020)|day_format('< YYYY > - MM - DD')" :value="value|day_set('year', 2020)|day_format('< YYYY > - MM - DD')"/>
<code-and-result label="value|day_set('month', 0)|day_format('YYYY - < MM > - DD')" :value="value|day_set('month', 0)|day_format('YYYY - < MM > - DD')"/>
<code-and-result label="value|day_set('date', 1)|day_format('YYYY - MM - < DD >')" :value="value|day_set('date', 1)|day_format('YYYY - MM - < DD >')"/>
<code-and-result label="value|day_set('hour', 0)|day_format('< HH > : mm : ss')" :value="value|day_set('hour', 0)|day_format('< HH > : mm : ss')"/>
<code-and-result label="value|day_set('minute', 0)|day_format('HH : < mm > : ss')" :value="value|day_set('minute', 0)|day_format('HH : < mm > : ss')"/>
<code-and-result label="value|day_set('second', 0)|day_format('HH : mm : < ss >')" :value="value|day_set('second', 0)|day_format('HH : mm : < ss >')"/>
<code-title title="增加" sub-title="增加时间并返回一个新的 Dayjs 对象"/>
<code-and-result label="value|day_add(1, 'year')|day_format('< YYYY > - MM - DD')" :value="value|day_add(1, 'year')|day_format('< YYYY > - MM - DD')"/>
<code-and-result label="value|day_add(1, 'month')|day_format('YYYY - < MM > - DD')" :value="value|day_add(1, 'month')|day_format('YYYY - < MM > - DD')"/>
<code-and-result label="value|day_add(1, 'day')|day_format('YYYY - MM - < DD >')" :value="value|day_add(1, 'day')|day_format('YYYY - MM - < DD >')"/>
<code-and-result label="value|day_add(1, 'hour')|day_format('< HH > : mm : ss')" :value="value|day_add(1, 'hour')|day_format('< HH > : mm : ss')"/>
<code-and-result label="value|day_add(1, 'minute')|day_format('HH : < mm > : ss')" :value="value|day_add(1, 'minute')|day_format('HH : < mm > : ss')"/>
<code-and-result label="value|day_add(1, 'second')|day_format('HH : mm : < ss >')" :value="value|day_add(1, 'second')|day_format('HH : mm : < ss >')"/>
<code-title title="减少" sub-title="减少时间并返回一个新的 Dayjs 对象"/>
<code-and-result label="value|day_subtract(1, 'year')|day_format('< YYYY > - MM - DD')" :value="value|day_subtract(1, 'year')|day_format('< YYYY > - MM - DD')"/>
<code-and-result label="value|day_subtract(1, 'month')|day_format('YYYY - < MM > - DD')" :value="value|day_subtract(1, 'month')|day_format('YYYY - < MM > - DD')"/>
<code-and-result label="value|day_subtract(1, 'day')|day_format('YYYY - MM - < DD >')" :value="value|day_subtract(1, 'day')|day_format('YYYY - MM - < DD >')"/>
<code-and-result label="value|day_subtract(1, 'hour')|day_format('< HH > : mm : ss')" :value="value|day_subtract(1, 'hour')|day_format('< HH > : mm : ss')"/>
<code-and-result label="value|day_subtract(1, 'minute')|day_format('HH : < mm > : ss')" :value="value|day_subtract(1, 'minute')|day_format('HH : < mm > : ss')"/>
<code-and-result label="value|day_subtract(1, 'second')|day_format('HH : mm : < ss >')" :value="value|day_subtract(1, 'second')|day_format('HH : mm : < ss >')"/>
<code-title title="开头时间" sub-title="返回当前时间的开头时间的 Dayjs 对象如月份的第一天"/>
<code-and-result label="value|day_startof('year')|day_format" :value="value|day_startof('year')|day_format"/>
<code-and-result label="value|day_startof('month')|day_format" :value="value|day_startof('month')|day_format"/>
<code-and-result label="value|day_startof('date')|day_format" :value="value|day_startof('date')|day_format"/>
<code-and-result label="value|day_startof('hour')|day_format" :value="value|day_startof('hour')|day_format"/>
<code-and-result label="value|day_startof('minute')|day_format" :value="value|day_startof('minute')|day_format"/>
<code-title title="末尾时间" sub-title="返回当前时间的末尾时间的 Dayjs 对象如月份的最后一天"/>
<code-and-result label="value|day_endof('year')|day_format" :value="value|day_endof('year')|day_format"/>
<code-and-result label="value|day_endof('month')|day_format" :value="value|day_endof('month')|day_format"/>
<code-and-result label="value|day_endof('date')|day_format" :value="value|day_endof('date')|day_format"/>
<code-and-result label="value|day_endof('hour')|day_format" :value="value|day_endof('hour')|day_format"/>
<code-and-result label="value|day_endof('minute')|day_format" :value="value|day_endof('minute')|day_format"/>
<code-title title="显示" sub-title="格式化 Dayjs 对象并展示"/>
<code-and-result label="value|day_format" :value="value|day_format"/>
<code-and-result label="value|day_format('YY-MM-DD')" :value="value|day_format('YY-MM-DD')"/>
<code-and-result label="value|day_format('YYYY-M-D')" :value="value|day_format('YYYY-M-D')"/>
<code-and-result label="value|day_format('YYYY-M-D H:m:s')" :value="value|day_format('YYYY-M-D H:m:s')"/>
<code-title title="时间差" sub-title="获取两个 Dayjs 对象的时间差默认毫秒"/>
<code-and-result label="value|day_diff('2012-10-31', 'year')" :value="value|day_diff('2012-10-31', 'year')"/>
<code-and-result label="value|day_diff('2012-10-31', 'month')" :value="value|day_diff('2012-10-31', 'month')"/>
<code-and-result label="value|day_diff('2012-10-31', 'day')" :value="value|day_diff('2012-10-31', 'day')"/>
<code-and-result label="value|day_diff('2012-10-31', 'hour')" :value="value|day_diff('2012-10-31', 'hour')"/>
<code-and-result label="value|day_diff('2012-10-31', 'minute')" :value="value|day_diff('2012-10-31', 'minute')"/>
<code-and-result label="value|day_diff('2012-10-31', 'second')" :value="value|day_diff('2012-10-31', 'second')"/>
<code-title title="Unix 时间戳" sub-title="返回毫秒和秒"/>
<code-and-result label="value|day_value_millisecond" :value="value|day_value_millisecond"/>
<code-and-result label="value|day_value_second" :value="value|day_value_second"/>
<code-title title="月份天数" sub-title="返回传入日期月份的天数"/>
<code-and-result label="value|day_days_in_month" :value="value|day_days_in_month"/>
<code-title title="处理为其它格式" sub-title="原生的 Date 对象数组jsonios 标准对象字符串"/>
<code-and-result label="value|day_to_date" :value="value|day_to_date"/>
<code-and-result label="value|day_to_array" :value="value|day_to_array"/>
<code-and-result label="value|day_to_json" :value="value|day_to_json"/>
<code-and-result label="value|day_to_iso" :value="value|day_to_iso"/>
<code-and-result label="value|day_to_object" :value="value|day_to_object"/>
<code-and-result label="value|day_to_string" :value="value|day_to_string"/>
<code-title title="查询" sub-title="是否之前之后或者相同"/>
<code-and-result label="value|day_is_before('2020-1-1')" :value="value|day_is_before('2020-1-1')"/>
<code-and-result label="value|day_is_after('2012-1-1')" :value="value|day_is_after('2012-1-1')"/>
<code-and-result label="value|day_is_same(new Date())" :value="value|day_is_same(new Date())"/>
<code-and-result label="value|day_is_same(new Date(), 'date')" :value="value|day_is_same(new Date(), 'date')"/>
</d2-container>
</template>
<script>
import codeTitle from './components/code-title'
import codeAndResult from './components/code-and-result'
export default {
components: {
codeTitle,
codeAndResult
},
data () {
return {
value: new Date()
}
}
}
</script>

View File

@@ -0,0 +1,22 @@
<template>
<d2-container :filename="filename" type="ghost">
<d2-module-index-banner slot="header" v-bind="banner"/>
<d2-module-index-menu :menu="menu"/>
</d2-container>
</template>
<script>
import menu from '@/menu/modules/demo-filters'
export default {
data () {
return {
filename: __filename,
menu,
banner: {
title: 'FILTERS',
subTitle: '内置过滤器'
}
}
}
}
</script>