@using PageAdmin.Common;
@using PageAdmin.Utils;
@{
    var installEnabled = ViewBag.InstallEnabled;
    System.Diagnostics.Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
    string lastTime = null, lastIp = null, logins = null;
    dynamic userData = ViewBag.CurrentUserData;
    if (userData != null)
    {
        lastTime = userData.LastDate.ToString("yyyy-MM-dd HH:mm:ss");
        lastIp = userData.LastIp.ToString();
        logins = userData.Logins.ToString();
    }
    CurrentUser user = (CurrentUser)ViewBag.CurrentUser;
    int bindEmailState = (int)ViewBag.EmailBindState;
    int bindMobileState = (int)ViewBag.MobileBindState;
    string securityLevel = "低";
    if (bindEmailState == 1 && bindMobileState == 1)
    {
        securityLevel = "高";
    }
    else if (bindEmailState == 1 || bindMobileState == 1)
    {
        securityLevel = "中";
    }
}
<link rel="stylesheet" href="~/Areas/Admin/Css/Home.css?v4.0.10" type="text/css">
<link rel="stylesheet" href="~/Incs/font-awesome/css/font-awesome.min.css">
<style>
    .table {
        margin: 0px 0px
    }

        .table td {
            padding: 5px !important
        }

        .table tbody tr:hover > td {
            background-color: white;
        }

    .quick-link li {
        float: left;
        width: 18%;
        position: relative;
        margin-bottom: 10px;
        margin-right: 2%;
    }

        .quick-link li a {
            display: block;
            padding: 20px;
            font-size: 14px;
            line-height: 25px;
            background-color: #F5F5F5;
            height: 25px;
            overflow: hidden;
            text-overflow: ellipsis;
            text-wrap: none
        }

            .quick-link li a .fa {
                color: #666;
            }

            .quick-link li a:hover {
                box-shadow: 2px 2px 5px #ccc;
            }

                .quick-link li a:hover .fa {
                    font-weight: 800;
                    color: #333
                }

        .quick-link li.add a {
            width: 25px;
            text-align: center
        }

            .quick-link li.add a i {
                font-size: 18px
            }

    .qucik-menu-toolbar {
        position: absolute;
        right: 0px;
        top: 0px;
        display: none
    }

    .quick-link li:hover .qucik-menu-toolbar {
        display: block
    }

    .qucik-menu-toolbar .fa {
        font-size: 12px;
        color: #666
    }

    .qucik-menu-toolbar .el-button {
        border: 0px;
        padding: 5px 5px;
        background-color: transparent
    }

        .qucik-menu-toolbar .el-button + .el-button {
            margin-left: -1px
        }

        .qucik-menu-toolbar .el-button:hover {
            background-color: #333;
            color: #fff
        }

            .qucik-menu-toolbar .el-button:hover .fa {
                color: #fff
            }
