增加单用户站点模式

This commit is contained in:
WispX 2020-03-18 14:25:36 +08:00
parent 807c96d68b
commit ef797c2847
8 changed files with 378 additions and 1 deletions

View File

@ -36,7 +36,8 @@
* [x] (Dark)暗黑主题
* [x] IP 封禁功能
* [x] 自定义链接参数
* [ ] 图片广场
* [x] 单用户模式
* [ ] 图片广场
...
### 🛠 安装要求

View File

@ -9,11 +9,29 @@
namespace app\index\controller;
use app\common\model\Images;
use app\common\model\Users;
use think\Exception;
class Index extends Base
{
public function index()
{
// 是否是单用户模式
if (env('system.single_user_mode') && !request()->user) {
if ($this->request->isPost()) {
try {
$account = $this->request->post('account');
$password = $this->request->post('password');
$field = filter_var($account, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
Users::login($account, $password, $field);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success('欢迎回来');
}
return view('index/home');
}
$this->assign('images_count', Images::cache(120)->count());
return $this->fetch();
}

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
<title>{$config.site_name}</title>
<link rel="stylesheet" href="/static/app/css/home.css">
<!--[if IE]>
<script>window.location.href = '/compatibility.html';</script>
<![endif]-->
</head>
<body>
<div id="bg"></div>
<div id="mask"></div>
<div id="login-btn">SIGN IN</div>
<div id="login-box">
<input type="text" name="account" placeholder="请输入用户名或邮箱">
<input type="password" name="password" placeholder="请输入密码">
<button type="button" id="login">登录</button>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script>
$('#login-btn').click(function () {
$(this).hide();
$('body').addClass('fade')
});
$('#login').click(function () {
$.ajax({
url: '',
type: 'post',
data: {
account: $('[name=account]').val(),
password: $('[name=password]').val(),
},
success: function (response) {
alert(response.msg);
if (response.code) {
history.go(0)
}
}
});
});
</script>
</html>

View File

@ -7,6 +7,8 @@
*/
return [
// 是否开启单用户模式
'single_user_mode' => env('single_user_mode', false),
// 违规图片是否直接拦截
'intercept_salacity' => env('system.intercept_salacity', false),
// 图片链接额外参数(例: ?test=123)

View File

@ -0,0 +1,165 @@
*,
*:before,
*:after {
box-sizing: border-box;
}
a {
color: #03A9F4;
}
a,
a:hover,
a:active,
a:focus {
text-decoration: none;
}
a:focus {
outline-style: none;
}
audio,
body,
caption,
div,
footer,
form,
h1,
h2,
h3,
h4,
h5,
h6,
header,
html,
iframe,
label,
legend,
li,
main,
mark,
menu,
nav,
ol,
p,
section,
span,
summary,
table,
textarea,
time,
ul,
video {
padding: 0;
margin: 0;
border: 0;
outline: 0 none;
}
html {
position: relative;
min-height: 100%;
}
html,
body {
width: 100%;
margin: 0;
padding: 0;
}
body,
body #mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow: hidden;
width: 100%;
height: 100%;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
}
#bg {
position: absolute;
width: 100%;
height: 100%;
background-image: url("/static/app/images/bg.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: center;
filter: blur(0px);
transition: filter 0.5s, background-size 0.5s;
}
#login-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #35bc9d;
letter-spacing: 2px;
height: 50px;
line-height: 50px;
cursor: pointer;
border-radius: 5px;
color: white;
font-size: 1.3rem;
text-align: center;
padding: 0 1rem;
font-family: inherit;
font-weight: normal;
box-shadow: 0 0 20px 0 rgba(5, 143, 220, 0.33);
z-index: 3;
}
#mask {
opacity: 0.4;
background-color: #1b1f23;
z-index: 1;
}
#login-box {
display: flex;
flex-direction: column;
max-width: 500px;
max-height: 300px;
border-radius: 10px;
text-align: center;
padding: 1rem;
background-color: white;
box-shadow: 0 0 20px 0 rgba(186, 186, 186, 0.49);
transition: all 0.7s;
transform: scale(2);
opacity: 0;
z-index: 2;
}
#login-box input {
width: 100%;
border-radius: 20px;
height: 40px;
border: 0;
outline: 0;
padding: 0.8rem;
background-color: #e3e3e3;
}
#login-box input:first-child {
margin-bottom: 10px;
}
#login-box button {
width: 100%;
color: white;
background-color: #1abc9c;
border-radius: 10px;
text-align: center;
height: 35px;
line-height: 35px;
margin-top: 10px;
outline: 0;
border: 0;
cursor: pointer;
}
body.fade #login-box {
opacity: 1;
transform: scale(1.3);
}
body.fade #bg {
filter: blur(2px);
background-size: 105% 105%;
}
/*# sourceMappingURL=home.css.map */

View File

