重构代码:Login.cshtml页面重新整合到一个文件视图中,删除Loginm相关文件

This commit is contained in:
Argo-MacBookPro 2018-09-06 16:37:49 +08:00
parent 680c050a01
commit dc14356606
7 changed files with 132 additions and 220 deletions

View File

@ -1,7 +1,5 @@
using Bootstrap.Admin.Models; using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using Bootstrap.Security; using Bootstrap.Security;
using Longbow.Web;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -33,9 +31,7 @@ namespace Bootstrap.Admin.Controllers
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = remember == "true" }); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = remember == "true" });
return Redirect("~/"); return Redirect("~/");
} }
var mobile = Request.IsMobileDevice(); return View("Login", new ModelBase());
var model = Request.IPad();
return mobile && !model ? View("Loginm", new ModelBase()) : View("Login", new ModelBase());
} }
/// <summary> /// <summary>
/// Logout this instance. /// Logout this instance.

View File

@ -1,8 +1,111 @@
@model ModelBase @model ModelBase
@{ @{
ViewBag.Title = Model.Title; ViewBag.Title = Model.Title;
Layout = "~/Views/Shared/_Login.cshtml"; Layout = "~/Views/Shared/_Root.cshtml";
} }
@section css { @section css {
<environment include="Development">
<link href="~/css/bootstrap.css" rel="stylesheet">
<link href="~/css/font-awesome.css" rel="stylesheet" />
</environment>
<environment exclude="Development">
<link href="~/css/bootstrap.min.css" rel="stylesheet">
<link href="~/css/font-awesome.min.css" rel="stylesheet" />
</environment>
<link href="~/css/sweetalert.css" rel="stylesheet" />
<link href="~/css/theme.css" rel="stylesheet" />
<link href="~/css/login.css" rel="stylesheet" /> <link href="~/css/login.css" rel="stylesheet" />
<link href="~/css/login-responsive.css" rel="stylesheet" />
@if (!string.IsNullOrEmpty(Model.Theme))
{
<link href="~/css/@Model.Theme" rel="stylesheet" />
} }
}
@section javascript {
<environment include="Development">
<script src="~/js/bootstrap.bundle.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/sweetalert.js"></script>
</environment>
<environment exclude="Development">
<script src="~/js/bootstrap.bundle.min.js"></script>
<script src="~/js/jquery.validate.min.js"></script>
<script src="~/js/messages_zh.min.js"></script>
<script src="~/js/sweetalert.min.js"></script>
</environment>
<script src="~/js/longbow.common.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/login.js"></script>
}
@await Html.PartialAsync("SignIn")
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit" data-valid-modal="#dialogNew">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">新用户注册</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="userName">登陆账号:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user-plus"></span>
</div>
</div>
<input type="text" id="userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" value="" maxlength="50" remote="api/New/" data-remote-msg="此用户已存在" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="displayName">显示名称:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user-circle-o"></span>
</div>
</div>
<input type="text" id="displayName" class="form-control" value="" placeholder="显示名称不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="password">密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="password" class="form-control" value="" placeholder="密码不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="assurePassword">确认密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="assurePassword" class="form-control" value="" placeholder="确认密码" maxlength="50" equalTo="#password" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="description">申请理由:</label>
<textarea id="description" class="form-control" placeholder="申请理由500字以内" rows="3" maxlength="500" data-valid="true"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
<button type="button" class="btn btn-primary" id="btnSubmit">
<i class="fa fa-save"></i>
<span>提交</span>
</button>
</div>
</div>
</div>
</div>

View File

@ -1,8 +0,0 @@
@model ModelBase
@{
ViewBag.Title = Model.Title;
Layout = "~/Views/Shared/_Login.cshtml";
}
@section css {
<link href="~/css/loginm.css" rel="stylesheet" />
}

View File

