67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
const { ipcRenderer } = require('electron');
|
|
|
|
class Login {
|
|
constructor() {
|
|
this.renderImg();
|
|
this.enterRoom();
|
|
}
|
|
|
|
|
|
renderImg() {
|
|
var type = null;
|
|
for (var i = 1; i <= 10; i++) {
|
|
if (i == 3 || i == 4 || i == 5) {
|
|
type = "gif"
|
|
} else {
|
|
type = "jpg"
|
|
}
|
|
|
|
$(".modal-body").append(`
|
|
<img class="${i == 1 ? 'active': ''}" src="../img/${i}.${type}" alt="">
|
|
`)
|
|
}
|
|
|
|
$(".modal-body img").click(function () {
|
|
$(this).addClass("active").siblings().removeClass("active");
|
|
|
|
$(".login img").attr({
|
|
src: $(this).attr("src")
|
|
});
|
|
|
|
$('#myModal').modal('hide')
|
|
})
|
|
}
|
|
|
|
|
|
enterRoom() {
|
|
$(".enter").click(function () {
|
|
var username = $(".username").val();
|
|
var userroom = $(".userroom").val();
|
|
|
|
if (username.length == 0) {
|
|
new $.zui.Messager('用户名必填', {
|
|
icon: 'bell'
|
|
}).show();
|
|
|
|
return;
|
|
}
|
|
|
|
if (userroom.length == 0) {
|
|
new $.zui.Messager('房间号必填', {
|
|
icon: 'bell'
|
|
}).show();
|
|
return;
|
|
}
|
|
|
|
var userInfo = {
|
|
user_img: $(".login img").attr("src"),
|
|
user_name: username,
|
|
user_room: userroom
|
|
}
|
|
localStorage.setItem("userInfo", JSON.stringify(userInfo))
|
|
ipcRenderer.send('GoToIndex', 1)
|
|
})
|
|
}
|
|
}
|
|
|
|
new Login(); |