对接后台笔记更新接口

master
pan 4 years ago
parent 464421c2a3
commit e7e7b6737a
  1. 8
      nuxt.config.js
  2. 20
      pages/index/read.vue

@ -215,7 +215,9 @@ export default {
"rating_ok": "评价成功", "rating_ok": "评价成功",
"search_next": "查找下一个", "search_next": "查找下一个",
"search_prev": "查找上一个", "search_prev": "查找上一个",
"search_zero": "正文中没有 ‘{keyword}’" "search_zero": "正文中没有 ‘{keyword}’",
"update_note_fail": "笔记保存失败",
"update_note_ok": "笔记保存成功"
} }
}, },
"reading_online": "在线阅读", "reading_online": "在线阅读",
@ -377,7 +379,9 @@ export default {
"rating_ok": "", "rating_ok": "",
"search_next": "", "search_next": "",
"search_prev": "", "search_prev": "",
"search_zero": "" "search_zero": "",
"update_note_fail": "",
"update_note_ok": ""
} }
}, },
"reading_online": "", "reading_online": "",

@ -62,7 +62,6 @@
<el-col :span="5" class="ml3 note-list"> <el-col :span="5" class="ml3 note-list">
<template v-if="noteList.length>0"> <template v-if="noteList.length>0">
<el-row v-for="(item,index) in noteList" :key="index" class="mb2"> <el-row v-for="(item,index) in noteList" :key="index" class="mb2">
<el-tooltip :content="$t('read.tip.click_note_list')" :disabled="item.isEdit">
<el-card> <el-card>
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<el-row type="flex" justify="space-around"> <el-row type="flex" justify="space-around">
@ -78,7 +77,6 @@
</el-button-group> </el-button-group>
</el-row> </el-row>
</div> </div>
<div class="text item" @click="jump(item)" @mouseover="highlighting(item)" <div class="text item" @click="jump(item)" @mouseover="highlighting(item)"
@mouseout="reset(item)"> @mouseout="reset(item)">
<transition v-if="item.isEdit" @after-leave="save(item)"> <transition v-if="item.isEdit" @after-leave="save(item)">
@ -88,11 +86,12 @@
</el-tooltip> </el-tooltip>
</transition> </transition>
<template v-else> <template v-else>
<el-tooltip :content="$t('read.tip.click_note_list')" :disabled="item.isEdit">
<pre style="background-color: white">{{item.content}}</pre> <pre style="background-color: white">{{item.content}}</pre>
</el-tooltip>
</template> </template>
</div> </div>
</el-card> </el-card>
</el-tooltip>
<el-alert v-if="item.message" <el-alert v-if="item.message"
@close="item.message=null;item.type=null" @close="item.message=null;item.type=null"
:title="item.message" :title="item.message"
@ -369,8 +368,19 @@
}, },
// //
save(item: any) { save(item: any) {
this.$set(item, 'type', 'success') let that=this
this.$set(item, 'message', '保存成功') this.GLOBAL.fetchJSON('/v1/api/notes/update','PUT',{
noteId:item.id,
noteContent:item.content
},function(res) {
if(res.code==='200'){
that.$set(item, 'type', 'success')
that.$set(item, 'message', that.$t('read.tip.update_note_ok'))
}else {
that.$set(item, 'type', 'error')
that.$set(item, 'message', that.$t('read.tip.update_note_fail'))
}
})
}, },
// //
del(item: any, index: number) { del(item: any, index: number) {

Loading…
Cancel
Save