Compare commits

...

3 Commits

Author SHA1 Message Date
Anyon
907a21e0cc Update admin.js 2022-03-09 12:43:48 +08:00
Anyon
25a2911c24 修改小号阴影样式 2022-03-09 10:49:12 +08:00
Anyon
ca39ff6c3c 优化后台JS 2022-03-09 10:44:04 +08:00
4 changed files with 25 additions and 39 deletions

View File

@ -37,22 +37,15 @@ if (typeof Array.prototype.forEach !== 'function') {
}
/*! 脚本应用根路径 */
window.appRoot = (function (src) {
return src.pop(), src.pop(), src.join('/') + '/';
})(document.scripts[document.scripts.length - 1].src.split('/'));
var srcs = document.scripts[document.scripts.length - 1].src.split('/');
window.appRoot = srcs.slice(0, -2).join('/') + '/';
/*! 静态插件库路径 */
window.baseRoot = (function (src) {
return src.substring(0, src.lastIndexOf("/") + 1);
})(document.scripts[document.scripts.length - 1].src);
window.baseRoot = srcs.slice(0, -1).join('/') + '/';
/*! 动态插件库路径 */
window.tapiRoot = window.tapiRoot || window.appRoot + "admin";
/*! 配置 layui 插件 */
layui.config({base: baseRoot + 'plugs/layui_exts/'});
/*! 挂载 layui & jquery 对象 */
layui.config({base: baseRoot + 'plugs/layui_exts/'});
window.form = layui.form, window.layer = layui.layer;
window.laytpl = layui.laytpl, window.laydate = layui.laydate;
window.jQuery = window.$ = window.jQuery || window.$ || layui.$;
@ -343,15 +336,15 @@ $(function () {
uri = uri.indexOf(location.host) > -1 ? uri.split(location.host)[1] : uri;
return (uri.indexOf('#') > -1 ? uri.split('#')[1] : uri).split('?')[0];
};
/*! 通过 URI 查询最有可能的菜单 NODE */
this.queryNode = function (url, node) {
/*! 通过 URI 查询最菜单 NODE */
this.queryNode = function (uri, node) {
if (!/^m-/.test(node = node || location.href.replace(/.*spm=([\d\-m]+).*/ig, '$1'))) {
var $menu = $('[data-menu-node][data-open*="' + url.replace(/\.html$/ig, '') + '"]');
var $menu = $('[data-menu-node][data-open*="' + uri.replace(/\.html$/ig, '') + '"]');
return $menu.size() ? $menu.get(0).dataset.menuNode : '';
}
return node;
};
/*! URL 转 URI */
/*! 完整 URL 转 URI 地址 */
this.parseUri = function (uri, elem, vars, temp, attrs) {
vars = {}, attrs = [], elem = elem || document.createElement('a');
if (uri.indexOf('?') > -1) uri.split('?')[1].split('&').forEach(function (item) {
@ -368,33 +361,25 @@ $(function () {
/*! 后台菜单动作初始化 */
this.listen = function () {
var layout = $('.layui-layout-admin'), mclass = 'layui-layout-left-mini';
/*! 菜单模式显示 */
if (layui.data('AdminMenuType')['mini']) layout.addClass(mclass);
/*! 菜单切换事件 */
/*! 菜单切及MiniTips处理 */
onEvent('click', '[data-target-menu-type]', function () {
layui.data('AdminMenuType', {key: 'mini', value: layout.toggleClass(mclass).hasClass(mclass)});
}).on('click', '[data-submenu-layout]>a', function () {
setTimeout("$.menu.sync(1);", 100);
}).on('mouseenter', '[data-target-tips]', function (evt) {
if (!layout.hasClass(mclass) || !this.dataset.targetTips) return;
evt.idx = layer.tips(this.dataset.targetTips, this, {time: 0});
$(this).mouseleave(function () {
layer.close(evt.idx);
});
});
/*! 监听窗口尺寸 */
/*! 监听窗口大小及HASH切换 */
$(window).on('resize', function () {
(layui.data('AdminMenuType')['mini'] || $body.width() < 1000) ? layout.addClass(mclass) : layout.removeClass(mclass);
}).trigger('resize');
/*! Mini 模式 TIPS 显示 */
$('[data-target-tips]').mouseenter(function () {
if (layout.hasClass(mclass)) (function (idx) {
$(this).mouseleave(function () {
layer.close(idx);
});
}).call(this, layer.tips(this.dataset.targetTips || '', this, {time: 0}));
});
/*! 左则二级菜单展示 */
$('[data-submenu-layout]>a').on('click', function () {
setTimeout("$.menu.sync(1);", 100);
});
/*! 监听 HASH 切换事件 */
$(window).on('hashchange', function () {
}).trigger('resize').on('hashchange', function () {
if (/^#(https?:)?(\/\/|\\\\)/.test(location.hash)) return $.msg.tips('禁止访问外部链接!');
if (location.hash.length < 1) return $body.find('[data-menu-node]:first').trigger('click');
else that.href(location.hash);
else return that.href(location.hash);
}).trigger('hashchange');
};
/*! 同步二级菜单展示状态 */
@ -411,7 +396,7 @@ $(function () {
// $.msg.page.show(),$.form.load(hash, {}, 'get', $.msg.page.hide, true),that.sync(2);
$.form.load(hash, {}, 'get', false, !$.msg.page.stat()), that.sync(2);
/*! 菜单选择切换 */
if (/^m-/.test(node = that.queryNode(that.getUri()))) {
if (/^m-/.test(node = node || that.queryNode(that.getUri()))) {
var arr = node.split('-'), tmp = arr.shift(), $all = $('a[data-menu-node]').parent('.layui-this');
while (arr.length > 0) {
tmp = tmp + '-' + arr.shift();
@ -431,6 +416,7 @@ $(function () {
}
};
};
/*! 表单验证组件 */
$.vali = function (form, callable) {
return $(form).data('validate') || new Validate();

View File

@ -24,7 +24,7 @@
@InputBorderActiveColor: #DDD;
// 基础阴影配置
@ShadowOuterMin: 0 0 4px 1px rgba(0, 0, 0, 0.20);
@ShadowOuterMin: 0 0 4px 0 rgba(0, 0, 0, 0.20);
@ShadowOuterMax: 0 0 6px 1px rgba(0, 0, 0, 0.20);
@ShadowBodyTop: 0 1px 6px 1px rgba(0, 21, 41, 0.35);
@ShadowBodyLeft: 1px 0 6px 1px rgba(0, 21, 41, 0.35);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long