Commit 9d0c39a9 authored by 华国豪's avatar 华国豪 🙄

新增收藏

parent a974744f
...@@ -544,7 +544,37 @@ ipc.on('get-face', function(event, keyword) { ...@@ -544,7 +544,37 @@ ipc.on('get-face', function(event, keyword) {
}) })
}) })
req.end() req.end()
})
ipc.on('get-url-info', function (event, url, id) {
let html = "",
list = [],
buffer = null,
newslist = [];
let req = https.request(url, function(res) {
res.on("data", function(data) {
list.push(data)
})
res.on("end", function() {
buffer = Buffer.concat(list)
html = buffer.toString()
let $ = cheerio.load(html)
let src = ""
if ($("img")) {
for (var i = 1; i <= 1; i++) {
$("img").each((index, ele) => {
src = $(ele).attr("data-original-src") ? $(ele).attr("data-original-src") : $(ele).attr("src")
})
}
}
let obj = {
text: $("title").text() ? $("title").text() : url,
img: src ? src : "http://imgfile.oytour.com/New/Upload/Cloud/2019-07/20190719083952562.png",
id: id
}
event.sender.send('show-url-info', obj)
})
})
req.end()
}) })
ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => { ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => {
try { try {
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
import util from "../../../utils"; import util from "../../../utils";
import config from "../../../configs"; import config from "../../../configs";
import emojiObj from "../../../configs/emoji"; import emojiObj from "../../../configs/emoji";
const reg = "(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$" const reg = "^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*([\?&]\w+=\w*)*$"
export default { export default {
props: { props: {
...@@ -336,8 +336,6 @@ export default { ...@@ -336,8 +336,6 @@ export default {
// 收藏 // 收藏
Collection: function(e){ Collection: function(e){
let msg = this.msg let msg = this.msg
console.log(msg)
return
let sendMsg = { let sendMsg = {
PicURL: '', PicURL: '',
URL: '', URL: '',
...@@ -345,16 +343,16 @@ export default { ...@@ -345,16 +343,16 @@ export default {
Content: '', Content: '',
FromUser: '', FromUser: '',
CollectionType: '', CollectionType: '',
FromContent: JSON.stringify(msg)
} }
if (msg.type === 'text') { if (msg.type === 'text') {
// if (reg.test(msg.showText)){ if(/.*[\u4e00-\u9fa5]+.*$/.test(msg.showText)) {
// console.log('yes') sendMsg.CollectionType = 3
// } else { } else if (msg.showText.match(new RegExp(reg,'i'))){
// console.log('no') sendMsg.CollectionType = 1
// } } else {
console.log(msg.showText.match(new RegExp(reg,'i'))) sendMsg.CollectionType = 3
return }
sendMsg.CollectionType = 3
} else if (msg.type === 'image' || msg.type === 'video' || msg.type === 'custom-type1' || msg.type === 'custom-type3') { } else if (msg.type === 'image' || msg.type === 'video' || msg.type === 'custom-type1' || msg.type === 'custom-type3') {
sendMsg.CollectionType = 2 sendMsg.CollectionType = 2
sendMsg.PicURL = msg.type === 'video' ? msg.file.url + '?V10086' : msg.originLink sendMsg.PicURL = msg.type === 'video' ? msg.file.url + '?V10086' : msg.originLink
......
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
} }
},mounted() { },mounted() {
},methods: { },methods: {
} }
...@@ -102,6 +102,8 @@ export default { ...@@ -102,6 +102,8 @@ export default {
} }
.text-row1{ .text-row1{
overflow: hidden; overflow: hidden;
white-space: normal;
word-break: break-all;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 1; -webkit-line-clamp: 1;
......
<template> <template>
<li v-contextmenu:msg-contextmenu @click="preview"> <li v-contextmenu:msg-contextmenu @click="preview">
<v-contextmenu ref="msg-contextmenu"> <v-contextmenu ref="msg-contextmenu">
<v-contextmenu-item @click="">转发</v-contextmenu-item> <v-contextmenu-item @click="forwardMsg">转发</v-contextmenu-item>
<v-contextmenu-item @click="deleteCollection(item.ID)">删除</v-contextmenu-item> <v-contextmenu-item @click="deleteCollection(item.ID)">删除</v-contextmenu-item>
</v-contextmenu> </v-contextmenu>
<el-row class="item" :gutter="30"> <el-row class="item" :gutter="30">
...@@ -12,16 +12,22 @@ ...@@ -12,16 +12,22 @@
<div class="file" v-if="item.CollectionType === 4"> <div class="file" v-if="item.CollectionType === 4">
<div class="fileIcon" :class="[item.Title]"></div> <div class="fileIcon" :class="[item.Title]"></div>
<div> <div>
<el-tooltip class="item" effect="dark" :content="item.Content" placement="top"> <el-tooltip popper-class="tooltip-item" effect="dark" :content="item.Content" placement="top">
<p class="text-row1 file-name">{{item.Content}}</p> <p class="text-row1 file-name">{{item.Content}}</p>
</el-tooltip> </el-tooltip>
<!-- <p>56.8K</p> --> <!-- <p>56.8K</p> -->
</div> </div>
</div> </div>
<div class="file" v-if="item.CollectionType === 3"> <div class="file" v-if="item.CollectionType === 3 || item.CollectionType === 1">
<div class="images" style="margin-right: 10px" v-if="item.CollectionType === 1">
<img :src="addrObj.img" alt="">
</div>
<div> <div>
<el-tooltip class="item" effect="dark" :content="item.Content" placement="top"> <el-tooltip popper-class="tooltip-item" effect="dark" :content="item.Content" placement="top">
<p class="text-row1 file-name">{{item.Content}}</p> <p v-if="item.CollectionType !== 1" class="text-row1 file-name">{{item.Content}}</p>
</el-tooltip>
<el-tooltip popper-class="tooltip-item" effect="dark" :content="addrObj.text" placement="top">
<p v-if="item.CollectionType === 1" class="text-row1 file-name">{{addrObj.text}}</p>
</el-tooltip> </el-tooltip>
</div> </div>
</div> </div>
...@@ -46,31 +52,56 @@ export default { ...@@ -46,31 +52,56 @@ export default {
data(){ data(){
return{ return{
url: '', url: '',
imgUrl: '' imgUrl: '',
addrObj: {
text: '',
img: '',
id: 0
},
}
}, watch: {
item(newVal, oldVal) {
console.log(newVal)
this.setData()
} }
},mounted() { },mounted() {
if (this.item.CollectionType === 2) { this.setData()
let url = this.item.PicURL },
this.imgUrl = '' methods: {
let _this = this setData: function (){
if (url.indexOf('V10086') !== -1){ if (this.item.CollectionType === 2) {
console.log('这是一个视频文件', url) let url = this.item.PicURL
this.url = url this.imgUrl = ''
let scale = 0.8 let _this = this
setTimeout(()=>{ if (url.indexOf('V10086') !== -1){
let video = document.getElementById("video"); this.url = url
var canvas = document.createElement("canvas");//创建一个canvas let scale = 0.8
canvas.width = video.videoWidth * scale;//设置canvas的宽度为视频的宽度 setTimeout(()=>{
canvas.height = video.videoHeight * scale;//设置canvas的高度为视频的高度 let video = document.getElementById("video");
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);//绘制图像 var canvas = document.createElement("canvas");//创建一个canvas
_this.imgUrl = canvas.toDataURL("image/png");//将绘制的图像用img显示出来 canvas.width = video.videoWidth * scale;//设置canvas的宽度为视频的宽度
}, 500) canvas.height = video.videoHeight * scale;//设置canvas的高度为视频的高度
// video.addEventListener('loadeddata', ); canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);//绘制图像
} else { _this.imgUrl = canvas.toDataURL("image/png");//将绘制的图像用img显示出来
this.imgUrl = this.item.PicURL }, 500)
} else {
this.imgUrl = this.item.PicURL
}
} else if (this.item.CollectionType === 1) {
this.$electron.ipcRenderer.send("get-url-info", this.item.Content, this.item.ID)
this.$electron.ipcRenderer.on('show-url-info', (event, html) => {
if(html.id === this.item.ID) {
this.addrObj = html
this.$forceUpdate()
}
})
} }
} },
},methods: { // 转发
forwardMsg: function(){
let msg = JSON.parse(this.item.FromContent)
this.MsgBus.$emit("forward",msg);
},
// 预览 // 预览
preview: function () { preview: function () {
let url = this.item.PicURL let url = this.item.PicURL
...@@ -89,6 +120,9 @@ export default { ...@@ -89,6 +120,9 @@ export default {
openUrl = `http://reborn.oytour.com/plug/pdf/web/viewer.html?file=${url}`; openUrl = `http://reborn.oytour.com/plug/pdf/web/viewer.html?file=${url}`;
} }
this.$electron.ipcRenderer.send("openPreviwerfile", openUrl); this.$electron.ipcRenderer.send("openPreviwerfile", openUrl);
} else if (this.item.CollectionType === 1) { //网址
let url = this.item.Content;
this.$electron.ipcRenderer.send("openUrl", url);
} }
}, },
// 删除 // 删除
...@@ -102,11 +136,15 @@ export default { ...@@ -102,11 +136,15 @@ export default {
} }
}, err => {}) }, err => {})
} }
}, beforeDestroy() {
// 重复图片问题解决方案
// 事件处理中心msgBus,vue页面销毁后,原先的监听事件并没有销毁,导致组件再次载入的时候会重复相同的事件监听,所以当组件销毁时同时需要在 beforeDestroy 钩子中销毁对应的事件监听!!!
this.$electron.ipcRenderer.removeAllListeners(['show-url-info'])
} }
} }
</script> </script>
<style scoped> <style>
#video{ #video{
position: absolute; position: absolute;
left: -999px; left: -999px;
...@@ -116,4 +154,7 @@ export default { ...@@ -116,4 +154,7 @@ export default {
width: 60px; width: 60px;
height: 60px; height: 60px;
} }
.tooltip-item{
max-width: 300px;
}
</style> </style>
\ No newline at end of file
...@@ -60,7 +60,6 @@ export default { ...@@ -60,7 +60,6 @@ export default {
this.loading = true this.loading = true
this.apipost("user_post_GetCollectionList", {}, res => { this.apipost("user_post_GetCollectionList", {}, res => {
if (res.data.resultCode === 1) { if (res.data.resultCode === 1) {
console.log(res.data.data)
this.showData = res.data.data this.showData = res.data.data
this.dataList = res.data.data this.dataList = res.data.data
} else { } else {
...@@ -71,6 +70,7 @@ export default { ...@@ -71,6 +70,7 @@ export default {
}, },
// 改变收藏类型 // 改变收藏类型
changeType: function (id){ changeType: function (id){
this.showData = []
this.activeID = id; this.activeID = id;
if (id === 0) { if (id === 0) {
this.showData = this.dataList this.showData = this.dataList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment