Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Madara
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
Madara
Commits
9d0c39a9
Commit
9d0c39a9
authored
Oct 15, 2019
by
华国豪
🙄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增收藏
parent
a974744f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
42 deletions
+113
-42
index.js
src/main/index.js
+31
-1
chatitem.vue
src/renderer/components/msssage/chatitem.vue
+9
-11
CollectionContentList.vue
src/renderer/components/team/CollectionContentList.vue
+3
-1
CollectionContentListItem.vue
src/renderer/components/team/CollectionContentListItem.vue
+69
-28
Collection.vue
src/renderer/components/tools/Collection.vue
+1
-1
No files found.
src/main/index.js
View file @
9d0c39a9
...
...
@@ -544,7 +544,37 @@ ipc.on('get-face', function(event, keyword) {
})
})
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) => {
try {
...
...
src/renderer/components/msssage/chatitem.vue
View file @
9d0c39a9
...
...
@@ -203,7 +203,7 @@
import
util
from
"../../../utils"
;
import
config
from
"../../../configs"
;
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
{
props
:
{
...
...
@@ -336,8 +336,6 @@ export default {
// 收藏
Collection
:
function
(
e
){
let
msg
=
this
.
msg
console
.
log
(
msg
)
return
let
sendMsg
=
{
PicURL
:
''
,
URL
:
''
,
...
...
@@ -345,16 +343,16 @@ export default {
Content
:
''
,
FromUser
:
''
,
CollectionType
:
''
,
FromContent
:
JSON
.
stringify
(
msg
)
}
if
(
msg
.
type
===
'text'
)
{
// if (reg.test(msg.showText)){
// console.log('yes')
// } else {
// console.log('no')
// }
console
.
log
(
msg
.
showText
.
match
(
new
RegExp
(
reg
,
'i'
)))
return
sendMsg
.
CollectionType
=
3
if
(
/.*
[\u
4e00-
\u
9fa5
]
+.*$/
.
test
(
msg
.
showText
))
{
sendMsg
.
CollectionType
=
3
}
else
if
(
msg
.
showText
.
match
(
new
RegExp
(
reg
,
'i'
))){
sendMsg
.
CollectionType
=
1
}
else
{
sendMsg
.
CollectionType
=
3
}
}
else
if
(
msg
.
type
===
'image'
||
msg
.
type
===
'video'
||
msg
.
type
===
'custom-type1'
||
msg
.
type
===
'custom-type3'
)
{
sendMsg
.
CollectionType
=
2
sendMsg
.
PicURL
=
msg
.
type
===
'video'
?
msg
.
file
.
url
+
'?V10086'
:
msg
.
originLink
...
...
src/renderer/components/team/CollectionContentList.vue
View file @
9d0c39a9
...
...
@@ -29,7 +29,7 @@ export default {
}
},
mounted
()
{
},
methods
:
{
}
...
...
@@ -102,6 +102,8 @@ export default {
}
.text-row1
{
overflow
:
hidden
;
white-space
:
normal
;
word-break
:
break-all
;
text-overflow
:
ellipsis
;
display
:
-webkit-box
;
-webkit-line-clamp
:
1
;
...
...
src/renderer/components/team/CollectionContentListItem.vue
View file @
9d0c39a9
<
template
>
<li
v-contextmenu:msg-contextmenu
@
click=
"preview"
>
<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>
<el-row
class=
"item"
:gutter=
"30"
>
...
...
@@ -12,16 +12,22 @@
<div
class=
"file"
v-if=
"item.CollectionType === 4"
>
<div
class=
"fileIcon"
:class=
"[item.Title]"
></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>
</el-tooltip>
<!--
<p>
56.8K
</p>
-->
</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>
<el-tooltip
class=
"item"
effect=
"dark"
:content=
"item.Content"
placement=
"top"
>
<p
class=
"text-row1 file-name"
>
{{
item
.
Content
}}
</p>
<el-tooltip
popper-class=
"tooltip-item"
effect=
"dark"
:content=
"item.Content"
placement=
"top"
>
<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>
</div>
</div>
...
...
@@ -46,31 +52,56 @@ export default {
data
(){
return
{
url
:
''
,
imgUrl
:
''
imgUrl
:
''
,
addrObj
:
{
text
:
''
,
img
:
''
,
id
:
0
},
}
},
watch
:
{
item
(
newVal
,
oldVal
)
{
console
.
log
(
newVal
)
this
.
setData
()
}
},
mounted
()
{
if
(
this
.
item
.
CollectionType
===
2
)
{
let
url
=
this
.
item
.
PicURL
this
.
imgUrl
=
''
let
_this
=
this
if
(
url
.
indexOf
(
'V10086'
)
!==
-
1
){
console
.
log
(
'这是一个视频文件'
,
url
)
this
.
url
=
url
let
scale
=
0.8
setTimeout
(()
=>
{
let
video
=
document
.
getElementById
(
"video"
);
var
canvas
=
document
.
createElement
(
"canvas"
);
//创建一个canvas
canvas
.
width
=
video
.
videoWidth
*
scale
;
//设置canvas的宽度为视频的宽度
canvas
.
height
=
video
.
videoHeight
*
scale
;
//设置canvas的高度为视频的高度
canvas
.
getContext
(
'2d'
).
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
//绘制图像
_this
.
imgUrl
=
canvas
.
toDataURL
(
"image/png"
);
//将绘制的图像用img显示出来
},
500
)
// video.addEventListener('loadeddata', );
}
else
{
this
.
imgUrl
=
this
.
item
.
PicURL
this
.
setData
()
},
methods
:
{
setData
:
function
(){
if
(
this
.
item
.
CollectionType
===
2
)
{
let
url
=
this
.
item
.
PicURL
this
.
imgUrl
=
''
let
_this
=
this
if
(
url
.
indexOf
(
'V10086'
)
!==
-
1
){
this
.
url
=
url
let
scale
=
0.8
setTimeout
(()
=>
{
let
video
=
document
.
getElementById
(
"video"
);
var
canvas
=
document
.
createElement
(
"canvas"
);
//创建一个canvas
canvas
.
width
=
video
.
videoWidth
*
scale
;
//设置canvas的宽度为视频的宽度
canvas
.
height
=
video
.
videoHeight
*
scale
;
//设置canvas的高度为视频的高度
canvas
.
getContext
(
'2d'
).
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
//绘制图像
_this
.
imgUrl
=
canvas
.
toDataURL
(
"image/png"
);
//将绘制的图像用img显示出来
},
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
()
{
let
url
=
this
.
item
.
PicURL
...
...
@@ -89,6 +120,9 @@ export default {
openUrl
=
`http://reborn.oytour.com/plug/pdf/web/viewer.html?file=
${
url
}
`
;
}
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 {
}
},
err
=>
{})
}
},
beforeDestroy
()
{
// 重复图片问题解决方案
// 事件处理中心msgBus,vue页面销毁后,原先的监听事件并没有销毁,导致组件再次载入的时候会重复相同的事件监听,所以当组件销毁时同时需要在 beforeDestroy 钩子中销毁对应的事件监听!!!
this
.
$electron
.
ipcRenderer
.
removeAllListeners
([
'show-url-info'
])
}
}
</
script
>
<
style
scoped
>
<
style
>
#video
{
position
:
absolute
;
left
:
-999px
;
...
...
@@ -116,4 +154,7 @@ export default {
width
:
60px
;
height
:
60px
;
}
.tooltip-item
{
max-width
:
300px
;
}
</
style
>
\ No newline at end of file
src/renderer/components/tools/Collection.vue
View file @
9d0c39a9
...
...
@@ -60,7 +60,6 @@ export default {
this
.
loading
=
true
this
.
apipost
(
"user_post_GetCollectionList"
,
{},
res
=>
{
if
(
res
.
data
.
resultCode
===
1
)
{
console
.
log
(
res
.
data
.
data
)
this
.
showData
=
res
.
data
.
data
this
.
dataList
=
res
.
data
.
data
}
else
{
...
...
@@ -71,6 +70,7 @@ export default {
},
// 改变收藏类型
changeType
:
function
(
id
){
this
.
showData
=
[]
this
.
activeID
=
id
;
if
(
id
===
0
)
{
this
.
showData
=
this
.
dataList
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment