Files
ulthon_admin/extend/base/admin/view/index/index.js

58 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

window.pageType = 'index';
$(function () {
var options = {
iniUrl: ua.url('ajax/initAdmin'), // 初始化接口
clearUrl: ua.url("ajax/clearCache"), // 缓存清理接口
urlHashLocation: true, // 是否打开hash定位
bgColorDefault: 0, // 主题默认配置(0=标准皮肤经典配色)
menuChildOpen: false, // 是否默认展开菜单
loadingTime: 0, // 初始化加载时间
pageAnim: true, // iframe窗口动画
maxTabNum: 20, // 最大的tab打开数量
};
miniAdmin.render(options);
$('.login-out').on("click", function () {
ua.request.get({
url: 'login/out',
prefix: true,
}, function (res) {
ua.msg.success(res.msg, function () {
window.location = ua.url('login/index');
});
});
});
});
// 顶栏铃铛未读数轮询(仅框架首页执行;60s 轮询一次;接口失败静默,badge 维持现状;无退避,页面关闭即停)
function initUnreadPolling() {
var unreadCountUrl = ua.url('notice/unreadCount');
var pollInterval = 60000;
var $badge = $('#ua-notice-unread');
function renderBadge(count) {
count = parseInt(count, 10) || 0;
if (count <= 0) {
$badge.text('').hide();
} else {
$badge.text(count > 99 ? '99+' : count).show();
}
}
function fetchUnreadCount() {
$.getJSON(unreadCountUrl).done(function (res) {
if (res && res.code === 0 && res.data) {
renderBadge(res.data.count);
}
}).fail(function () {
// 静默失败,不做任何处理
});
}
fetchUnreadCount();
setInterval(fetchUnreadCount, pollInterval);
}
if (window.pageType === 'index') {
initUnreadPolling();
}