refs #355 List up saved tags in hastag page
This commit is contained in:
parent
2659991091
commit
00452f9fe2
|
@ -626,6 +626,17 @@ ipcMain.on('save-hashtag', (event, tag) => {
|
|||
})
|
||||
})
|
||||
|
||||
ipcMain.on('list-hashtags', (event, _) => {
|
||||
const hashtags = new Hashtags(hashtagsDB)
|
||||
hashtags.listTags()
|
||||
.then((tags) => {
|
||||
event.sender.send('response-list-hashtags', tags)
|
||||
})
|
||||
.catch((err) => {
|
||||
event.sender.send('error-list-hashtags', err)
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Auto Updater
|
||||
*
|
||||
|
|
|
@ -1,13 +1,56 @@
|
|||
<template>
|
||||
<div>
|
||||
</div>
|
||||
<div id="list">
|
||||
<table class="tag-list">
|
||||
<tbody>
|
||||
<tr v-for="tag in tags" v-bind:key="tag._id" @click="openTimeline(tag.tagName)">
|
||||
<td>
|
||||
{{ tag.tagName }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'list'
|
||||
name: 'list',
|
||||
computed: {
|
||||
...mapState({
|
||||
tags: state => state.TimelineSpace.Contents.Hashtag.List.tags
|
||||
})
|
||||
},
|
||||
created () {
|
||||
this.$store.dispatch('TimelineSpace/Contents/Hashtag/List/listTags')
|
||||
},
|
||||
methods: {
|
||||
openTimeline (tag) {
|
||||
this.$router.push({ path: `/${this.$route.params.id}/hashtag/${tag}` })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#list {
|
||||
.tag-list {
|
||||
width: 100%;
|
||||
|
||||
tr,
|
||||
th,
|
||||
td {
|
||||
background-color: var(--theme-background-color);
|
||||
color: var(--theme-secondary-color);
|
||||
border-bottom: 1px solid var(--theme-border-color);
|
||||
padding: 12px 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-top: 1px solid var(--theme-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,5 +1,31 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
|
||||
const List = {
|
||||
namespaced: true
|
||||
namespaced: true,
|
||||
state: {
|
||||
tags: []
|
||||
},
|
||||
mutations: {
|
||||
updateTags (state, tags) {
|
||||
state.tags = tags
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
listTags ({ commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.once('response-list-hashtags', (event, tags) => {
|
||||
ipcRenderer.removeAllListeners('error-list-hashtags')
|
||||
commit('updateTags', tags)
|
||||
resolve(tags)
|
||||
})
|
||||
ipcRenderer.once('error-list-hashtags', (event, err) => {
|
||||
ipcRenderer.removeAlListeners('response-list-hashtags')
|
||||
reject(err)
|
||||
})
|
||||
ipcRenderer.send('list-hashtags')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default List
|
||||
|
|
Loading…
Reference in New Issue