</style>
<div class="main clearfix" id="main" v-cloak>
    <el-alert title="授权提示： 您的站点还未经过PageAdmin商业授权许可！" type="error" show-icon v-show="isAuthorize==0"></el-alert>
    @if (installEnabled == "true")
    {
        <el-alert title="安全提示：请到系统设置>>安全设置中把安装状态设为禁止安装！" type="warning" show-icon style="margin-top:5px"></el-alert>
    }
    <div class="account-info clearfix">
        <div class="account-left">
            <a href="javascript:void(0)" v-on:click="dialogVisible=true"><el-avatar :size="65" :src="avatar" alt="我的头像"></el-avatar></a>
            <el-dialog title=""
                       :visible.sync="dialogVisible"
                       width="400px">
                <img :src="avatar" style="max-width:100%;max-height:100%" />
            </el-dialog>
        </div>
        <div class="account-body">
            <span>欢迎您，<strong style="font-size:16px">@(user.UserName)</strong></span>
            <el-tooltip class="item" effect="dark" content="用户资料修改" placement="right-start">
                <a href="@Url.ActionUrl("UserInfo","MyLogin")"><span class="fa fa-edit"></span></a>
            </el-tooltip>
            <p>
                <span>管理角色：@ViewBag.RoleName &nbsp;&nbsp;</span>
                @if (!string.IsNullOrEmpty(ViewBag.DepartmentName))
                {<span>所属部门：@ViewBag.DepartmentName &nbsp;&nbsp;</span>}
                <span>用户组：@ViewBag.MemberGroupName</span>
            </p>
            <p>
                这是您第 @logins 次登录，上次登录日期：@lastTime，登录Ip:@lastIp
            </p>
        </div>
    </div>

    <div class="panel">
        <div class="panel-heading clearfix">
            <span class="left"><i class="fa fa-tasks"></i>快捷导航</span>
        </div>
        <div class="panel-body">
            <ul class="quick-link clearfix">
                <li v-for="item in quickMentList">
                    <span class="qucik-menu-toolbar">
                        <el-tooltip class="item" effect="dark" content="编辑" placement="top-start">
                            <el-button size="mini" v-on:click="dialog({title:'编辑导航',url:'@Url.ActionUrl("Edit","QuickMenu")?id='+item.Id,width:'750px',height:'550px',target:'self'})"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></el-button>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
                            <el-button size="mini" v-on:click="submit({url:'@Url.ActionUrl("Delete","QuickMenu")',data:{id:item.Id},confirmMsg:'确定删除吗？',successMsg:'删除成功！',success:loadQuickMenu})"><i class="fa fa-trash" aria-hidden="true"></i></el-button>
                        </el-tooltip>
                    </span>
                    <a :href="formatLink(item.Link)" :target="item.Target">
                        <i class="fa" :class="[item.Icon,item.Icon==''?'fa-tag':'']"> {{item.Name}}</i>
                    </a>
                </li>
                <li class="add">
                    <el-tooltip class="item" effect="dark" content="添加快捷导航" placement="top-start">
                        <a href="javascript:void(0);" v-on:click="dialog({title:'添加导航',url:'@Url.ActionUrl("Add","QuickMenu")?xuhao='+quickMentList.length,width:'750px',height:'550px',target:'self'})"><i class="fa fa-plus"></i></a>
                    </el-tooltip>
                </li>
            </ul>
        </div>
    </div>


    <div class="panel notice-box">
        <div class="panel-heading clearfix">
            <span class="left"><i class="fa fa-file-audio-o"></i>网站公告</span>
        </div>
        <div class="panel-body">
            <ul id="noticeList" class="title-list">
                <li class="item clearfix" v-for="item in noticeList">
                    <a class="title" :href="item.Url" target="_blank"><i class="fa fa-angle-right" aria-hidden="true"></i> {{item.Title}} <span class="date">/ {{item.Thedate}}</span></a>
                </li>
            </ul>
        </div>
    </div>

    <div class="panel sys-info">
        <div class="panel-heading"><i class="fa fa-calendar-o"></i>系统信息</div>
        <div class="panel-body">
            <table class="table">
                <tr>
                    <td>商业授权：</td>
                    <td>
                        <span v-show="cmsInfo.authorize"><i class="fa fa-id-card" aria-hidden="true"></i>已授权</span>
                        <span v-show="!cmsInfo.authorize">未授权</span>
                    </td>
                </tr>
                <tr>
                    <td width="150px">当前版本：</td>
                    <td>
                        V@(ViewBag.CurrentVersion)
                    </td>
                </tr>
                <tr>
                    <td>新版本检测：</td>
                    <td>
                        <span v-show="cmsInfo.latestVersion==-1"><i class="fa fa-spinner fa-spin"></i>正在检查更新</span>
                        <span v-show="cmsInfo.latestVersion==-2">由于网络问题，检测失败</span>
                        <span v-show="cmsInfo.latestVersion==1">当前已是最新版本</span>
                        <el-tooltip effect="dark" :value="showUpgradeTips" content="您好，系统有新的版本，请您尽快升级！" placement="right">
                            <a href="javascript:void(0)" v-show="cmsInfo.latestVersion===0" v-on:click="upgrade"><i class="fa fa-cloud-upload"></i>点击在线升级</a>
                        </el-tooltip>
                    </td>
                </tr>
                <tr v-if="cmsInfo.serviceExpire">
                    <td>售后服务：</td>
                    <td>
                        <span id="spServiceExpire">已到期</span>
                    </td>
                </tr>
                <tr>
                    <td>网站域名：</td>
                    <td>@Request.ServerVariables["SERVER_NAME"]:@Request.ServerVariables["SERVER_PORT"]</td>
                </tr>
                <tr>
                    <td>网站框架：</td>
                    <td><a href="http://www.pageadmin.net/" target="_blank">PageAdmin CMS内容管理系统</a></td>
                </tr>
                <tr>
                    <td>运行环境：</td>
                    <td>@Request.ServerVariables["SERVER_SOFTWARE"]   .Net @System.Environment.Version.ToString()</td>
                </tr>

                <tr>
                    <td>客户端/服务器IP：</td>
                    <td>@StringHelper.GetClientIP() <i>/</i> @Request.ServerVariables["LOCAL_ADDR"]</td>
                </tr>
                <tr>
                    <td>占用内存/总线程数：</td>
                    <td>@((((double)currentProcess.WorkingSet64) / 1024 / 1024).ToString("f2"))MB  <i>/</i> @currentProcess.Threads.Count</td>
                </tr>

                <tr>
                    <td>服务器目录：</td>
                    <td>@Server.MapPath("/")</td>
                </tr>
            </table>
        </div>
    </div>

</div>
<script type="text/javascript">
    var adminPath="@ViewBag.AdminPath";
    var vue = new Vue({
        el: "#main",
        data: {
            dialogVisible: false,
            avatar:"@Html.Raw(ViewBag.Avatar)",
            noticeList: [],
            quickMentList:[],
            cmsInfo: {latestVersion:-1, authorize: false, serviceExpire: false },
            isAuthorize: 1,
            showUpgradeTips:false,
        },
        created: function ()
        {
            if (isNullOrEmpty(this.avatar)) {
                this.avatar = "/areas/member/css/images/DefaultAvatar.png";
            }
        },
        methods: {
            loadQuickMenu: function () {
                var _this = this;
                this.ajax({url: "@Url.ActionUrl("ListData", "QuickMenu")",success: function (data) {
                    _this.quickMentList = data
                }
                });
            },
            upgrade:function(){
            location.href = "@Url.ActionUrl("index", "OnlineUpgrade")";
        },
        formatLink:function (link)
            {
               return link.replace("{admin}", adminPath);
            },
        }
    });

    function loadData() {
        ///加载公告
        vue.ajax({
            url: "@Url.ActionUrl("GetWebNotice")",
            data: { number: 6},
            success: function (data) {
                vue.noticeList = data;
            }
        });
        //加载cms基本信息
        vue.ajax({
            url: "@Url.ActionUrl("CmsInfo")",
            success: function (result) {
                if (isNullOrEmpty(result)) {
                    return;
                }
                var latestVersion = result.LatestVersion;
                var authorize = result.Authorize;
                vue.cmsInfo.latestVersion = latestVersion;
                vue.isAuthorize = authorize;
                var serviceExpire = result.ServiceExpire;
                switch (latestVersion)
                {
                    case 0:
                        vue.showUpgradeTips = true;
                        break;
                    case 1:

                        break;
                    default:
                        vue.cmsInfo.latestVersion =-2;
                        break;
                }
                switch (authorize) {
                    case 1:
                        vue.cmsInfo.authorize = true;
                        if (serviceExpire == 1) {
                            vue.cmsInfo.serviceExpire = true;
                        }
                        break;
                }
            }
        });
        //加载快捷菜单
        vue.loadQuickMenu();
    }
    loadData();
</script>