作者 开飞机的舒克

登录背景图修改

{"files":[],"license":"regular","licenseto":"10789","licensekey":"h8YbnJFE7QZAdgU5 GFjFJbmJZmHK1IHwEKCJLI2FIaH29SZNquUK1WNqXP4=","domains":["campus.cn"],"licensecodes":[],"validations":["c51a74160ee0aa6a19729b33d4a9fcdc"]}
\ No newline at end of file
... ...
<?php
namespace addons\loginvideo;
use app\admin\library\Auth;
use think\Addons;
/**
* 登录背景视频插件
*/
class Loginvideo extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enable()
{
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disable()
{
return true;
}
/**
* 响应输出前
*/
public function responseSend(\think\Response $params)
{
$request = \think\Request::instance();
$module = strtolower($request->module());
$controller = strtolower($request->controller());
$action = strtolower($request->action());
$config = $this->getConfig();
if (!$request->isAjax() && $module == 'admin' && $controller == 'index' && $action == 'login') {
$auth = Auth::instance();
if (!$auth->isLogin()) {
$config['background-image'] = $config['background-image'] ? cdnurl($config['background-image']) : '';
if ($config['background-video']) {
$videoArr = explode(',', $config['background-video']);
$videoCount = count($videoArr);
if ($videoCount > 1) {
$index = date("d") % $videoCount;
$config['background-video'] = isset($videoArr[$index]) ? $videoArr[$index] : $videoArr[0];
}
$config['background-video'] = $config['background-video'] ? cdnurl($config['background-video']) : '';
// 手机端禁用视频背景
if ($request->isMobile()) {
$config['background-video'] = '';
}
}
$this->view->assign('config', $config);
$content = $params->getContent();
$this->view->engine->layout(false);
$background = $this->view->fetch('view/background');
$content = str_replace('<body>', '<body>' . $background, $content);
$params->content($content);
}
}
}
}
... ...
<?php
return array(
array(
'name' => 'background-color',
'title' => '背景色',
'type' => 'string',
'content' =>
array(),
'value' => '',
'rule' => '',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
),
array(
'name' => 'background-image',
'title' => '背景图片URL',
'type' => 'image',
'content' =>
array(),
'value' => 'https://wx2.sinaimg.cn/large/0060lm7Tly1fvblyjxs3dj31hc0u0tc1.jpg',
'rule' => '',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
),
array(
'name' => 'background-video',
'title' => '背景视频URL',
'type' => 'file',
'content' =>
array(),
'value' => 'https://t1.aixinxi.net/o_1cnh2rofs19skpcq11u6g921qm9a.mp4',
'rule' => '',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
),
);
... ...
<?php
namespace addons\loginvideo\controller;
use think\addons\Controller;
class Index extends Controller
{
public function index()
{
$this->error("当前插件暂无前台页面");
}
}
... ...
name = loginvideo
title = 登录页视频背景
intro = 可以在登录页添加背景视频
author = Karson
website = https://www.fastadmin.net
version = 1.0.1
state = 1
url = /addons/loginvideo
license = regular
licenseto = 10789
... ...
{if $config['background-video']}
<div id="video_wrapper">
<video autoplay muted loop>
<source src="{$config['background-video']}" type="video/mp4">
</video>
</div>
{/if}
<style>
body {
{if $config['background-color'] || $config['background-image']}
background:{$config['background-color']} {if $config['background-image']}url("{$config['background-image']}"){/if};
{/if}
background-size:cover;
}
{if $config['background-video']}
#video_wrapper {
margin: 0px;
padding: 0px;
}
#video_wrapper video {
position: fixed;
top: 50%;
left: 50%;
z-index: -100;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
transform: translate(-50%, -50%);
}
{/if}
</style>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<html lang="{$config.language}">
<head>
{include file="common/meta" /}
<style type="text/css">
body {
color: #999;
background-color: #f1f4fd;
background-size: cover;
}
a {
color: #444;
color:#fff;
}
.login-panel{margin-top:150px;}
.login-screen {
max-width: 430px;
padding: 0;
margin: 100px auto 0 auto;
max-width:400px;
padding:0;
margin:100px auto 0 auto;
}
.login-screen .well {
border-radius: 3px;
-webkit-box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
background: rgba(255, 255, 255, 1);
border: none;
overflow: hidden;
padding: 0;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
background: rgba(255,255,255, 0.2);
}
@media (max-width: 767px) {
.login-screen .copyright {
text-align: center;
}
@media(max-width:767px) {
.login-screen {
padding: 0 20px;
padding:0 20px;
}
}
.profile-img-card {
width: 100px;
height: 100px;
margin: 10px auto;
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
margin: -93px auto 30px;
border: 5px solid #fff;
}
.profile-name-card {
text-align: center;
}
.login-head {
background: #899fe1;
}
.login-form {
padding: 40px 30px;
position: relative;
z-index: 99;
}
#login-form {
margin-top: 20px;
margin-top:20px;
}
#login-form .input-group {
margin-bottom: 15px;
margin-bottom:15px;
}
#login-form .form-control {
font-size: 13px;
}
</style>
<!--@formatter:off-->
{if $background}
<style type="text/css">
body{
background-image: url('{$background}');
}
</style>
<style type="text/css">
body{
background-image: url('{$background}');
}
</style>
{/if}
<!--@formatter:on-->
</head>
<body>
<div class="container">
<div class="login-wrapper">
<div class="login-wrapper" style="margin-top:200px">
<div class="login-screen">
<div class="well">
<div class="login-head">
<img src="__CDN__/assets/img/login-head.png" style="width:100%;"/>
</div>
<div class="login-form">
<img id="profile-img" class="profile-img-card" src="__CDN__/assets/img/avatar.png"/>
<img id="profile-img" class="profile-img-card" src="__CDN__/assets/img/avatar.png" />
<p id="profile-name" class="profile-name-card"></p>
<form action="" method="post" id="login-form">
<!--@AdminLoginFormBegin-->
<div id="errtips" class="hide"></div>
{:token()}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
<input type="text" class="form-control" id="pd-form-username" placeholder="{:__('Username')}" name="username" autocomplete="off" value="" data-rule="{:__('Username')}:required;username"/>
<input type="text" class="form-control" id="pd-form-username" placeholder="{:__('Username')}" name="username" autocomplete="off" value="" data-rule="{:__('Username')}:required;username" />
</div>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password"/>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password" />
</div>
<!--@CaptchaBegin-->
{if $Think.config.fastadmin.login_captcha}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length})" autocomplete="off"/>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length(4)" />
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span>
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span>
</div>
{/if}
<!--@CaptchaEnd-->
<div class="form-group checkbox">
<div class="form-group">
<label class="inline" for="keeplogin">
<input type="checkbox" name="keeplogin" id="keeplogin" value="1"/>
<input type="checkbox" name="keeplogin" id="keeplogin" value="1" />
{:__('Keep login')}
</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block" style="background:#708eea;">{:__('Sign in')}</button>
<button type="submit" class="btn btn-success btn-lg btn-block">{:__('Sign in')}</button>
</div>
<!--@AdminLoginFormEnd-->
</form>
</div>
</div>
... ... @@ -140,4 +103,4 @@
</div>
{include file="common/script" /}
</body>
</html>
</html>
\ No newline at end of file
... ...
... ... @@ -3,6 +3,9 @@
return [
'autoload' => false,
'hooks' => [
'response_send' => [
'loginvideo',
],
'module_init' => [
'qiniu',
'third',
... ...