|
|
@ -12,10 +12,12 @@ |
|
|
|
<el-input autosize type="textarea" v-model="note_form.original_text" disabled></el-input> |
|
|
|
<el-input autosize type="textarea" v-model="note_form.original_text" disabled></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('read.form.note_title')" prop="note_title"> |
|
|
|
<el-form-item :label="$t('read.form.note_title')" prop="note_title"> |
|
|
|
<el-input v-model="note_form.note_title" :placeholder="$t('input_please', { keyword: this.$t('read.form.note_title') })"></el-input> |
|
|
|
<el-input v-model="note_form.note_title" |
|
|
|
|
|
|
|
:placeholder="$t('input_please', { keyword: this.$t('read.form.note_title') })"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('read.form.note_content')" prop="note_content"> |
|
|
|
<el-form-item :label="$t('read.form.note_content')" prop="note_content"> |
|
|
|
<el-input autosize type="textarea" v-model="note_form.note_content" :placeholder="$t('input_please', { keyword: this.$t('read.form.note_content') })"></el-input> |
|
|
|
<el-input autosize type="textarea" v-model="note_form.note_content" |
|
|
|
|
|
|
|
:placeholder="$t('input_please', { keyword: this.$t('read.form.note_content') })"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button @click="addNote">{{$t('button.add')}}</el-button> |
|
|
|
<el-button @click="addNote">{{$t('button.add')}}</el-button> |
|
|
@ -25,7 +27,9 @@ |
|
|
|
<el-button slot="reference">{{$t('read.contextmenu.add')}}</el-button> |
|
|
|
<el-button slot="reference">{{$t('read.contextmenu.add')}}</el-button> |
|
|
|
</el-popover> |
|
|
|
</el-popover> |
|
|
|
</v-contextmenu-item> |
|
|
|
</v-contextmenu-item> |
|
|
|
<v-contextmenu-item><el-button @click="showSearch=true;queryContent()" class="w-100">{{$t('read.contextmenu.search')}}</el-button></v-contextmenu-item> |
|
|
|
<v-contextmenu-item> |
|
|
|
|
|
|
|
<el-button @click="updateFind(true);queryContent()" class="w-100">{{$t('read.contextmenu.search')}}</el-button> |
|
|
|
|
|
|
|
</v-contextmenu-item> |
|
|
|
</v-contextmenu> |
|
|
|
</v-contextmenu> |
|
|
|
<el-tabs v-model="activeName" type="card" closable @tab-remove="removeTab"> |
|
|
|
<el-tabs v-model="activeName" type="card" closable @tab-remove="removeTab"> |
|
|
|
<el-tab-pane :label="key" :name="key" v-for="(item,key) in openList" :key="key"> |
|
|
|
<el-tab-pane :label="key" :name="key" v-for="(item,key) in openList" :key="key"> |
|
|
@ -33,7 +37,8 @@ |
|
|
|
<el-col :span="18"> |
|
|
|
<el-col :span="18"> |
|
|
|
<el-form :inline="true" v-if="showSearch"> |
|
|
|
<el-form :inline="true" v-if="showSearch"> |
|
|
|
<el-form-item :label="$t('read.form.keyword')"> |
|
|
|
<el-form-item :label="$t('read.form.keyword')"> |
|
|
|
<el-input @input="queryContent" :placeholder="$t('input_please',{keyword:$t('read.form.keyword')})" v-model="search_form.keyword" |
|
|
|
<el-input @input="queryContent" :placeholder="$t('input_please',{keyword:$t('read.form.keyword')})" |
|
|
|
|
|
|
|
v-model="search_form.keyword" |
|
|
|
maxlength="10" |
|
|
|
maxlength="10" |
|
|
|
show-word-limit> |
|
|
|
show-word-limit> |
|
|
|
<i slot="prefix" class="el-input__icon el-icon-search"></i> |
|
|
|
<i slot="prefix" class="el-input__icon el-icon-search"></i> |
|
|
@ -42,19 +47,23 @@ |
|
|
|
<template v-if="num>0"> |
|
|
|
<template v-if="num>0"> |
|
|
|
<el-form-item>{{search_index+1+'/'+num}}</el-form-item> |
|
|
|
<el-form-item>{{search_index+1+'/'+num}}</el-form-item> |
|
|
|
<el-tooltip :content="$t('read.tip.search_prev')"> |
|
|
|
<el-tooltip :content="$t('read.tip.search_prev')"> |
|
|
|
<el-image src="/prev.svg" class="img" @click="search_index>0?search_index--:search_index=num-1;change_search_index()"></el-image> |
|
|
|
<el-image src="/prev.svg" class="img" |
|
|
|
|
|
|
|
@click="search_index>0?search_index--:search_index=num-1;change_search_index()"></el-image> |
|
|
|
</el-tooltip> |
|
|
|
</el-tooltip> |
|
|
|
<el-tooltip :content="$t('read.tip.search_next')"> |
|
|
|
<el-tooltip :content="$t('read.tip.search_next')"> |
|
|
|
<el-image src="/next.svg" class="img" @click="search_index<num-1?search_index++:search_index=0;change_search_index()"></el-image> |
|
|
|
<el-image src="/next.svg" class="img" |
|
|
|
|
|
|
|
@click="search_index<num-1?search_index++:search_index=0;change_search_index()"></el-image> |
|
|
|
</el-tooltip> |
|
|
|
</el-tooltip> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
<pre class="content" v-contextmenu:contextmenu :ref="'edit'+item.title" @mouseup="show" |
|
|
|
<pre class="content" v-contextmenu:contextmenu :ref="'edit'+item.title" @mouseup="show" |
|
|
|
@contextmenu="selectText" v-html="item.content" |
|
|
|
@contextmenu="selectText" @scroll="scrollContent" v-html="item.content" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
<el-col :span="5" class="ml3 note-list"> |
|
|
|
<el-col :span="5" class="ml3 note-list"> |
|
|
|
|
|
|
|
<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"> |
|
|
@ -70,22 +79,29 @@ |
|
|
|
</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)"> |
|
|
|
<el-tooltip class="item" effect="dark" :content="$t('read.tip.auto_save')" v-model="item.isEdit"> |
|
|
|
<el-tooltip class="item" effect="dark" :content="$t('read.tip.auto_save')" |
|
|
|
|
|
|
|
v-model="item.isEdit"> |
|
|
|
<el-input autosize type="textarea" v-model="item.content"></el-input> |
|
|
|
<el-input autosize type="textarea" v-model="item.content"></el-input> |
|
|
|
</el-tooltip> |
|
|
|
</el-tooltip> |
|
|
|
</transition> |
|
|
|
</transition> |
|
|
|
<template v-else><pre style="background-color: white">{{item.content}}</pre></template> |
|
|
|
<template v-else> |
|
|
|
|
|
|
|
<pre style="background-color: white">{{item.content}}</pre> |
|
|
|
|
|
|
|
</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" |
|
|
|
:type="item.type"> |
|
|
|
:type="item.type"> |
|
|
|
</el-alert> |
|
|
|
</el-alert> |
|
|
|
</el-row> |
|
|
|
</el-row> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<h1 v-else>{{$t('read.tip.note_zero')}}</h1> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-row> |
|
|
|
</el-tab-pane> |
|
|
|
</el-tab-pane> |
|
|
@ -119,6 +135,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
export default Vue.extend({ |
|
|
|
export default Vue.extend({ |
|
|
|
name: 'read', |
|
|
|
name: 'read', |
|
|
|
|
|
|
|
layout: 'my-pre', |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
//显示搜索框 |
|
|
|
//显示搜索框 |
|
|
@ -135,6 +152,7 @@ |
|
|
|
search_index: -1, |
|
|
|
search_index: -1, |
|
|
|
//笔记表单 |
|
|
|
//笔记表单 |
|
|
|
note_form: { |
|
|
|
note_form: { |
|
|
|
|
|
|
|
note_id: '', |
|
|
|
note_title: '', |
|
|
|
note_title: '', |
|
|
|
note_content: '', |
|
|
|
note_content: '', |
|
|
|
original_text: '' |
|
|
|
original_text: '' |
|
|
@ -168,16 +186,41 @@ |
|
|
|
//打开的论文标签 |
|
|
|
//打开的论文标签 |
|
|
|
openList() { |
|
|
|
openList() { |
|
|
|
return this.$store.state.read.read |
|
|
|
return this.$store.state.read.read |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//当前激活的正文元素 |
|
|
|
|
|
|
|
pre() { |
|
|
|
|
|
|
|
return this.$refs['edit' + this.activeName][0] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//当前激活的论文实体 |
|
|
|
|
|
|
|
activeContent() { |
|
|
|
|
|
|
|
return this.$store.state.read.read[this.activeName] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
|
//激活的论文标签 |
|
|
|
//激活的论文标签 |
|
|
|
activeName(newVal) { |
|
|
|
activeName(newVal) { |
|
|
|
this.$store.commit('read/choose', newVal) |
|
|
|
this.$store.commit('read/choose', newVal) |
|
|
|
|
|
|
|
this.doScroll() |
|
|
|
|
|
|
|
if (this.activeContent.find && this.activeContent.find.showSearch) { |
|
|
|
|
|
|
|
this.showSearch = this.activeContent.find.showSearch |
|
|
|
|
|
|
|
this.search_form.keyword = this.activeContent.find.keyword |
|
|
|
|
|
|
|
let search_index = this.activeContent.find.search_index |
|
|
|
|
|
|
|
this.queryContent() |
|
|
|
|
|
|
|
this.search_index = search_index |
|
|
|
|
|
|
|
this.change_search_index() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.showSearch = false |
|
|
|
|
|
|
|
this.search_form = { |
|
|
|
|
|
|
|
keyword: '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.num = 0 |
|
|
|
|
|
|
|
this.search_index = -1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
showSearch(newVal) { |
|
|
|
showSearch(newVal) { |
|
|
|
if (!newVal) { |
|
|
|
if (!newVal) { |
|
|
|
let pre:HTMLElement=this.$refs['edit'+this.$store.state.read.activeName][0] |
|
|
|
let pre: HTMLElement = this.pre |
|
|
|
this.search_form.keyword = '' |
|
|
|
this.search_form.keyword = '' |
|
|
|
this.resetQuery(pre) |
|
|
|
this.resetQuery(pre) |
|
|
|
} |
|
|
|
} |
|
|
@ -185,19 +228,41 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
|
|
|
|
//滚动正文 |
|
|
|
|
|
|
|
scrollContent(e) { |
|
|
|
|
|
|
|
this.$store.commit('read/scroll', e.target.scrollTop) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
doScroll() { |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
if (this.activeContent.scrollTop) { |
|
|
|
|
|
|
|
this.pre.scrollTo({ |
|
|
|
|
|
|
|
top: this.activeContent.scrollTop |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
//激活选中的搜索结果 |
|
|
|
//激活选中的搜索结果 |
|
|
|
change_search_index() { |
|
|
|
change_search_index() { |
|
|
|
let ele=document.getElementsByClassName('search-light')[this.search_index] |
|
|
|
let ele = this.pre.querySelectorAll('span[class^=search-light]')[this.search_index] |
|
|
|
ele.classList.add('choose-search-text') |
|
|
|
ele.classList.add('choose-search-text') |
|
|
|
ele.scrollIntoView({ |
|
|
|
ele.scrollIntoView({ |
|
|
|
block: 'center' |
|
|
|
block: 'center' |
|
|
|
}) |
|
|
|
}) |
|
|
|
for (let index = 0; index < this.num; index++) { |
|
|
|
for (let index = 0; index < this.num; index++) { |
|
|
|
if (index !== this.search_index) { |
|
|
|
if (index !== this.search_index) { |
|
|
|
document.getElementsByClassName('search-light')[index].classList.remove('choose-search-text') |
|
|
|
this.pre.querySelectorAll('span[class^=search-light]')[index].classList.remove('choose-search-text') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateFind(this.showSearch) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
updateFind(showSearch = false) { |
|
|
|
|
|
|
|
this.showSearch = showSearch |
|
|
|
|
|
|
|
this.$store.commit('read/find', { |
|
|
|
|
|
|
|
showSearch: showSearch, |
|
|
|
|
|
|
|
keyword: this.search_form.keyword, |
|
|
|
|
|
|
|
search_index: this.search_index |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
//重置搜索 |
|
|
|
//重置搜索 |
|
|
|
resetQuery(pre: HTMLElement) { |
|
|
|
resetQuery(pre: HTMLElement) { |
|
|
@ -211,7 +276,7 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
//正文搜索 |
|
|
|
//正文搜索 |
|
|
|
queryContent() { |
|
|
|
queryContent() { |
|
|
|
let pre:HTMLElement=this.$refs['edit'+this.$store.state.read.activeName][0] |
|
|
|
let pre: HTMLElement = this.pre |
|
|
|
this.resetQuery(pre) |
|
|
|
this.resetQuery(pre) |
|
|
|
if (this.search_form.keyword.length === 0) { |
|
|
|
if (this.search_form.keyword.length === 0) { |
|
|
|
let selection = getSelection() |
|
|
|
let selection = getSelection() |
|
|
@ -323,6 +388,8 @@ |
|
|
|
block: 'center' |
|
|
|
block: 'center' |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.highlighting(item) |
|
|
|
}, |
|
|
|
}, |
|
|
|
//是否显示右键菜单 |
|
|
|
//是否显示右键菜单 |
|
|
|
show() { |
|
|
|
show() { |
|
|
@ -344,6 +411,7 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
resetNote() { |
|
|
|
resetNote() { |
|
|
|
this.replace = {} |
|
|
|
this.replace = {} |
|
|
|
|
|
|
|
this.note_form.note_id = '' |
|
|
|
this.note_form.note_title = '' |
|
|
|
this.note_form.note_title = '' |
|
|
|
this.note_form.note_content = '' |
|
|
|
this.note_form.note_content = '' |
|
|
|
this.note_form.original_text = '' |
|
|
|
this.note_form.original_text = '' |
|
|
@ -361,7 +429,7 @@ |
|
|
|
that.replace.replaceVal[index - 1].after(that.replace.replaceVal[index]) |
|
|
|
that.replace.replaceVal[index - 1].after(that.replace.replaceVal[index]) |
|
|
|
} |
|
|
|
} |
|
|
|
that.noteList.unshift({ |
|
|
|
that.noteList.unshift({ |
|
|
|
id: `fuck${(Math.random()*10).toFixed()}`, |
|
|
|
id: this.note_form.note_id, |
|
|
|
title: this.note_form.note_title, |
|
|
|
title: this.note_form.note_title, |
|
|
|
content: this.note_form.note_content |
|
|
|
content: this.note_form.note_content |
|
|
|
}) |
|
|
|
}) |
|
|
@ -376,7 +444,7 @@ |
|
|
|
showClose: true, |
|
|
|
showClose: true, |
|
|
|
duration: 1000 |
|
|
|
duration: 1000 |
|
|
|
}) |
|
|
|
}) |
|
|
|
return false; |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
this.visible = false |
|
|
|
this.visible = false |
|
|
|
}) |
|
|
|
}) |
|
|
@ -394,6 +462,8 @@ |
|
|
|
let anchorNode = range.startContainer |
|
|
|
let anchorNode = range.startContainer |
|
|
|
let bold = document.createElement('span') |
|
|
|
let bold = document.createElement('span') |
|
|
|
bold.classList.add('bold') |
|
|
|
bold.classList.add('bold') |
|
|
|
|
|
|
|
this.note_form.note_id = this.$uuid.v1() |
|
|
|
|
|
|
|
bold.setAttribute('id', this.note_form.note_id) |
|
|
|
if (range.endOffset - range.startOffset === anchorNode.length) { |
|
|
|
if (range.endOffset - range.startOffset === anchorNode.length) { |
|
|
|
console.info(tip + '全选') |
|
|
|
console.info(tip + '全选') |
|
|
|
bold.innerText = anchorNode.wholeText |
|
|
|
bold.innerText = anchorNode.wholeText |
|
|
@ -424,26 +494,20 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
mounted() { |
|
|
|
this.activeName = this.$store.state.read.activeName |
|
|
|
this.activeName = this.$store.state.read.activeName |
|
|
|
for (let n = 0; n < 10; n++) { |
|
|
|
|
|
|
|
this.noteList.push({ |
|
|
|
|
|
|
|
id: `fuck${n}`, |
|
|
|
|
|
|
|
title: `笔记${n}`, |
|
|
|
|
|
|
|
content: `内容${n}` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let that = this |
|
|
|
let that = this |
|
|
|
addEventListener('keyup', function(event) { |
|
|
|
addEventListener('keyup', function(event) { |
|
|
|
//监听查找操作 |
|
|
|
//监听查找操作 |
|
|
|
if (event.shiftKey && 'F' === event.key.toUpperCase()) { |
|
|
|
if (event.shiftKey && 'F' === event.key.toUpperCase()) { |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault() |
|
|
|
that.showSearch = !that.showSearch |
|
|
|
that.showSearch = !that.showSearch |
|
|
|
} else if ('ESCAPE' === event.key.toUpperCase()) { |
|
|
|
} else if ('ESCAPE' === event.key.toUpperCase()) { |
|
|
|
that.showSearch = false |
|
|
|
that.showSearch = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
that.updateFind(that.showSearch) |
|
|
|
}, true) |
|
|
|
}, true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<style> |
|
|
|
<style> |
|
|
@ -459,10 +523,17 @@ |
|
|
|
.choose-search-text { |
|
|
|
.choose-search-text { |
|
|
|
animation: changeshadow 1s ease-in infinite; |
|
|
|
animation: changeshadow 1s ease-in infinite; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@keyframes changeshadow { |
|
|
|
@keyframes changeshadow { |
|
|
|
0%{ text-shadow: 0 0 4px blue} |
|
|
|
0% { |
|
|
|
50%{ text-shadow: 0 0 40px blue} |
|
|
|
text-shadow: 0 0 4px blue |
|
|
|
100%{ text-shadow: 0 0 4px blue} |
|
|
|
} |
|
|
|
|
|
|
|
50% { |
|
|
|
|
|
|
|
text-shadow: 0 0 40px blue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
100% { |
|
|
|
|
|
|
|
text-shadow: 0 0 4px blue |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.choose-note { |
|
|
|
.choose-note { |
|
|
|