修正一个揪心的空引用
大石头 authored at 2017-08-16 16:56:49
3.68 KiB
X
@using NewLife.Common;
@using XCode.Membership;
@{
    var user = ViewBag.User as IUser ?? User.Identity as IUser;
    var uid = 0;
    if (user != null) { uid = user.ID; }
    var cfg = ViewBag.Config as SysConfig;
    var name = cfg == null ? "" : cfg.DisplayName;
}
<!-- #section:basics/navbar.layout -->
<div id="navbar" class="navbar navbar-default">
    <script type="text/javascript">
        try { ace.settings.check('navbar', 'fixed') } catch (e) { }
    </script>

    <div class="navbar-container" id="navbar-container">
        <!-- #section:basics/sidebar.mobile.toggle -->
        <button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
            <span class="sr-only">Toggle sidebar</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <!-- /section:basics/sidebar.mobile.toggle -->
        <div class="pull-left">
            <!-- #section:basics/navbar.layout.brand -->
            <a href="#" class="navbar-brand">
                <small>
                    @name
                </small>
            </a>
        </div>

        <!-- #section:basics/navbar.dropdown -->
        <div class="navbar-buttons navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
                <!-- #section:basics/navbar.user_menu -->
                <li class="light-blue">
                    <a data-toggle="dropdown" href="~/Admin/User/Info/@uid" class="dropdown-toggle" target="main">
                        @*<img class="nav-user-photo" src="~/Content/ace/avatars/user.jpg" alt="@User.FriendName" />*@
                        <span class="user-info">
                            @*<small>欢迎,</small>*@
                            @user @*[@User["RoleName"]]*@
                        </span>

                        <i class="ace-icon fa fa-caret-down"></i>
                    </a>

                    <ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="~/" target="_blank">
                                <i class="ace-icon fa fa-cog"></i>
                                网站首页
                            </a>
                        </li>

                        @if (user.Has("Admin/Sys", PermissionFlags.Detail))
                        {
                            <li>
                                <a href="~/Admin/Sys" target="main">
                                    <i class="ace-icon fa fa-cog"></i>
                                    设置
                                </a>
                            </li>
                        }

                        <li>
                            <a href="~/Admin/User/Info/@uid" target="main">
                                <i class="ace-icon fa fa-user"></i>
                                个人信息
                            </a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="~/Admin/User/Logout">
                                <i class="ace-icon fa fa-power-off"></i>
                                注销
                            </a>
                        </li>
                    </ul>
                </li>

                <!-- /section:basics/navbar.user_menu -->
            </ul>
        </div>

        <!-- /section:basics/navbar.dropdown -->
    </div>
    <!-- /.navbar-container -->
</div>
<!-- /section:basics/navbar.layout -->