🐛 消息标记已读问题修复

This commit is contained in:
ronger 2021-04-27 21:12:16 +08:00
parent 2d844b1d8b
commit 739c180043

View File

@ -9,7 +9,8 @@
<el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col> <el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col>
</el-col> </el-col>
<el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;"> <el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;">
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false" @click="read(notification.idNotification)"> <el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false"
@click="read(notification.idNotification)">
<i class="el-icon-check"></i> 标记已读 <i class="el-icon-check"></i> 标记已读
</el-link> </el-link>
</el-col> </el-col>
@ -21,7 +22,8 @@
<el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col> <el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col>
</el-col> </el-col>
<el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;"> <el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;">
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false" @click="read(notification.idNotification)"> <el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false"
@click="read(notification.idNotification)">
<i class="el-icon-check"></i> 标记已读 <i class="el-icon-check"></i> 标记已读
</el-link> </el-link>
</el-col> </el-col>
@ -71,32 +73,32 @@
</template> </template>
<script> <script>
export default { export default {
name: "NotificationList", name: "NotificationList",
props: { props: {
notifications: { notifications: {
type: Object type: Object
} }
},
methods: {
currentChange(page) {
this.$emit('currentChange', page);
}, },
methods: { read(id) {
currentChange(page) { let _ts = this;
this.$emit('currentChange', page); this.$axios.$put('/api/notification/read/' + id).then(function () {
}, _ts.$store.commit('notification/updateState', true)
read(id) { _ts.$store.dispatch('notification/fetchList', {page: 1})
let _ts = this; }).catch(error => console.log(error));
this.$axios.$put('/api/notification/read/' + id).then(function () { },
_ts.$store.commit('notification/updateState', true) onRouter(notification) {
_ts.currentChange(1); if (notification.hasRead === '0') {
}).catch(error => console.log(error)); this.read(notification.idNotification);
},
onRouter(notification) {
if (notification.hasRead === '0') {
this.read(notification.idNotification);
}
window.location.href = notification.dataUrl;
} }
window.location.href = notification.dataUrl;
} }
} }
}
</script> </script>
<style scoped> <style scoped>