解决编目系统偶尔因notice.js的原因加载失败问题

master
guoxin 1 year ago
parent 699973e3cd
commit 54cea26eb0
  1. 16
      shandan-bianmu/src/main/resources/static/js/index.js
  2. 3
      shandan-bianmu/src/main/resources/view/index.html
  3. 5
      shandan-system/src/main/resources/static/js/sys/notification/notification.js
  4. 2
      shandan-system/src/main/resources/view/sys/notification/notification.html

@ -1,15 +1,11 @@
layui.extend({ layui.use(['element', 'flow', 'util'], function () {
notification: `{/}${ctx}/js/sys/notification/notification` // {/}的意思即代表采用自有路径,即不跟随 base 路径
})
layui.use(['element', 'flow', 'util', 'notification'], function () {
let element = layui.element; let element = layui.element;
//setTimeout(()=>{ setTimeout(()=>{
window.NotificationUtil = layui.notification.init(); window.NotificationUtil = notification.init();
// 轮询查询系统未读通知 // 轮询查询系统未读通知
NotificationUtil.getUnreadNotifications(); NotificationUtil.getUnreadNotifications();
//},1500) },1500)
// 右侧用户导航栏不显示点击状态样式 // 右侧用户导航栏不显示点击状态样式
element.on('nav(user-nav)', function(elem){ element.on('nav(user-nav)', function(elem){
$('#user-nav li').removeClass('layui-this') $('#user-nav li').removeClass('layui-this')
@ -65,7 +61,7 @@ layui.use(['element', 'flow', 'util', 'notification'], function () {
* 水平导航栏默认点击第一个 * 水平导航栏默认点击第一个
*/ */
const navbarInit = function () { const navbarInit = function () {
$("#navbar-top li:first a:first").click();
} }
/** /**
@ -129,7 +125,7 @@ layui.use(['element', 'flow', 'util', 'notification'], function () {
window.onresize = function (ev) { window.onresize = function (ev) {
$(".tab-content-div").css("height", $(".layui-body")[0].offsetHeight + "px"); $(".tab-content-div").css("height", $(".layui-body")[0].offsetHeight + "px");
} }
navbarInit();
$("#navbar-top li:first a:first").click();
}) })

@ -9,7 +9,6 @@
<!-- 引入公用部分 --> <!-- 引入公用部分 -->
<script th:replace="common/head::static"></script> <script th:replace="common/head::static"></script>
<!--<script th:src="@{/js/sys/notification/notification.js}"></script>--> <!--<script th:src="@{/js/sys/notification/notification.js}"></script>-->
<script th:src="@{/js/index.js}"></script>
</head> </head>
<body> <body>
<div class="layui-layout layui-layout-admin"> <div class="layui-layout layui-layout-admin">
@ -64,6 +63,8 @@
</div> </div>
</div> </div>
<script th:replace="common/head::static-foot"></script> <script th:replace="common/head::static-foot"></script>
<script th:src="@{/js/sys/notification/notification.js}"></script>
<script th:src="@{/js/index.js}"></script>
<!-- th:inLine="javascript" 声明以下javascript代码可处理Thymeleaf脚本 --> <!-- th:inLine="javascript" 声明以下javascript代码可处理Thymeleaf脚本 -->
<script th:inline="javascript"> <script th:inline="javascript">
const menuList = [[${menuList}]]; const menuList = [[${menuList}]];

@ -6,6 +6,7 @@
* @author GuoXin * @author GuoXin
* @since 2021/6/11 * @since 2021/6/11
*/ */
let notification;
layui.define(['notice', 'jquery', 'layer'], function (exports) { layui.define(['notice', 'jquery', 'layer'], function (exports) {
var notice = layui.notice; var notice = layui.notice;
@ -221,7 +222,7 @@ layui.define(['notice', 'jquery', 'layer'], function (exports) {
let NotificationUtil; let NotificationUtil;
const _exports = { notification = {
init: function () { init: function () {
let user = sessionStorage.getItem('login_user'); let user = sessionStorage.getItem('login_user');
if(user && user.indexOf('{') === 0){ if(user && user.indexOf('{') === 0){
@ -234,5 +235,5 @@ layui.define(['notice', 'jquery', 'layer'], function (exports) {
} }
} }
} }
exports('notification', _exports); exports('notification', notification);
}); });

@ -5,7 +5,6 @@
<head> <head>
<!-- 引入公用部分 --> <!-- 引入公用部分 -->
<script th:replace="common/head::static"></script> <script th:replace="common/head::static"></script>
<script th:src="@{/js/sys/notification/notification.js}"></script>
<!-- 样式 --> <!-- 样式 -->
<link th:href="@{/css/common/contianer.css}" rel="stylesheet" type="text/css"/> <link th:href="@{/css/common/contianer.css}" rel="stylesheet" type="text/css"/>
<style> <style>
@ -36,6 +35,7 @@
</body> </body>
<!-- js --> <!-- js -->
<script th:replace="common/head::static-foot"></script> <script th:replace="common/head::static-foot"></script>
<script th:src="@{/js/sys/notification/notification.js}"></script>
<!--<script th:src="@{/js/business/review/review.js}"></script>--> <!--<script th:src="@{/js/business/review/review.js}"></script>-->
<script> <script>
const sizeInit = () => { const sizeInit = () => {