no message

Former-commit-id: 393b0dcb5b150dba8c885950b4e7ff014694b0a3
Former-commit-id: 474f4843c60b88e4caafcf172c30e47a07efd93b
Former-commit-id: 8c7c236ef02b6ebe012640406ff1dc48e11c6290
Former-commit-id: 2baf360fdad8b6026a87bf379cf48e0e18d06bbb
This commit is contained in:
liyang
2018-06-12 14:52:55 +08:00
parent 4e73b6a8ae
commit aca56a052a
6 changed files with 3 additions and 126 deletions

View File

@@ -70,8 +70,7 @@ function sideBarPlugins () {
'data-export',
'data-import',
'i18n',
'mock',
'timeago'
'mock'
]
}

View File

@@ -1,49 +0,0 @@
# 时间差计算
``` js
import timeago from 'timeago.js'
export default {
data () {
return {
// 打开页面时间
openPageDate: new Date(),
// 打开页面已经过去的时间
openPageDateAgo: '',
// 打开页面时间计时器
dateTimeRangeTimer: null,
// 起止时间
dateTimeRange: [new Date(2018, 0, 1, 0, 0), new Date()],
// 上面起止时间的计算结果
dateTimeRangeAgo: ''
}
},
mounted () {
// 刷新打开页面过去的时间
this.refreshOpenPageDateAgo()
this.dateTimeRangeTimer = setInterval(this.refreshOpenPageDateAgo, 1000)
// 刷新起止时间的计算结果
this.refreshDateTimeRangeAgo()
},
beforeDestroy () {
// 清空计时器
clearInterval(this.dateTimeRangeTimer)
},
watch: {
dateTimeRange () {
// 刷新起止时间的计算结果
this.refreshDateTimeRangeAgo()
}
},
methods: {
// 计算打开页面过了多久
refreshOpenPageDateAgo () {
this.openPageDateAgo = timeago().format(this.openPageDate, 'zh_CN')
},
// 计算起止时间间隔
refreshDateTimeRangeAgo () {
const timeagoInstance = timeago(this.dateTimeRange[1])
this.dateTimeRangeAgo = timeagoInstance.format(this.dateTimeRange[0], 'zh_CN')
}
}
}
```

View File

@@ -32,7 +32,6 @@
"path-posix": "^1.0.0",
"quill": "^1.3.4",
"simplemde": "^1.11.2",
"timeago.js": "^3.0.2",
"vue": "^2.5.2",
"vue-grid-layout": "^2.1.11",
"vue-i18n": "^7.4.2",

View File

@@ -41,8 +41,7 @@ const demoPlugins = {
{ path: `${pre}build`, title: '环境区分' },
{ path: `${pre}clipboard-polyfill`, title: '剪贴板访问' },
{ path: `${pre}day`, title: '日期计算' },
{ path: `${pre}js-cookie`, title: 'Cookie 读写' },
{ path: `${pre}timeago`, title: '时间差计算' }
{ path: `${pre}js-cookie`, title: 'Cookie 读写' }
])('/demo/plugins/')
}

View File

@@ -1,70 +0,0 @@
<template>
<d2-container type="ghost">
<el-card shadow="never" class="d2-mb">
<div class="d2-text-center">
<h1 style="font-size: 30px;">您在{{openPageDateAgo}}打开的此页面</h1>
<p style="font-size: 10px;">请稍等一下 10秒后会开始自动刷新</p>
</div>
</el-card>
<el-card shadow="never">
<div class="d2-text-center">
<h1 style="font-size: 30px;">{{dateTimeRangeAgo}}</h1>
<el-date-picker
v-model="dateTimeRange"
type="datetimerange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</div>
</el-card>
</d2-container>
</template>
<script>
import timeago from 'timeago.js'
export default {
data () {
return {
// 打开页面时间
openPageDate: new Date(),
// 打开页面已经过去的时间
openPageDateAgo: '',
// 打开页面时间计时器
dateTimeRangeTimer: null,
// 起止时间
dateTimeRange: [new Date(2018, 0, 1, 0, 0), new Date()],
// 上面起止时间的计算结果
dateTimeRangeAgo: ''
}
},
mounted () {
// 刷新打开页面过去的时间
this.refreshOpenPageDateAgo()
this.dateTimeRangeTimer = setInterval(this.refreshOpenPageDateAgo, 1000)
// 刷新起止时间的计算结果
this.refreshDateTimeRangeAgo()
},
beforeDestroy () {
// 清空计时器
clearInterval(this.dateTimeRangeTimer)
},
watch: {
dateTimeRange () {
// 刷新起止时间的计算结果
this.refreshDateTimeRangeAgo()
}
},
methods: {
// 计算打开页面过了多久
refreshOpenPageDateAgo () {
this.openPageDateAgo = timeago().format(this.openPageDate, 'zh_CN')
},
// 计算起止时间间隔
refreshDateTimeRangeAgo () {
const timeagoInstance = timeago(this.dateTimeRange[1])
this.dateTimeRangeAgo = timeagoInstance.format(this.dateTimeRange[0], 'zh_CN')
}
}
}
</script>

View File

@@ -64,8 +64,7 @@ const routes = [
{ path: 'js-cookie', name: `${pre}js-cookie`, component: () => import('@/pages/demo/plugins/js-cookie/index.vue') },
{ path: 'mock/ajax', name: `${pre}mock-ajax`, component: () => import('@/pages/demo/plugins/mock/ajax.vue') },
{ path: 'mock/dpd', name: `${pre}mock-dpd`, component: () => import('@/pages/demo/plugins/mock/dpd.vue') },
{ path: 'mock/dtd', name: `${pre}mock-dtd`, component: () => import('@/pages/demo/plugins/mock/dtd.vue') },
{ path: 'timeago', name: `${pre}timeago`, component: () => import('@/pages/demo/plugins/timeago/index.vue') }
{ path: 'mock/dtd', name: `${pre}mock-dtd`, component: () => import('@/pages/demo/plugins/mock/dtd.vue') }
])('demo-plugins-')
},
{