Commit 4b4dd98a authored by 罗超's avatar 罗超

新增表情包

parent 0f8b0000
......@@ -11,6 +11,8 @@ const electron = require('electron')
const screenshot = require('screenshot-desktop')
const SDK = require('../../static/sdk/NIM_Web_SDK_nodejs_v6.9.0.js')
const http = require('http')
const https = require('https')
const cheerio = require("cheerio")
// const unhandled = require('electron-unhandled');
// unhandled();
......@@ -68,6 +70,7 @@ let messageProtocol = null
let CAP_IMG = ''
let nim = null
let SCREENCOUNT = 0
global.defaultdownloaddir = require('os').userInfo().homedir + '\\Downloads\\'
global.DEFAULT_SCREENSHOT_PATH = require('os').userInfo().homedir + '\\Pictures\\demo.png'
global.AUDIO_PATH = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)
......@@ -519,6 +522,30 @@ ipc.on('create-message-session', function(event) {
}, 3000)
}
})
ipc.on('get-face', function(event, keyword) {
let html = "",
list = [],
buffer = null,
newslist = [];
let req = https.request("https://www.doutula.com/search?keyword=" + keyword, 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)
for (var i = 1; i <= 3; i++) {
$("img[referrerpolicy='no-referrer']").each((index, ele) => {
newslist.push($(ele).attr("data-original"))
})
}
event.sender.send('show-network-face', newslist)
})
})
req.end()
})
ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => {
try {
downloadpath = pdownloadpath
......@@ -955,7 +982,6 @@ let getNoticeWindows = function() {
width: 300,
height: 115,
skipTaskbar: true,
alwaysOnTop: false,
focusable: false
})
noticeWindows.setBounds({
......@@ -966,7 +992,8 @@ let getNoticeWindows = function() {
})
}
noticeWindows.loadURL(noticeUrl)
mainWindow.setFocusable(true)
//mainWindow.setFocusable(true)
noticeWindows.setFocusable(false)
noticeWindows.setMenu(null)
noticeWindows.once('ready-to-show', () => {
noticeWindows.show()
......
This diff is collapsed.
......@@ -102,7 +102,6 @@ export default {
};
},
mounted() {
console.log(this.$electron.remote.getGlobal("LOGINUSER"))
const updateOnlineStatus = () => {
if(navigator.onLine && this.isdissconnection){
this.isdissconnection=false
......@@ -199,6 +198,7 @@ export default {
that.MsgBus.$emit("close-copy")
that.MsgBus.$emit("hide-this-winShow")
});
},
methods: {
reconnect(){
......@@ -245,7 +245,6 @@ export default {
},
computed: {
netState(){
return this.$store.state.isNetError
}
}
......
......@@ -49,6 +49,7 @@
v-on:add-emoji="addEmoji"
v-on:hide-emoji="hideEmoji"
></chat-emoji>
<net-work-face v-if='faces && faces.length>0' :faces="faces" @close-face="closeNetworkFace" :scene=scene :to=to></net-work-face>
<div id="dirtyData" style="display:none"></div>
</div>
</template>
......@@ -61,10 +62,12 @@ import BMF from "browser-md5-file";
import kscreenshot from "kscreenshot";
import contentEditor from "../tools/contenteditor";
import pageUtil from "../../../utils/page";
import NetWorkFace from './networkFace'
export default {
components: {
ChatEmoji,
contentEditor
contentEditor,
NetWorkFace
},
updated() {
window.document.body.addEventListener("click", () => {
......@@ -106,6 +109,9 @@ export default {
}
that.MsgBus.$emit("update-sending");
});
this.$electron.ipcRenderer.on('show-network-face', (event,faces) => {
that.faces=faces
})
},
props: {
type: String,
......@@ -160,6 +166,11 @@ export default {
inputObj: {
handler(val, oldVal) {
this.msgToSent = val.txt;
if(val.txt.length>0 && val.txt.length<5){
this.getNetworkFace()
}else if(val.txt.length==0){
this.faces=[]
}
},
deep: true
}
......@@ -183,6 +194,8 @@ export default {
top: 0,
left: 0,
hideThisWinShow: false,
faces:[],
};
},
computed: {
......@@ -209,6 +222,16 @@ export default {
}
},
methods: {
closeNetworkFace(t){
this.faces=[]
if(t==1){
this.$refs.editor.clearContent();
}
},
getNetworkFace(){
this.faces=[]
this.$electron.ipcRenderer.send('get-face',encodeURIComponent(this.msgToSent));
},
setWinActive(){
this.hideThisWinActive = this.hideThisWinActive == '1' ? '' : '1';
window.localStorage.hideThisWinActive = this.hideThisWinActive
......
......@@ -516,7 +516,6 @@ export default {
item.emojiCnt = emojiCnt
item.type = "custom-type4";
} else {
console.log(item)
this.formatCustom(item);
item.showText = util.parseCustomMsg(item);
if (item.showText == "[自定义消息]") {
......@@ -539,7 +538,14 @@ export default {
} else if (item.type === "file") {
item.fileLink = item.file.url;
item.showText = item.file.name;
this.formatFile(item);
if(item.file.name.indexOf('.png')!=-1||item.file.name.indexOf('.gif')!=-1||item.file.name.indexOf('.jpg')!=-1)
{
item.type="image";
item.originLink = item.file.url;
this.$electron.ipcRenderer.send("addPrevImgs", item.file.url);
}else{
this.formatFile(item);
}
} else if (item.type === "notification") {
if (item.scene === "team") {
item.showText = util.generateTeamSysmMsg(item);
......@@ -619,6 +625,7 @@ export default {
return result;
},
formatCustom(item) {
console.log(item)
if (item.content) {
item.customData = JSON.parse(item.content).data;
......@@ -629,6 +636,15 @@ export default {
ext: item.customData.content.fileName,
name: item.customData.content.fileName
};
} else if (/(.png|.gif|.jpg|.bmp)/i.test(item.customData.content.fileName)) {
item.type = "image";
item.originLink = item.customData.content.fileUrl;
item.file = {
url: item.customData.content.fileUrl,
ext: item.customData.content.fileName,
name: item.customData.content.fileName
};
this.$electron.ipcRenderer.send("addPrevImgs", item.customData.content.fileUrl);
} else {
if (item.customData.content.fileName) {
let exts = item.customData.content.fileName.split(".");
......
......@@ -655,7 +655,7 @@ export default {
if (item.to == "684cb79fe92f46888888") {
if(this.noticeLastTime<item.lastMsg.time){
this.noticeLastTime=item.lastMsg.time
this.showNotice()
//this.showNotice()
}
this.noticeObj = item;
return;
......@@ -677,7 +677,7 @@ export default {
}
});
if (item.unread > 0 && !item.isMute) {
if (item.lastMsg.tip && item.lastMsg.tip.indexOf("抖了一下") != -1) {
if (item.lastMsg && item.lastMsg.tip && item.lastMsg.tip.indexOf("抖了一下") != -1) {
this.dou();
this.enterChat(item);
}
......
<template>
<div class="net-work-face" @mouseover="clearTime" @mouseout="addTime">
<div class="arrow" :class="{'dis':index==0}" @click="changePage(-1)">
<i class="el-icon-arrow-left"></i>
</div>
<div class="face-content">
<template v-for="(item, index) in showFaces">
<img :src="item" :key="index" @click="sendFace(item)" />
</template>
</div>
<div class="arrow" :class="{'dis':index==maxPage-1}" @click="changePage(1)">
<i class="el-icon-arrow-right"></i>
</div>
</div>
</template>
<script>
export default {
props: {
faces: {
type: Array,
default: []
},
scene: {
type: String,
default: ""
},
to: {
type: String,
default: ""
}
},
data() {
return {
showFaces: [],
index: 0,
maxPage: 0,
timer: null
};
},
mounted() {
this.maxPage = Math.ceil(this.faces.length / 6);
this.init();
},
methods: {
clearTime() {
clearTimeout(this.timer);
},
addTime() {
this.timer = setTimeout(() => {
this.close(0);
}, 1000 * 5);
},
init() {
if (this.index >= 0 && this.index < this.maxPage) {
this.showFaces = [];
for (let i = this.index * 6; i < this.index * 6 + 6; i++) {
this.showFaces.push(this.faces[i]);
}
}
},
changePage(i) {
let t = this.index + i;
if (t < 0 || t > this.maxPage - 1) return;
this.index = t;
this.init();
},
close(t) {
this.$emit("close-face",t);
},
sendFace(url) {
let t = url.split("/");
let fileName = t[t.length - 1];
this.$store.dispatch("sendMsg", {
type: "custom",
scene: this.scene,
to: this.to,
pushContent: "表情消息",
content: {
msgtype: "custom_file",
data: {
pushContent: "表情消息",
Height: "84",
content: {
fileType: "image",
fileUrl: url,
fileName: fileName,
fileSize: "230KB"
},
recentContent: fileName,
Width: "210"
}
}
});
this.close(1)
}
}
};
</script>
<style scoped>
.net-work-face {
position: absolute;
left: 10px;
top: -90px;
/* right: 0; */
/* border-top: 1px solid #eee; */
/* border-bottom: 1px solid #ccc; */
background-color: #fff;
z-index: 2017;
width: 482px;
height: 82px;
box-shadow: 0 0 5px #ccc;
border-radius: 2px;
display: flex;
}
.net-work-face .arrow {
width: 20px;
text-align: center;
line-height: 82px;
font-size: 14px;
color: #666;
cursor: pointer;
}
.net-work-face .arrow.dis {
color: #bbb;
cursor: no-drop;
}
.net-work-face .face-content {
display: flex;
flex: 1;
padding-top: 5px;
justify-content: space-between;
}
.net-work-face .face-content img {
width: 70px;
height: 70px;
cursor: pointer;
}
.net-work-face .face-content img:hover {
outline: 1px solid #ccc;
}
</style>
\ No newline at end of file
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