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

新增表情包

parent 0f8b0000
...@@ -11,6 +11,8 @@ const electron = require('electron') ...@@ -11,6 +11,8 @@ const electron = require('electron')
const screenshot = require('screenshot-desktop') const screenshot = require('screenshot-desktop')
const SDK = require('../../static/sdk/NIM_Web_SDK_nodejs_v6.9.0.js') const SDK = require('../../static/sdk/NIM_Web_SDK_nodejs_v6.9.0.js')
const http = require('http') const http = require('http')
const https = require('https')
const cheerio = require("cheerio")
// const unhandled = require('electron-unhandled'); // const unhandled = require('electron-unhandled');
// unhandled(); // unhandled();
...@@ -68,6 +70,7 @@ let messageProtocol = null ...@@ -68,6 +70,7 @@ let messageProtocol = null
let CAP_IMG = '' let CAP_IMG = ''
let nim = null let nim = null
let SCREENCOUNT = 0 let SCREENCOUNT = 0
global.defaultdownloaddir = require('os').userInfo().homedir + '\\Downloads\\' global.defaultdownloaddir = require('os').userInfo().homedir + '\\Downloads\\'
global.DEFAULT_SCREENSHOT_PATH = require('os').userInfo().homedir + '\\Pictures\\demo.png' global.DEFAULT_SCREENSHOT_PATH = require('os').userInfo().homedir + '\\Pictures\\demo.png'
global.AUDIO_PATH = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) global.AUDIO_PATH = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)
...@@ -519,6 +522,30 @@ ipc.on('create-message-session', function(event) { ...@@ -519,6 +522,30 @@ ipc.on('create-message-session', function(event) {
}, 3000) }, 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) => { ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => {
try { try {
downloadpath = pdownloadpath downloadpath = pdownloadpath
...@@ -955,7 +982,6 @@ let getNoticeWindows = function() { ...@@ -955,7 +982,6 @@ let getNoticeWindows = function() {
width: 300, width: 300,
height: 115, height: 115,
skipTaskbar: true, skipTaskbar: true,
alwaysOnTop: false,
focusable: false focusable: false
}) })
noticeWindows.setBounds({ noticeWindows.setBounds({
...@@ -966,7 +992,8 @@ let getNoticeWindows = function() { ...@@ -966,7 +992,8 @@ let getNoticeWindows = function() {
}) })
} }
noticeWindows.loadURL(noticeUrl) noticeWindows.loadURL(noticeUrl)
mainWindow.setFocusable(true) //mainWindow.setFocusable(true)
noticeWindows.setFocusable(false)
noticeWindows.setMenu(null) noticeWindows.setMenu(null)
noticeWindows.once('ready-to-show', () => { noticeWindows.once('ready-to-show', () => {
noticeWindows.show() noticeWindows.show()
......
import md5 from 'js-md5' import md5 from 'js-md5'
import MsgBus from './msgBus' import MsgBus from './msgBus'
export default { export default {
install (Vue, options) { install(Vue, options) {
Vue.prototype.MsgBus = MsgBus; Vue.prototype.MsgBus = MsgBus;
Vue.prototype.GLOBALSENDING = []; Vue.prototype.GLOBALSENDING = [];
Vue.prototype.TOPSESSION = []; Vue.prototype.TOPSESSION = [];
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
return process.env.NODE_ENV !== 'development'; return process.env.NODE_ENV !== 'development';
} }
Vue.prototype.domainManager = function() { Vue.prototype.domainManager = function() {
var domainUrl = "http://reborn.oytour.com";//主域名 var domainUrl = "http://reborn.oytour.com"; //主域名
if (this.isOnline()) { if (this.isOnline()) {
domainUrl = "http://reborn.oytour.com"; domainUrl = "http://reborn.oytour.com";
} }
...@@ -37,27 +37,27 @@ export default { ...@@ -37,27 +37,27 @@ export default {
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd = $ {cmd} & msg = $ {encodeMsg} & timestamp = $ {timestamp} & token = $ {token} & key = $ {key}`); var md5Str = md5(`cmd = $ {cmd} & msg = $ {encodeMsg} & timestamp = $ {timestamp} & token = $ {token} & key = $ {key}`);
var postData = { var postData = {
"msg":msg, "msg": msg,
"cmd":cmd, "cmd": cmd,
"timestamp":timestamp, "timestamp": timestamp,
"token":token, "token": token,
"sign":md5Str "sign": md5Str
} }
this.$http.post(apiurl, postData, { this.$http.post(apiurl, postData, {
headers: { headers: {
'Content-Type':'application/json', 'Content-Type': 'application/json',
'Referer-Viitto':this.$route.path 'Referer-Viitto': this.$route.path
}, },
timeout:1000*15 timeout: 1000 * 15
}) })
.then(res => { .then(res => {
if (res.resultCode == 10000 || res.resultCode == 10001) { if (res.resultCode == 10000 || res.resultCode == 10001) {
this.$router.push( { this.$router.push({
path:'/login' path: '/login'
}) })
}else if (res.resultCode == 10005) { } else if (res.resultCode == 10005) {
this.$router.go(-1) this.$router.go(-1)
}else { } else {
successCall(res) successCall(res)
} }
}, faildCall) }, faildCall)
...@@ -68,24 +68,30 @@ export default { ...@@ -68,24 +68,30 @@ export default {
} }
this.$http.post(path, msg, { this.$http.post(path, msg, {
headers: { headers: {
'Content-Type':'application/json' 'Content-Type': 'application/json'
} }
}) })
.then(res => { .then(res => {
successCall(res) successCall(res)
}, faildCall) }, faildCall)
} }
Vue.prototype.getLocalStorage = function () { Vue.prototype.getNetRequest = function(url, successCall, faildCall) {
this.$http.post(url)
.then(res => {
successCall(res)
}, faildCall)
}
Vue.prototype.getLocalStorage = function() {
var localStorageData = window.localStorage["userInfo"]; var localStorageData = window.localStorage["userInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') { if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData); return JSON.parse(localStorageData);
}else { } else {
return null; return null;
} }
} }
Vue.prototype.loadFileICON = function (suffix,size) { Vue.prototype.loadFileICON = function(suffix, size) {
size=size?size:1 size = size ? size : 1
let icons = [{ let icons = [{
"name": "\u7f51\u76d8BT\u79bb\u7ebf\u4e0b\u8f7d", "name": "\u7f51\u76d8BT\u79bb\u7ebf\u4e0b\u8f7d",
......
...@@ -102,7 +102,6 @@ export default { ...@@ -102,7 +102,6 @@ export default {
}; };
}, },
mounted() { mounted() {
console.log(this.$electron.remote.getGlobal("LOGINUSER"))
const updateOnlineStatus = () => { const updateOnlineStatus = () => {
if(navigator.onLine && this.isdissconnection){ if(navigator.onLine && this.isdissconnection){
this.isdissconnection=false this.isdissconnection=false
...@@ -199,6 +198,7 @@ export default { ...@@ -199,6 +198,7 @@ export default {
that.MsgBus.$emit("close-copy") that.MsgBus.$emit("close-copy")
that.MsgBus.$emit("hide-this-winShow") that.MsgBus.$emit("hide-this-winShow")
}); });
}, },
methods: { methods: {
reconnect(){ reconnect(){
...@@ -245,7 +245,6 @@ export default { ...@@ -245,7 +245,6 @@ export default {
}, },
computed: { computed: {
netState(){ netState(){
return this.$store.state.isNetError return this.$store.state.isNetError
} }
} }
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
v-on:add-emoji="addEmoji" v-on:add-emoji="addEmoji"
v-on:hide-emoji="hideEmoji" v-on:hide-emoji="hideEmoji"
></chat-emoji> ></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 id="dirtyData" style="display:none"></div>
</div> </div>
</template> </template>
...@@ -61,10 +62,12 @@ import BMF from "browser-md5-file"; ...@@ -61,10 +62,12 @@ import BMF from "browser-md5-file";
import kscreenshot from "kscreenshot"; import kscreenshot from "kscreenshot";
import contentEditor from "../tools/contenteditor"; import contentEditor from "../tools/contenteditor";
import pageUtil from "../../../utils/page"; import pageUtil from "../../../utils/page";
import NetWorkFace from './networkFace'
export default { export default {
components: { components: {
ChatEmoji, ChatEmoji,
contentEditor contentEditor,
NetWorkFace
}, },
updated() { updated() {
window.document.body.addEventListener("click", () => { window.document.body.addEventListener("click", () => {
...@@ -106,6 +109,9 @@ export default { ...@@ -106,6 +109,9 @@ export default {
} }
that.MsgBus.$emit("update-sending"); that.MsgBus.$emit("update-sending");
}); });
this.$electron.ipcRenderer.on('show-network-face', (event,faces) => {
that.faces=faces
})
}, },
props: { props: {
type: String, type: String,
...@@ -160,6 +166,11 @@ export default { ...@@ -160,6 +166,11 @@ export default {
inputObj: { inputObj: {
handler(val, oldVal) { handler(val, oldVal) {
this.msgToSent = val.txt; 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 deep: true
} }
...@@ -183,6 +194,8 @@ export default { ...@@ -183,6 +194,8 @@ export default {
top: 0, top: 0,
left: 0, left: 0,
hideThisWinShow: false, hideThisWinShow: false,
faces:[],
}; };
}, },
computed: { computed: {
...@@ -209,6 +222,16 @@ export default { ...@@ -209,6 +222,16 @@ export default {
} }
}, },
methods: { 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(){ setWinActive(){
this.hideThisWinActive = this.hideThisWinActive == '1' ? '' : '1'; this.hideThisWinActive = this.hideThisWinActive == '1' ? '' : '1';
window.localStorage.hideThisWinActive = this.hideThisWinActive window.localStorage.hideThisWinActive = this.hideThisWinActive
......
...@@ -516,7 +516,6 @@ export default { ...@@ -516,7 +516,6 @@ export default {
item.emojiCnt = emojiCnt item.emojiCnt = emojiCnt
item.type = "custom-type4"; item.type = "custom-type4";
} else { } else {
console.log(item)
this.formatCustom(item); this.formatCustom(item);
item.showText = util.parseCustomMsg(item); item.showText = util.parseCustomMsg(item);
if (item.showText == "[自定义消息]") { if (item.showText == "[自定义消息]") {
...@@ -539,7 +538,14 @@ export default { ...@@ -539,7 +538,14 @@ export default {
} else if (item.type === "file") { } else if (item.type === "file") {
item.fileLink = item.file.url; item.fileLink = item.file.url;
item.showText = item.file.name; item.showText = item.file.name;
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); this.formatFile(item);
}
} else if (item.type === "notification") { } else if (item.type === "notification") {
if (item.scene === "team") { if (item.scene === "team") {
item.showText = util.generateTeamSysmMsg(item); item.showText = util.generateTeamSysmMsg(item);
...@@ -619,6 +625,7 @@ export default { ...@@ -619,6 +625,7 @@ export default {
return result; return result;
}, },
formatCustom(item) { formatCustom(item) {
console.log(item)
if (item.content) { if (item.content) {
item.customData = JSON.parse(item.content).data; item.customData = JSON.parse(item.content).data;
...@@ -629,6 +636,15 @@ export default { ...@@ -629,6 +636,15 @@ export default {
ext: item.customData.content.fileName, ext: item.customData.content.fileName,
name: 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 { } else {
if (item.customData.content.fileName) { if (item.customData.content.fileName) {
let exts = item.customData.content.fileName.split("."); let exts = item.customData.content.fileName.split(".");
......
...@@ -655,7 +655,7 @@ export default { ...@@ -655,7 +655,7 @@ export default {
if (item.to == "684cb79fe92f46888888") { if (item.to == "684cb79fe92f46888888") {
if(this.noticeLastTime<item.lastMsg.time){ if(this.noticeLastTime<item.lastMsg.time){
this.noticeLastTime=item.lastMsg.time this.noticeLastTime=item.lastMsg.time
this.showNotice() //this.showNotice()
} }
this.noticeObj = item; this.noticeObj = item;
return; return;
...@@ -677,7 +677,7 @@ export default { ...@@ -677,7 +677,7 @@ export default {
} }
}); });
if (item.unread > 0 && !item.isMute) { 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.dou();
this.enterChat(item); 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