mirror of https://gitee.com/stylefeng/guns
193 lines
6.9 KiB
HTML
193 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8"/>
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||
<link href="${ctxPath}/assets/expand/images/favicon.ico" rel="icon">
|
||
<title>${constants.getSystemName()}</title>
|
||
<link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
|
||
<link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css?v=${constants.getReleaseVersion()}"/>
|
||
<!--[if lt IE 9]>
|
||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||
<![endif]-->
|
||
</head>
|
||
<body class="layui-layout-body">
|
||
<div class="layui-layout layui-layout-admin">
|
||
<!-- 头部 -->
|
||
@include("/layout/_header.html"){}
|
||
|
||
<!-- 侧边栏 -->
|
||
@include("/layout/_sidebar.html"){}
|
||
|
||
<!-- 主体部分 -->
|
||
@include("/layout/_body.html"){}
|
||
|
||
<!-- 底部 -->
|
||
@include("/layout/_footer.html"){}
|
||
|
||
</div>
|
||
|
||
<!-- 加载动画 -->
|
||
@include("/layout/loading.html"){}
|
||
|
||
<!-- js全局变量 -->
|
||
<script type="text/javascript">
|
||
var Feng = {
|
||
ctxPath: "${ctxPath}",
|
||
version: '${constants.getReleaseVersion()}',
|
||
wsUrl: '${wsUrl}'
|
||
};
|
||
</script>
|
||
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
|
||
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>
|
||
|
||
<script>
|
||
var wsInst = null
|
||
layui.use(['layer', 'element', 'admin', 'index', 'HttpRequest', 'ws', 'notice'], function () {
|
||
var $ = layui.jquery;
|
||
var layer = layui.layer;
|
||
var admin = layui.admin;
|
||
var index = layui.index;
|
||
var HttpRequest = layui.HttpRequest;
|
||
var ws = layui.ws;
|
||
var notice = layui.notice;
|
||
|
||
//获取支持的语言列表
|
||
var languageRequest = new HttpRequest(Feng.ctxPath + "/i18n/getAllLanguages", 'get', function (data) {
|
||
for (var i = 0; i < data.data.length; i++) {
|
||
var code = data.data[i].code;
|
||
var description = data.data[i].name;
|
||
$("#languageDiv").append('<dd lay-unselect><a id="tran-' + code + '" href="javascript:;">' + description + '</a></dd>');
|
||
|
||
//设置监听事件,设置点击按钮切换当前系统语言
|
||
(function (code) {
|
||
$('#tran-' + code).click(function () {
|
||
var changeLanguageRequest = new HttpRequest(Feng.ctxPath + "/i18n/changeUserTranslation", 'post', function (data) {
|
||
window.location.href = Feng.ctxPath + "/";
|
||
}, function (data) {
|
||
layer.msg("切换多语言失败!" + data.message, {icon: 5, anim: 6});
|
||
});
|
||
changeLanguageRequest.set("tranLanguageCode", code);
|
||
changeLanguageRequest.start(true);
|
||
});
|
||
})(code);
|
||
}
|
||
}, function (data) {
|
||
layer.msg("获取语言列表失败!" + data.responseJSON.message, {icon: 5, anim: 6});
|
||
});
|
||
languageRequest.start();
|
||
|
||
// 默认加载主页
|
||
index.loadHome({
|
||
menuPath: $("#firstPageAction").attr('lay-href'),
|
||
menuName: '<i class="layui-icon layui-icon-home"></i>'
|
||
});
|
||
|
||
// 修改密码点击事件
|
||
$('#setPsw').click(function () {
|
||
admin.open({
|
||
id: 'pswForm',
|
||
type: 2,
|
||
title: "修改密码",
|
||
shade: 0,
|
||
content: '${ctxPath}/view/changePassword'
|
||
});
|
||
});
|
||
|
||
// 退出登录点击事件
|
||
$('#btnLogout').click(function () {
|
||
var request = new HttpRequest(Feng.ctxPath + "/logout", 'post', function (data) {
|
||
Feng.success("退出成功!");
|
||
window.location.href = Feng.ctxPath + "/";
|
||
}, function (data) {
|
||
layer.msg("退出失败!" + data.message, {icon: 5, anim: 6});
|
||
});
|
||
request.start();
|
||
});
|
||
wsInst = ws.render({
|
||
wsUrl: Feng.wsUrl,//WebSocket的地址
|
||
connectErr: function (event) {
|
||
console.log(event)
|
||
//如果不支持websocket 回调
|
||
},
|
||
onWsError: function (event) {
|
||
//发生连接错误回调
|
||
},
|
||
onWsOpen: function (event) {
|
||
//连接成功回调
|
||
console.log("Socket 已打开");
|
||
wsInst.send("消息发送测试(From Client)");
|
||
},
|
||
onWsMessage: function (event) {
|
||
//服务器发送消息回调
|
||
let data = event.data;
|
||
try {
|
||
let msg = JSON.parse(data)
|
||
notice.info({
|
||
title: '['+msg.businessTypeValue+']'+msg.messageTitle,
|
||
message: msg.messageContent,
|
||
timeout: false
|
||
});
|
||
$('#messageDot').show();
|
||
} catch (e) {
|
||
}
|
||
},
|
||
onWsClose: function (event) {
|
||
//关闭连接回调
|
||
},
|
||
|
||
wsSend: function (event) {
|
||
//发送成功后的回调
|
||
},
|
||
|
||
})
|
||
});
|
||
|
||
/*
|
||
var socket;
|
||
if (typeof (WebSocket) == "undefined") {
|
||
console.log("遗憾:您的浏览器不支持WebSocket");
|
||
} else {
|
||
|
||
//实现化WebSocket对象
|
||
//指定要连接的服务器地址与端口建立连接
|
||
//注意ws、wss使用不同的端口。我使用自签名的证书测试,
|
||
//无法使用wss,浏览器打开WebSocket时报错
|
||
//ws对应http、wss对应https。
|
||
socket = new WebSocket(Feng.wsUrl);
|
||
//连接打开事件
|
||
socket.onopen = function() {
|
||
console.log("Socket 已打开");
|
||
socket.send("消息发送测试(From Client)");
|
||
};
|
||
//收到消息事件
|
||
socket.onmessage = function(msg) {
|
||
console.log(msg.data);
|
||
};
|
||
//连接关闭事件
|
||
socket.onclose = function() {
|
||
console.log("Socket已关闭");
|
||
};
|
||
//发生了错误事件
|
||
socket.onerror = function() {
|
||
alert("Socket发生了错误");
|
||
}
|
||
|
||
//窗口关闭时,关闭连接
|
||
window.unload=function() {
|
||
socket.close();
|
||
};
|
||
|
||
}*/
|
||
window.unload = function () {
|
||
if (wsInst) {
|
||
wsInst.close();
|
||
}
|
||
};
|
||
</script>
|
||
</body>
|
||
|
||
</html>
|