Skip to content

Commit

Permalink
Merge pull request #148 from HereIsYui/master
Browse files Browse the repository at this point in the history
bye~ xiaoIce
  • Loading branch information
adlered authored Jun 14, 2024
2 parents dafa580 + 39759c2 commit 9350cfc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 126 deletions.
98 changes: 0 additions & 98 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,102 +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 = new WebSocket('wss://game.yuis.cc/wss');
let iceWsHeart = null;
iceWs.onopen = function () {
iceWs.send(JSON.stringify({
type: 'setUser',
user: Label.currentUser,
ck: ChatRoom.IceGameCK,
uid: Label.currentUserId
}))
iceWsHeart = setInterval(() => {
iceWs.send(JSON.stringify({type: 'hb'}))
}, 15000)
}
iceWs.onclose = function () {
let html = `<div class="ice-msg-item">
<div class="ice-msg-content">小冰网络失去连接</div>
</div>`
$('#iceMsgList').prepend(html);
}
iceWs.onerror = function (err) {
let html = `<div class="ice-msg-item">
<div class="ice-msg-content">小冰网络维护中...</div>
</div>`
$('#iceMsgList').prepend(html);
}
// 收到消息
iceWs.onmessage = function (e) {
let data = JSON.parse(e.data);
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);
}
if (data.type === "setCK") {
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";
console.log(/(登录)/.test(msg))
if (/(登录)/.test(msg)) {
type = "login"
}
iceWs.send(JSON.stringify({
type: type,
ck: ChatRoom.IceGameCK,
msg: msg
}));
},

/**
* 渲染捕获消息
Expand Down
29 changes: 1 addition & 28 deletions src/main/resources/skins/classic/chat-room.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -169,34 +169,7 @@
</div>
<div id="goToTop" style="position:fixed;bottom:20px;right:10%;display:none;"><a href="#"><svg style="width:30px;height:30px;color:#626262;"><use xlink:href="#toTopIcon"></use></svg></a></div>
<div id="xiaoIceGameBtn" class="ice-game-btn">
<img src="${staticServePath}/images/xiaoIce/xiaoIce.gif" class="ice-game-icon" alt="">
</div>
<div id="xiaoIceGameBox" style="display: none">
<div class="ice-tool-bar">
<img src="${staticServePath}/images/xiaoIce/xiaoIce-icon.png" class="ice-logo" alt="">
xiaoIce Game
<div class="ice-toolbar-btn">
<div id="iceMinimize">
<svg class="ice-minimize-btn" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32">
<title>最小化</title>
<path d="M128 448h768v128H128z" fill="#ffffff"></path>
</svg>
<svg class="ice-restore-btn" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32">
<title>还原窗口</title>
<path d="M128.576377 895.420553 128.576377 128.578424l766.846222 0 0 766.842129L128.576377 895.420553zM799.567461 224.434585 224.432539 224.434585l0 575.134923 575.134923 0L799.567461 224.434585z" fill="#ffffff"></path>
</svg>
</div>
<svg id="iceClose" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32">
<title>关闭</title>
<path d="M576 512l277.333333 277.333333-64 64-277.333333-277.333333L234.666667 853.333333 170.666667 789.333333l277.333333-277.333333L170.666667 234.666667 234.666667 170.666667l277.333333 277.333333L789.333333 170.666667 853.333333 234.666667 576 512z" fill="#ffffff"></path>
</svg>
</div>
</div>
<div class="ice-chat-box">
<input class="ice-chat-input" type="text" placeholder="开始游戏"/>
<div id="iceSendMsg" class="ice-send-btn">发送</div>
</div>
<div id="iceMsgList"></div>
<a href="https://game.yuis.cc" target="_blank"><img src="${staticServePath}/images/xiaoIce/xiaoIce.gif" class="ice-game-icon" alt=""></a>
</div>
<div id="robotBtn" class="robot-btn" style=""><img src="https://file.fishpi.cn/2024/05/chatbot-7857bb0c.gif" class="ice-game-icon" style="border-radius: 50%;" alt=""></div>
<div id="robotBox" style="display: none;" class="">
Expand Down

0 comments on commit 9350cfc

Please sign in to comment.