first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

38
public/admin/js/common.js Executable file
View File

@ -0,0 +1,38 @@
/**
* 浏览页面顶部搜索框展开收回控制
*/
function toggleSearchFormShow()
{
let $ = layui.$;
let items = $('.top-search-from .layui-form-item');
if (items.length <= 2) {
if (items.length <= 1) $('.top-search-from').parent().parent().remove();
return;
}
let btns = $('.top-search-from .toggle-btn a');
let toggle = toggleSearchFormShow;
if (typeof toggle.hide === 'undefined') {
btns.on('click', function () {
toggle();
});
}
let countPerRow = parseInt($('.top-search-from').width()/$('.layui-form-item').width());
if (items.length <= countPerRow) {
return;
}
btns.removeClass('layui-hide');
toggle.hide = !toggle.hide;
if (toggle.hide) {
for (let i = countPerRow - 1; i < items.length - 1; i++) {
$(items[i]).hide();
}
return $('.top-search-from .toggle-btn a:last').addClass('layui-hide');
}
items.show();
$('.top-search-from .toggle-btn a:first').addClass('layui-hide');
}
layui.$(function () {
toggleSearchFormShow();
});

34
public/admin/js/permission.js Executable file
View File

@ -0,0 +1,34 @@
/**
* 获取控制器详细权限并决定展示哪些按钮或dom元素
*/
layui.$(function () {
let $ = layui.$;
$.ajax({
url: "/admin/api/permission",
dataType: "json",
success: function (res) {
let style = '';
let codes = res.data || [];
let isSuperAdmin = false;
// codes里有*,说明是超级管理员,拥有所有权限
if (codes.indexOf('*') !== -1) {
$("head").append("<style>*[permission]{display: initial}</style>");
isSuperAdmin = true;
}
if (self !== top) {
top.Admin.Account.isSuperAdmin = isSuperAdmin;
} else {
window.Admin.Account.isSuperAdmin = isSuperAdmin;
}
if (isSuperAdmin) return;
// 细分权限
layui.each(codes, function (k, code) {
codes[k] = '*[permission^="'+code+'"]';
});
if (codes.length) {
$("head").append("<style>" + codes.join(",") + "{display: initial}</style>");
}
}
});
});