@ -1,110 +0,0 @@
@model ModelBase
@{
ViewBag.Title = Model.Title;
Layout = "~/Views/Shared/_Root.cshtml";
}
@section css {
<environment include="Development">
<link href="~/css/bootstrap.css" rel="stylesheet">
<link href="~/css/font-awesome.css" rel="stylesheet" />
</environment>
<environment exclude="Development">
<link href="~/css/bootstrap.min.css" rel="stylesheet">
<link href="~/css/font-awesome.min.css" rel="stylesheet" />
</environment>
<link href="~/css/sweetalert.css" rel="stylesheet" />
<link href="~/css/theme.css" rel="stylesheet" />
@RenderSection("css", false)
@if (!string.IsNullOrEmpty(Model.Theme))
{
<link href="~/css/@Model.Theme" rel="stylesheet" />
}
}
@section javascript {
<environment include="Development">
<script src="~/js/bootstrap.bundle.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/sweetalert.js"></script>
</environment>
<environment exclude="Development">
<script src="~/js/bootstrap.bundle.min.js"></script>
<script src="~/js/jquery.validate.min.js"></script>
<script src="~/js/messages_zh.min.js"></script>
<script src="~/js/sweetalert.min.js"></script>
</environment>
<script src="~/js/longbow.common.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/login.js"></script>
}
@await Html.PartialAsync("SignIn")
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit" data-valid-modal="#dialogNew">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">新用户注册</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="userName">登陆账号:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user-plus"></span>
</div>
</div>
<input type="text" id="userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" value="" maxlength="50" remote="api/New/" data-remote-msg="此用户已存在" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="displayName">显示名称:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user-circle-o"></span>
</div>
</div>
<input type="text" id="displayName" class="form-control" value="" placeholder="显示名称不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="password">密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="password" class="form-control" value="" placeholder="密码不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="assurePassword">确认密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="assurePassword" class="form-control" value="" placeholder="确认密码" maxlength="50" equalTo="#password" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="description">申请理由:</label>
<textarea id="description" class="form-control" placeholder="申请理由500字以内" rows="3" maxlength="500" data-valid="true"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
<button type="button" class="btn btn-primary" id="btnSubmit">
<i class="fa fa-save"></i>
<span>提交</span>
</button>
</div>
</div>
</div>
</div>

View File

@ -1,12 +1,18 @@
@media (min-width: 375px) { @media (max-width: 767px) {
.form-signin { .form-signin {
width: 320px; margin: 0 auto;
background: #fff;
border-radius: 5px;
max-width: 320px;
border: solid 1px #ddd;
} }
} }
@media (min-width: 768px) { @media (min-width: 768px) {
body { body {
background: url('../images/bg2.jpg') fixed repeat; background-color: #5bc0de;
background: url('../images/bg2.jpg') fixed no-repeat;
background-size: 100% 100%;
} }
.container { .container {
@ -17,22 +23,15 @@
margin: 0 auto; margin: 0 auto;
} }
.form-signin { .form-signin-heading {
border: none; padding: 28px 0;
background: none; background-color: transparent;
width: auto;
}
.form-signin .form-signin-heading {
background: none;
margin-top: 10px;
}
.form-signin .input-group {
border: solid 1px #286090;
} }
.login-wrap { .login-wrap {
margin: 30px 0 0 370px; padding: 0;
margin: 36px 0 0 370px;
width: 280px;
height: 200px;
} }
} }

View File

@ -1,27 +1,19 @@
body { body {
background-color: #5bc0de; color: #797979;
background: url('../images/bg2.jpg') fixed no-repeat; background-color: #f1f2f7;
background-size: 100% 100%;
}
.container {
background: url('../images/bg3.png') no-repeat;
background-size: contain;
width: 704px;
height: 404px;
margin: 0 auto;
} }
.form-signin-heading { .form-signin-heading {
padding: 28px 0; margin: 0;
padding: 20px 15px;
text-align: center; text-align: center;
background-color: #41cac0;
border-radius: 5px 5px 0 0;
color: #fff; color: #fff;
} }
.login-wrap { .login-wrap {
margin: 36px 0 0 370px; padding: 20px;
width: 280px;
height: 200px;
} }
.login-footer a:last-child { .login-footer a:last-child {
@ -33,8 +25,10 @@
color: #fff; color: #fff;
text-transform: uppercase; text-transform: uppercase;
font-weight: 300; font-weight: 300;
box-shadow: 1px 1px #e56b60; font-family: 'Open Sans', sans-serif;
box-shadow: 0 4px #e56b60;
margin-bottom: 20px; margin-bottom: 20px;
outline: none !important;
margin-top: -8px; margin-top: -8px;
} }

View File

@ -1,62 +0,0 @@
body {
color: #797979;
background-color: #f1f2f7;
}
/*Login*/
.form-signin {
margin: 0 auto;
background: #fff;
border-radius: 5px;
-webkit-border-radius: 5px;
border: solid 1px #ddd;
}
.form-signin-heading {
margin: 0;
padding: 20px 15px;
text-align: center;
background: #41cac0;
border-radius: 5px 5px 0 0;
color: #fff;
}
.login-wrap {
padding: 20px;
}
.login-footer a:last-child {
float: right;
}
.btn-login {
background: #f67a6e;
color: #fff;
text-transform: uppercase;
font-weight: 300;
font-family: 'Open Sans', sans-serif;
box-shadow: 0 4px #e56b60;
margin-bottom: 20px;
outline: none !important;
margin-top: -8px;
}
@media (min-width: 375px) {
.form-signin {
width: 320px;
}
}
.form-control:focus, .form-control.is-valid:focus, .form-control.is-invalid:focus, .btn:focus, .btn:focus:active {
box-shadow: none;
}
.input-group-text {
background-color: #6bc3f4;
border-color: #1ca0e9;
line-height: 1.5;
}
.form-control {
border-color: #1ca0e9;
}