const { ipcRenderer } = require("electron"); class Index { constructor() { this.color = ""; this.size = "13px"; this.UserInfo = JSON.parse(localStorage.getItem("userInfo")); this.socket = io("ws://127.0.0.1:3000"); // console.log(this.socket); this.socketEmit() this.bindEvent() } socketEmit() { this.socket.emit("UserLogin", this.UserInfo) this.socket.emit("getOnlineUser", this.UserInfo) this.socket.on("PushMessage", (arg) => { this.sendMessage(arg, "") }) this.socket.on("PushShake", (arg) => { ipcRenderer.send("startShake") }) this.socket.on("PushOnlineUser", (arg) => { $(".content_right .title").text(`群成员 ${arg.length}`) $(".content_right ul").empty() arg.forEach(v => { $(".content_right ul").append(`
`)
}
$(".gif img").click(function() {
$(".footer_input").append($(this).clone())
})
$(".smiling img").hover(
function() {
$(this).attr({
src: `./img/icon/${$(this).index()}@2x.gif`
})
},
function() {
$(this).attr({
src: `./img/icon/${$(this).index()}fix@2x.png`
})
}
);
$(".smiling img").click(function() {
$(".footer_input").append($(this).clone())
});
$(".footer_menu .aaa").click(function() {
if ($(".menu_footer li").eq($(this).index()).hasClass("active")) {
$(".footer_topmenu").hide()
$(".menu_footer li").eq($(this).index()).removeClass("active")
} else {
$(".footer_topmenu").show()
$(".menu_footer li").eq($(this).index()).click()
}
})
$(".font input").on("input", function () {
self.color = $(this).val()
})
$(".font select").on("change", function () {
self.size = $(this).val()
})
$(".icon-shake").click(function () {
self.socket.emit("SetShake", self.UserInfo)
})
}
sendMessage(data,type = "right") {
$(".content_left").append(`