|
|
|
@ -7,13 +7,47 @@ class FimsMenuSupport extends MenuSupport {
|
|
|
|
|
|
|
|
|
|
this._menuItem = '<li data-key="{menuID}" class="menu-item">'
|
|
|
|
|
+'<a data-url="{url}" onclick="openMenu(this)" class="menu-link{toggle}">'
|
|
|
|
|
+'<i class="menu-icon tf-icons bx bx-layout"></i>'
|
|
|
|
|
+'<i class="menu-icon tf-icons {imageConf}"></i>'
|
|
|
|
|
+'<div data-i18n="{menuName}">{menuName}</div>'
|
|
|
|
|
+'</a>'
|
|
|
|
|
+'{menuSub}'
|
|
|
|
|
+'</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setMenuInfo(menus) {
|
|
|
|
|
|
|
|
|
|
let setParent = menu => {
|
|
|
|
|
let children = menu.children || [];
|
|
|
|
|
if (children.length < 1) return;
|
|
|
|
|
|
|
|
|
|
children.forEach(child => {
|
|
|
|
|
child.parent = menu;
|
|
|
|
|
setParent(child);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
menus.forEach(menu => setParent(menu));
|
|
|
|
|
this._menus = menus;
|
|
|
|
|
|
|
|
|
|
let menuItemTag = menu => {
|
|
|
|
|
let tag = this._menuItem
|
|
|
|
|
.replace(/{menuID}/gi, menu.id)
|
|
|
|
|
.replace(/{menuName}/gi, menu.name)
|
|
|
|
|
.replace(/{url}/gi, !menu.url ? "javascript:void(0);" : wctx.url(menu.url))
|
|
|
|
|
.replace(/{imageConf}/gi, !menu.imageConf ? "bx bx-layout" : menu.imageConf);
|
|
|
|
|
let parent = menu.children && menu.children.length > 0;
|
|
|
|
|
tag = tag.replace(/{toggle}/gi, !parent ? "" : " menu-toggle");
|
|
|
|
|
if (!parent)
|
|
|
|
|
return tag.replace(/{menuSub}/gi, "");
|
|
|
|
|
|
|
|
|
|
let children = menu.children.map(child => menuItemTag(child)).join("\n\t")
|
|
|
|
|
return tag.replace(/{menuSub}/gi, this._menuSub.replace(/{children}/gi, children));
|
|
|
|
|
}
|
|
|
|
|
let tags = (menus || []).map(menu => menuItemTag(menu));
|
|
|
|
|
document.querySelector("#menus").innerHTML = tags.join("");
|
|
|
|
|
|
|
|
|
|
return this._init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|