Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
增加文章列表导出状态更新展示支持
Browse files Browse the repository at this point in the history
  • Loading branch information
lunnlew committed Dec 21, 2019
1 parent 8424a8e commit 6610ac4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/backend/weicai/AppServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class AppServer {
console.log('wechat_history')
self.ws['wechat_history'].send(JSON.stringify(data))
})
self.recorder.on('export_status', (data) => {
console.log('export_status')
self.ws['wcclient'].send(JSON.stringify(data))
})
self.recorder.on('article_detail', (data) => {
console.log('article_detail')
self.ws['article_detail'].send(JSON.stringify(data))
Expand Down
13 changes: 12 additions & 1 deletion src/backend/weicai/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,20 @@ appServer.route(function(self) {
// 标记文件末尾
writerStream.end()
writerStream.on('finish', function() {
console.log("写入完成。")
self.recorder.emit('export_status', {
'type': 'export_status',
'data': {
'state': 'success'
}
})
});
writerStream.on('error', function(err) {
self.recorder.emit('export_status', {
'type': 'export_status',
'data': {
'state': 'fail'
}
})
console.log(err.stack)
});
res.send({
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ socket.addEventListener('message', function(event) {
if (data.type == 'toggleMakeImg') {
store.dispatch('toggleMakeImg', data.data)
}
if (data.type == 'export_status') {
store.dispatch('toggleLoading', data.data)
}
});


Expand Down
22 changes: 22 additions & 0 deletions src/renderer/store/modules/ExportView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const state = {
loading: false
}

const mutations = {
toggleLoading(state, data) {
console.log(data)
state.loading = !state.loading;
}
}

const actions = {
toggleLoading({ commit }, data) {
commit('toggleLoading', data)
}
}

export default {
state,
mutations,
actions
}
20 changes: 18 additions & 2 deletions src/renderer/view/ExportView/article.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Divider orientation="left">备选导出字段</Divider>
<Tag type="dot" closable color="default" v-for="item in keys_save" :key="item.field" :name="item.name" @on-close="handleCloseB">{{ item.name }}</Tag>
<Divider orientation="left">导出方式</Divider>
<Button type="primary" @click="clickExport('csv')">导出为CSV</Button>
<Button type="primary" :loading="loadingExport" @click="clickExport('csv')">导出为CSV</Button>
</div>
</div>
</div>
Expand Down Expand Up @@ -42,6 +42,15 @@ export default {
keys_save: [{
'name': '采集时间',
'field': 'create_time'
}, {
'name': '文章文本',
'field': 'text'
}, {
'name': '文章描述',
'field': 'msg_desc'
}, {
'name': '文章标识',
'field': 'msg_sn'
}]
}
},
Expand All @@ -57,6 +66,9 @@ export default {
this.keys.push(current.pop())
},
clickExport(type) {
this.$store.dispatch('toggleLoading')
articleAction({
'act': 'export',
'type': type
Expand All @@ -67,7 +79,11 @@ export default {
},
mounted() {},
watch: {},
computed: {}
computed: {
loadingExport() {
return this.$store.state.ExportView.loading
}
}
}
</script>
Expand Down

0 comments on commit 6610ac4

Please sign in to comment.