[fix]Config创建默认配置文件的开关Runtime.CreateConfigOnMissing,仅需对自动创建生效,而不应该阻止用户主动Save
智能大石头 authored at 2024-08-09 00:30:41 石头 committed at 2024-08-10 14:22:24
1.90 KiB
X
@using NewLife.Model;
@{
    var user = ManageProvider.User;

    var fact = ObjectContainer.Current.Resolve<IMenuFactory>();

    var Menus = fact.Root.Childs;
    if (user != null && user.Role != null)
    {
        Menus = fact.GetMySubMenus(fact.Root.ID);
    }

    // 如果顶级只有一层,并且至少有三级目录,则提升一级
    if (Menus.Count == 1 && Menus[0].Childs.All(m => m.Childs.Count > 0)) { Menus = Menus[0].Childs; }

    String[] icos = new String[] { "fa-tachometer", "fa-desktop", "fa-list", "fa-pencil-square-o", "fa-list-alt", "fa-calendar", "fa-picture-o", "fa-tag", "fa-file-o" };
    Int32 _idx = 0;
}
<ul class="nav nav-list">
    @foreach (IMenu menu in Menus.Where(m => m.Visible))
    {
        var childs = fact.GetMySubMenus(menu.ID).Where(m => m.Visible);
        if (_idx >= icos.Length) { _idx = 0; }
        <li @Html.Raw(menu == Menus[0] ? "class=\"active open\"" : "")>
            <a href="#" class="dropdown-toggle">
                <i class="menu-icon fa @icos[_idx++]"></i>
                <span class="menu-text">@menu.DisplayName</span>

                <b class="arrow fa fa-angle-down"></b>
            </a>
            @if (childs.Any())
            {
                <b class="arrow"></b>

                <ul @Html.Raw(menu == Menus[0] ? "class=\"submenu nav-show\" style=\"display:block;\"" : "class=\"submenu nav-hide\" style=\"display:none;\"")>
                    @foreach (IMenu menu2 in childs)
                    {
                        @Html.Partial("_Left_Item", menu2);
                    }
                </ul>

                @*<ul class="submenu">
                        @foreach (IMenu menu2 in childs)
                        {
                            @Html.Partial("_Left_Item", menu2);
                        }
                    </ul>*@
            }
        </li>
    }
</ul>
<!-- /.nav-list -->