Skip to content

Commit

Permalink
自定义date filter,修改Readme,增加Demo截图展示
Browse files Browse the repository at this point in the history
  • Loading branch information
eteplus committed Feb 2, 2016
1 parent 02cb947 commit 91df7c9
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Vue很轻量,易定制,比较适合移动端,很喜欢Vue写组件的方式,
所有用[VUE](http://cn.vuejs.org/)[SUI-Mobile](http://m.sui.taobao.org/) 写了一个移动端demo,用来反馈vue的学习成果(禁用了SUI自带的路由,使用[Vue-router](https://github.com/vuejs/vue-router)


##### 技术栈

> [vue](https://github.com/vuejs/vue)
Expand All @@ -22,6 +23,13 @@ Vue很轻量,易定制,比较适合移动端,很喜欢Vue写组件的方
> [es6-babel](https://babeljs.io/docs/learn-es2015/)
---
### 截图

---

![print](./src/assets/print.png)

---

### 安装
Expand All @@ -37,7 +45,7 @@ git clone https://github.com/eteplus/vue-sui-demo.git
npm install -g cnpm --registry=http://registry.npm.taobao.org
```

``` bash
```bash
# 安装依赖模块
cnpm install

Expand Down
4 changes: 4 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import routerConfig from './router'
import pullToRefresh from './directives/pullToRefresh'
import * as filters from './filters'
import app from './main'

// Router
Expand All @@ -26,6 +27,9 @@ Vue.http.options.emulateJSON = true
// Directive
Vue.directive('pullToRefresh', pullToRefresh)

// Filters
Vue.filter('date', filters.dateFilter)

router.start(app, '#app')

window.router = router
Binary file added src/assets/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/print.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export let dateFilter = (time, type) => {
let date = new Date(time * 1000)
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
let hours = date.getHours()
let minutes = date.getMinutes()
let result
switch (type)
{
case 0: // 01-05
result = (month >= 10 ? month : '0' + month) + '-' + (day >= 10 ? day : '0' + day)
break
case 1: // 11:12
result = hours + ':' + minutes
break
case 2: // 2015-01-05
result = year + '-' + (month >= 10 ? month : '0' + month) + '-' + (day >= 10 ? day : '0' + day)
break
case 3: // 2015-01-05 11:12
result = year + '-' + (month >= 10 ? month : '0' + month) + '-' + (day >= 10 ? day : '0' + day) + ' ' + hours + ':' + minutes
break
}
return result
}
3 changes: 2 additions & 1 deletion src/views/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</btn>
</v-content>
<div class="card-container">
<v-card-container v-for="task in tasks | orderBy 'created'"
<v-card-container v-for="task in tasks | orderBy 'created' -1"
:style="{backgroundColor: task.status === '1' ? 'white': 'rgb(224, 224, 224)' }">
<card type="content">
<list type="media">
Expand All @@ -30,6 +30,7 @@
<item type="inner">
<item type="title-row">
<item type="text">{{task.title}}</item>
<item type="text">{{task.created | date 2}}</item>
</item>
</item>
</li>
Expand Down

0 comments on commit 91df7c9

Please sign in to comment.