@ -0,0 +1 @@
{"version":3,"sources":["home.less"],"names":[],"mappings":"AAAA;AAAG,CAAC;AAAS,CAAC;EACZ,sBAAA;;AAGF;EACE,cAAA;;AAGF;AAAG,CAAC;AAAQ,CAAC;AAAS,CAAC;EACrB,qBAAA;;AAGF,CAAC;EACC,mBAAA;;AAGF;AAAO;AAAM;AAAS;AAAK;AAAQ;AAAM;AAAI;AAAI;AAAI;AAAI;AAAI;AAAI;AAAQ;AAAM;AAAQ;AAAO;AAAQ;AAAI;AAAM;AAAM;AAAM;AAAK;AAAI;AAAG;AAAS;AAAM;AAAS;AAAO;AAAU;AAAM;AAAI;EACzL,UAAA;EACA,SAAA;EACA,SAAA;EACA,eAAA;;AAGF;EACE,kBAAA;EACA,gBAAA;;AAGF;AAAM;EACJ,WAAA;EACA,SAAA;EACA,UAAA;;AAGF;AAAM,IAAK;EACT,eAAA;EACA,MAAA;EACA,OAAA;EACA,SAAA;EACA,QAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;EACA,cAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,qBAAA;;AAGF;EACE,kBAAA;EACA,WAAA;EACA,YAAA;EACA,sBAAsB,4BAAtB;EACA,4BAAA;EACA,0BAAA;EACA,2BAAA;EACA,QAAQ,SAAR;EACA,6CAAA;;AAGF;EACE,kBAAA;EACA,QAAA;EACA,SAAA;EACA,WAAW,qBAAX;EACA,yBAAA;EACA,mBAAA;EACA,YAAA;EACA,iBAAA;EACA,eAAA;EACA,kBAAA;EACA,YAAA;EACA,iBAAA;EACA,kBAAA;EACA,eAAA;EACA,oBAAA;EACA,mBAAA;EACA,8CAAA;EACA,UAAA;;AAGF;EACE,YAAA;EACA,yBAAA;EACA,UAAA;;AAGF;EACE,aAAA;EACA,sBAAA;EACA,gBAAA;EACA,iBAAA;EACA,mBAAA;EACA,kBAAA;EACA,aAAA;EACA,uBAAA;EACA,gDAAA;EACA,oBAAA;EACA,WAAW,QAAX;EACA,UAAA;EACA,UAAA;;AAbF,UAeE;EACE,WAAA;EACA,mBAAA;EACA,YAAA;EACA,SAAA;EACA,UAAA;EACA,eAAA;EACA,yBAAA;;AAEA,UATF,MASG;EACC,mBAAA;;AAzBN,UA6BE;EACE,WAAA;EACA,YAAA;EACA,yBAAA;EACA,mBAAA;EACA,kBAAA;EACA,YAAA;EACA,iBAAA;EACA,gBAAA;EACA,UAAA;EACA,SAAA;EACA,eAAA;;AAIJ,IAAI,KACF;EACE,UAAA;EACA,WAAW,UAAX;;AAHJ,IAAI,KAKF;EACE,QAAQ,SAAR;EACA,0BAAA","file":"home.css"}

View File

@ -0,0 +1,143 @@
*, *:before, *:after {
box-sizing: border-box;
}
a {
color: #03A9F4;
}
a, a:hover, a:active, a:focus {
text-decoration: none;
}
a:focus {
outline-style: none;
}
audio, body, caption, div, footer, form, h1, h2, h3, h4, h5, h6, header, html, iframe, label, legend, li, main, mark, menu, nav, ol, p, section, span, summary, table, textarea, time, ul, video {
padding: 0;
margin: 0;
border: 0;
outline: 0 none;
}
html {
position: relative;
min-height: 100%;
}
html, body {
width: 100%;
margin: 0;
padding: 0;
}
body, body #mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow: hidden;
width: 100%;
height: 100%;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
}
#bg {
position: absolute;
width: 100%;
height: 100%;
background-image: url("/static/app/images/bg.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: center;
filter: blur(0px);
transition: filter .5s, background-size .5s;
}
#login-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #35bc9d;
letter-spacing: 2px;
height: 50px;
line-height: 50px;
cursor: pointer;
border-radius: 5px;
color: white;
font-size: 1.3rem;
text-align: center;
padding: 0 1rem;
font-family: inherit;
font-weight: normal;
box-shadow: 0 0 20px 0 rgba(5, 143, 220, 0.33);
z-index: 3;
}
#mask {
opacity: .4;
background-color: #1b1f23;
z-index: 1;
}
#login-box {
display: flex;
flex-direction: column;
max-width: 500px;
max-height: 300px;
border-radius: 10px;
text-align: center;
padding: 1rem;
background-color: white;
box-shadow: 0 0 20px 0 rgba(186, 186, 186, 0.49);
transition: all .7s;
transform: scale(2);
opacity: 0;
z-index: 2;
input {
width: 100%;
border-radius: 20px;
height: 40px;
border: 0;
outline: 0;
padding: .8rem;
background-color: #e3e3e3;
&:first-child {
margin-bottom: 10px;
}
}
button {
width: 100%;
color: white;
background-color: #1abc9c;
border-radius: 10px;
text-align: center;
height: 35px;
line-height: 35px;
margin-top: 10px;
outline: 0;
border: 0;
cursor: pointer;
}
}
body.fade {
#login-box {
opacity: 1;
transform: scale(1.3);
}
#bg {
filter: blur(2px);
background-size: 105% 105%;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB