Esempio n. 1
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var menuInfo = (MenuInfo)e.Item.DataItem;

            var ltlTitle   = (Literal)e.Item.FindControl("ltlTitle");
            var phMenus    = (PlaceHolder)e.Item.FindControl("phMenus");
            var rptMenus   = (Repeater)e.Item.FindControl("rptMenus");
            var ltlActions = (Literal)e.Item.FindControl("ltlActions");

            ltlTitle.Text = menuInfo.Title;

            var menuInfoList = MenuDao.GetMenuInfoList(menuInfo.Id);

            if (menuInfoList.Count > 0)
            {
                phMenus.Visible         = true;
                rptMenus.DataSource     = menuInfoList;
                rptMenus.ItemDataBound += RptMenus_ItemDataBound;
                rptMenus.DataBind();
            }

            ltlActions.Text = $@"
<a href=""{PageMenuSettings.GetRedirectUrl(menuInfo.Id, 0)}"" class=""m-r-10"" onclick=""event.stopPropagation();"">新增二级菜单</a>
<a href=""{PageMenuSettings.GetRedirectUrl(menuInfo.ParentId, menuInfo.Id)}"" class=""m-r-10"" onclick=""event.stopPropagation();"">编辑</a>
<a href=""{GetRedirectUrl()}?up={true}&parentId={menuInfo.ParentId}&menuId={menuInfo.Id}"" class=""m-r-10"">上升</a>
<a href=""{GetRedirectUrl()}?down={true}&parentId={menuInfo.ParentId}&menuId={menuInfo.Id}"" class=""m-r-10"">下降</a>
<script>function del() {{{Utils.SwalWarning("删除菜单", $"此操作将删除菜单“{menuInfo.Title}”,确认吗?", "取消", "删除", $"location.href = '{GetRedirectUrl()}?delete={true}&menuId={menuInfo.Id}'")}}}</script>
<a href=""javascript:;"" onclick=""event.stopPropagation();del();"">删除</a>";
        }
Esempio n. 2
0
        public static object LoadConfig(IRequest request)
        {
            var dict = new Dictionary <string, List <MenuInfo> >();

            foreach (var parentInfo in MenuDao.GetMenuInfoList(0))
            {
                dict.Add(parentInfo.Title, MenuDao.GetMenuInfoList(parentInfo.Id));
            }
            var systemConfig = Main.Instance.ConfigApi.SystemConfig;
            var homeConfig   = Utils.GetConfigInfo();

            var user  = Main.Instance.UserApi.GetUserInfoByUserName(request.UserName);
            var group = GroupDao.GetGroupInfo(GroupUserDao.GetGroupId(request.UserName)) ??
                        Utils.GetDefaultGroupInfo(Utils.GetConfigInfo());

            var weiboUrl  = string.Empty;
            var weixinUrl = string.Empty;
            var qqUrl     = string.Empty;

            var loginPlugin = Main.Instance.PluginApi.GetPlugin <LoginPlugin>(LoginPlugin.PluginId);

            if (loginPlugin != null)
            {
                if (loginPlugin.IsOAuthReady(OAuthType.Weibo))
                {
                    weiboUrl = loginPlugin.GetOAuthLoginUrl(OAuthType.Weibo, string.Empty);
                }
                if (loginPlugin.IsOAuthReady(OAuthType.Weixin))
                {
                    weixinUrl = loginPlugin.GetOAuthLoginUrl(OAuthType.Weixin, string.Empty);
                }
                if (loginPlugin.IsOAuthReady(OAuthType.Qq))
                {
                    qqUrl = loginPlugin.GetOAuthLoginUrl(OAuthType.Qq, string.Empty);
                }
            }

            return(new
            {
                IsUserRegistrationAllowed = systemConfig.GetBool(SystemConfigAttribute.IsUserRegistrationAllowed),
                IsUserFindPassword = systemConfig.GetBool(SystemConfigAttribute.IsUserFindPassword),
                homeConfig.HomeUrl,
                homeConfig.Title,
                homeConfig.Copyright,
                homeConfig.BeianNo,
                homeConfig.LogoUrl,
                homeConfig.DefaultAvatarUrl,
                weiboUrl,
                weixinUrl,
                qqUrl,
                Menus = dict,
                User = user,
                Group = group
            });
        }
Esempio n. 3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (!Main.Instance.AdminApi.IsPluginAuthorized)
            {
                HttpContext.Current.Response.Write("<h1>未授权访问</h1>");
                HttpContext.Current.Response.End();
                return;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["delete"]) &&
                !string.IsNullOrEmpty(Request.QueryString["menuId"]))
            {
                MenuDao.Delete(Convert.ToInt32(Request.QueryString["menuId"]));
                LtlMessage.Text = Utils.GetMessageHtml("删除成功!", true);
            }
            else if (!string.IsNullOrEmpty(Request.QueryString["up"]) &&
                     !string.IsNullOrEmpty(Request.QueryString["parentId"]) &&
                     !string.IsNullOrEmpty(Request.QueryString["menuId"]))
            {
                MenuDao.UpdateTaxisToUp(Convert.ToInt32(Request.QueryString["parentId"]), Convert.ToInt32(Request.QueryString["menuId"]));
                LtlMessage.Text = Utils.GetMessageHtml("排序成功!", true);
            }
            else if (!string.IsNullOrEmpty(Request.QueryString["down"]) &&
                     !string.IsNullOrEmpty(Request.QueryString["parentId"]) &&
                     !string.IsNullOrEmpty(Request.QueryString["menuId"]))
            {
                MenuDao.UpdateTaxisToDown(Convert.ToInt32(Request.QueryString["parentId"]), Convert.ToInt32(Request.QueryString["menuId"]));
                LtlMessage.Text = Utils.GetMessageHtml("排序成功!", true);
            }

            if (IsPostBack)
            {
                return;
            }

            var menuInfoList = MenuDao.GetMenuInfoList(0);

            RptContents.DataSource     = menuInfoList;
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAdd.OnClientClick = $"location.href = '{PageMenuSettings.GetRedirectUrl(0, 0)}';return false;";
        }