Skip to content

Commit 58f621a

Browse files
committed
vuex state.assets
1 parent db23b5f commit 58f621a

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/components/List.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
tr(v-for="post in computedList" key="tr" class="table-row-item" :to="'/post/' + post.topicId" v-on:click="goToPost(post.topicId, post.announce)")
2424
td(key="announce") {{ post.announce }}
2525
td(key="replies") {{ post.NumReplies }}
26-
td(key="views") {{ post.DateTimeLastPost }}
26+
td(key="lastComment") {{ post.DateTimeLastPost }}
2727
td(key="rank") {{ post.rank }}
2828
td.links(key="links")
2929
a(v-on:click="dataHref(post.topicStarterUrl, $event)")

src/store/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Vue from 'vue'
2+
import Vuex from 'vuex'
3+
import axios from 'axios'
4+
Vue.use(Vuex)
5+
6+
const store = new Vuex.Store({
7+
state: {
8+
assets: []
9+
},
10+
actions: {
11+
LOAD_ASSETS_LIST: function ({ commit }) {
12+
axios.get('/static/data/announceList.json', {
13+
headers: {'Cache-Control': 'private, max-age=0, no-cache'}
14+
}).then((response) => {
15+
commit('SET_ASSETS_LIST', { list: response.data })
16+
}, (err) => {
17+
console.log(err)
18+
})
19+
},
20+
},
21+
mutations: {
22+
SET_ASSETS_LIST: (state, { list }) => {
23+
state.assets = list
24+
},
25+
},
26+
getters: {
27+
fullAssetsList: (state, getters) => (id) => {
28+
if (state.assets.length !== 0) {
29+
return state.assets.filter((item) => {
30+
return item.announce.toLowerCase().indexOf(id.toLowerCase()) !== -1
31+
})
32+
}
33+
}
34+
}
35+
})
36+
37+
export default store

0 commit comments

Comments
 (0)