Skip to content

Commit

Permalink
bye~ xiaoIce
Browse files Browse the repository at this point in the history
  • Loading branch information
HereIsYui committed Jun 14, 2024
1 parent f3c8339 commit 39759c2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 137 deletions.
99 changes: 0 additions & 99 deletions src/main/resources/js/chat-room.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,6 @@ var ChatRoom = {

// 加载挂件
ChatRoom.loadAvatarPendant();
// 加载小冰游戏
ChatRoom.loadXiaoIceGame();
// 加载用户捕获
ChatRoom.initCatchUser();
// 加载画图
Expand Down Expand Up @@ -2090,103 +2088,6 @@ ${result.info.msg}
this.imgWaitting = this.imgWaitting || delayshow()
// console.log("后", this.imgWaitting)
},
/**
* xiaoIce Game
* */
iceWs: "",
IceGameCK: localStorage.getItem("IceGameCK") || null,
loadXiaoIceGame: function () {
// 连接游戏服务器
iceWs = io("wss://game.yuis.cc");
iceWs.on("hello", function (e) {
iceWs.emit(
"setUser",
JSON.stringify({
user: Label.currentUser,
ck: ChatRoom.IceGameCK,
uid: Label.currentUserId
})
);
});
iceWs.on('connect_error', (error) => {
let html = `<div class="ice-msg-item">
<div class="ice-msg-content">小冰网络维护中...</div>
</div>`
$('#iceMsgList').prepend(html);
});
iceWs.on('disconnect', (timeout) => {
let html = `<div class="ice-msg-item">
<div class="ice-msg-content">小冰网络失去连接</div>
</div>`
$('#iceMsgList').prepend(html);
});
// 收到消息
iceWs.on('gameMsg', (e) => {
let data = JSON.parse(e);
if (data.user === "all" || data.user === Label.currentUser) {
let html = `<div class="ice-msg-item">
<div class="ice-msg-content">${data.msg}</div>
</div>`
$('#iceMsgList').prepend(html);
}
});
iceWs.on('setCK', (e) => {
let data = JSON.parse(e);
ChatRoom.IceGameCK = data.ck;
localStorage.setItem("IceGameCK", data.ck);
});
// 打开游戏界面
$('#xiaoIceGameBtn').click(function () {
$("#xiaoIceGameBox").show(200);
$('#xiaoIceGameBtn').hide(200);
setTimeout(() => {
$("#xiaoIceGameBox").addClass('active');
}, 220)
})
// 关闭游戏界面
$('#iceClose').click(function () {
const gameBox = $("#xiaoIceGameBox")
setTimeout(() => {
$('.ice-chat-input').val("");
$("#xiaoIceGameBox").hide(200);
$('#xiaoIceGameBtn').show(200);
}, gameBox.hasClass('active') ? 420 : 1)
gameBox.removeClass('active');
})
// 最小化切换
$('#iceMinimize').click(function () {
$("#xiaoIceGameBox").toggleClass('active');
})
// 发送指令
$('#iceSendMsg').click(ChatRoom.sendIceMsg);
$('.ice-chat-input').bind('keypress', function (event) {
if (event.keyCode === 13) {
event.preventDefault();
ChatRoom.sendIceMsg();
}
});
},

sendIceMsg: function () {
let msg = $('.ice-chat-input').val();
$('.ice-chat-input').val("");
let uMsg = `<div class="ice-msg-item me">
<div class="ice-msg-content">${msg}</div>
</div>`
$('#iceMsgList').prepend(uMsg);
let type = "gameMsg";
if (/()/.test(msg)) {
type = "login"
}
iceWs.emit(
type,
JSON.stringify({
ck: ChatRoom.IceGameCK,
uid:Label.currentUserId,
msg: msg
})
);
},

/**
* 渲染捕获消息
Expand Down
Loading

0 comments on commit 39759c2

Please sign in to comment.