diff --git a/components/center/collect.vue b/components/center/collect.vue index 2aa1d2e..9a67f68 100644 --- a/components/center/collect.vue +++ b/components/center/collect.vue @@ -1,17 +1,30 @@ diff --git a/components/center/myupload.vue b/components/center/myupload.vue index c2def81..0325588 100644 --- a/components/center/myupload.vue +++ b/components/center/myupload.vue @@ -1,18 +1,29 @@ + diff --git a/nuxt.config.js b/nuxt.config.js index 2fa8b4e..46b6121 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -208,7 +208,13 @@ export default { "add_tip_fail": "笔记添加失败", "add_tip_ok": "笔记添加成功", "auto_save": "失去焦点自动保存", + "cancel_collect": "取消收藏", + "cancel_collect_fail": "取消收藏失败", + "cancel_collect_ok": "取消收藏成功", "click_note_list": "单击卡片定位笔记", + "collect": "收藏", + "collect_fail": "收藏失败", + "collect_ok": "收藏成功", "contextmenu_err": "请选中文本进行操作", "del_confirm": "确认删除此笔记?", "note_zero": "还没有任何笔记,尝试正文选中文本右击添加一个笔记吧!", @@ -375,7 +381,13 @@ export default { "add_tip_fail": "", "add_tip_ok": "", "auto_save": "", + "cancel_collect": "", + "cancel_collect_fail": "", + "cancel_collect_ok": "", "click_note_list": "", + "collect": "", + "collect_fail": "", + "collect_ok": "", "contextmenu_err": "", "del_confirm": "", "note_zero": "", diff --git a/pages/index/document.vue b/pages/index/document.vue index 74ce24e..9a852a1 100644 --- a/pages/index/document.vue +++ b/pages/index/document.vue @@ -128,24 +128,8 @@ } }, methods: { - read(item: any) { - let loadingInstance =Loading.service({}); - let that=this - this.GLOBAL.fetchGet("/v1/api/file/find",{ - paperId:item.id, - fileId:item.fileId - },function(res) { - if(res.code==='200'){ - item.content=res.msg - that.$store.commit('menus/read') - that.$store.commit('read/open', item) - that.$router.push(that.localePath('/read')) - loadingInstance.close() - }else{ - that.$message.error(that.$t('error_500').toString()) - } - loadingInstance.close() - }) + read(item){ + this.$read(item) }, query(){ let that=this diff --git a/pages/index/note.vue b/pages/index/note.vue index 6ef95fe..e609560 100644 --- a/pages/index/note.vue +++ b/pages/index/note.vue @@ -95,7 +95,6 @@ item.content=res.msg that.$store.commit('menus/read') that.$store.commit('read/open', item) - // that.$router.push({that.localePath('/read')}) that.$router.push({ path:that.localePath('/read'), query:row diff --git a/pages/index/read.vue b/pages/index/read.vue index 0aeba73..979ac44 100644 --- a/pages/index/read.vue +++ b/pages/index/read.vue @@ -31,7 +31,13 @@ - + + + {{item.title}} + + + + @@ -226,6 +232,19 @@ }, methods: { + //收藏 + star(e,item){ + e.stopPropagation() + let that=this + this.GLOBAL.fetchJSON(`/v1/api/collect/${item.id}`,'POST',{},function(res) { + if(res.code==='200'){ + that.$store.commit('read/updateCollect',item.title) + that.$message.info(that.$t(res.msg)) + }else{ + that.$message.error(that.$t(res.msg)) + } + }) + }, //查找评价记录 queryRating(){ let that=this @@ -720,5 +739,4 @@ vertical-align: text-top; } - diff --git a/plugins/global.js b/plugins/global.js index 88b6cae..2e60abd 100644 --- a/plugins/global.js +++ b/plugins/global.js @@ -1,4 +1,5 @@ import Vue from 'vue' +import { Loading } from 'element-ui' Vue.prototype.GLOBAL ={ //用户cookie @@ -14,6 +15,7 @@ Vue.prototype.GLOBAL ={ return !(r.top > z.bottom || r.bottom < z.top || r.left > z.right || r.right < z.left); }, + //发送json请求 fetchJSON(url,method, form, success){ fetch(this.server_address + url, { body:JSON.stringify(form), @@ -26,6 +28,7 @@ Vue.prototype.GLOBAL ={ console.error(err) }) }, + //发送get请求 fetchGet(url,params,success){ if (params) { let paramsArray = []; @@ -43,6 +46,28 @@ Vue.prototype.GLOBAL ={ }).then(res=>res.json()).then(res=>success(res)).catch(err=>{ console.error(err) }) - } + }, + } +//阅读论文 +Vue.prototype.$read= function(item) { + let loadingInstance =Loading.service({}); + let that=this + this.GLOBAL.fetchGet("/v1/api/file/find",{ + paperId:item.id, + fileId:item.fileId + },function(res) { + if(res.code==='200'){ + item.content=res.msg + that.$store.commit('menus/read') + that.$store.commit('read/open', item) + that.$router.push(that.localePath('/read')) + loadingInstance.close() + }else{ + that.$message.error(that.$t('error_500').toString()) + } + loadingInstance.close() + }) +} + diff --git a/store/read.js b/store/read.js index c22c5ad..78deaf2 100644 --- a/store/read.js +++ b/store/read.js @@ -41,5 +41,9 @@ export const mutations = { //更新正文 updateContent(state,content){ state.read[state.activeName].content=content + }, + //更新收藏状态 + updateCollect(state,key){ + state.read[key].hasCollect=!state.read[key].hasCollect } }