Skip to content

Commit

Permalink
feat: 标记浏览过的帖子
Browse files Browse the repository at this point in the history
  • Loading branch information
ttop5 committed Aug 6, 2019
1 parent 7de4838 commit 48551a1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
v-ripple
tag="a"
target="_blank"
:style="`color: ${(readedLinks.includes(item.url)) ? 'gray' : 'unset'}`"
:href="item.url"
:key="item.index"
@click="clickHandler(item)"
>
{{ item.title }}
</q-item>
Expand All @@ -24,6 +26,7 @@ export default {
data() {
return {
postList: [],
readedLinks: JSON.parse(localStorage.getItem('slackReadedLinks')) || [],
};
},
watch: {
Expand All @@ -37,6 +40,12 @@ export default {
this.$set(this, 'postList', res.data.Data);
});
},
clickHandler(item) {
if (!this.readedLinks.includes(item.url)) {
this.readedLinks.push(item.url);
}
localStorage.setItem('slackReadedLinks', JSON.stringify(this.readedLinks));
},
},
created() {
this.getPostList();
Expand Down

0 comments on commit 48551a1

Please sign in to comment.