Browse Source

复制kcadmin,创建backend模块

wechat_public_accounts
linyao 5 years ago
parent
commit
acbc5d55db
  1. 26
      backend/assets/AppAsset.php
  2. 4
      backend/config/.gitignore
  3. 1
      backend/config/bootstrap.php
  4. 46
      backend/config/main.php
  5. 4
      backend/config/params.php
  6. 112
      backend/controllers/SiteController.php
  7. 1
      backend/models/.gitkeep
  8. 33
      backend/views/layouts/base.php
  9. 13
      backend/views/layouts/breadcrumb.php
  10. 7
      backend/views/layouts/footer.php
  11. 88
      backend/views/layouts/header.php
  12. 45
      backend/views/layouts/main.php
  13. 27
      backend/views/layouts/sidebar.php
  14. 27
      backend/views/site/error.php
  15. 6
      backend/views/site/index.php
  16. 34
      backend/views/site/login.php
  17. 68
      backend/views/site/test.php
  18. 2
      backend/web/assets/.gitignore
  19. 48
      backend/web/css/reset.css
  20. 52
      backend/web/css/site.css
  21. BIN
      backend/web/favicon.ico
  22. BIN
      backend/web/img/avatar.png
  23. BIN
      backend/web/img/avatar04.png
  24. BIN
      backend/web/img/avatar2.png
  25. BIN
      backend/web/img/avatar3.png
  26. BIN
      backend/web/img/avatar5.png
  27. BIN
      backend/web/img/credit/american-express.png
  28. BIN
      backend/web/img/credit/cirrus.png
  29. BIN
      backend/web/img/credit/mastercard.png
  30. BIN
      backend/web/img/credit/mestro.png
  31. BIN
      backend/web/img/credit/paypal.png
  32. BIN
      backend/web/img/credit/paypal2.png
  33. BIN
      backend/web/img/credit/visa.png
  34. BIN
      backend/web/img/default-50x50.gif
  35. BIN
      backend/web/img/icons.png
  36. BIN
      backend/web/img/photo1.png
  37. BIN
      backend/web/img/photo2.png
  38. BIN
      backend/web/img/photo3.jpg
  39. BIN
      backend/web/img/photo4.jpg
  40. BIN
      backend/web/img/user1-128x128.jpg
  41. BIN
      backend/web/img/user2-160x160.jpg
  42. BIN
      backend/web/img/user3-128x128.jpg
  43. BIN
      backend/web/img/user4-128x128.jpg
  44. BIN
      backend/web/img/user5-128x128.jpg
  45. BIN
      backend/web/img/user6-128x128.jpg
  46. BIN
      backend/web/img/user7-128x128.jpg
  47. BIN
      backend/web/img/user8-128x128.jpg
  48. 20
      backend/web/index.php
  49. 0
      backend/web/js/common.js

26
backend/assets/AppAsset.php

@ -0,0 +1,26 @@
<?php
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/common.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset',
'blobt\web\AdminlteAsset',
];
}

4
backend/config/.gitignore

@ -0,0 +1,4 @@
codeception-local.php
main-local.php
params-local.php
test-local.php

1
backend/config/bootstrap.php

@ -0,0 +1 @@
<?php

46
backend/config/main.php

@ -0,0 +1,46 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
return [
'id' => 'backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the app
'name' => 'backend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
],
'params' => $params,
];

4
backend/config/params.php

@ -0,0 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

112
backend/controllers/SiteController.php

@ -0,0 +1,112 @@
<?php
namespace backend\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use common\models\CategorySearch;
/**
* Site controller
*/
class SiteController extends Controller {
/**
* {@inheritdoc}
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error', 'test'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
// 'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'upload'=>[
'class'=>'iron\actions\UploadAction',
]
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex() {
return $this->render('index');
}
/**
* Login action.
*
* @return string
*/
public function actionLogin() {
$this->layout = 'base';
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
}
/**
* Logout action.
*
* @return string
*/
public function actionLogout() {
Yii::$app->user->logout();
return $this->goHome();
}
public function actionTest() {
$searchModel = new CategorySearch();
return $this->render('test', [
'name' => 'blobt',
'model' => $searchModel
]);
}
}

1
backend/models/.gitkeep

@ -0,0 +1 @@
*

33
backend/views/layouts/base.php

@ -0,0 +1,33 @@
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use kcadmin\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

13
backend/views/layouts/breadcrumb.php

@ -0,0 +1,13 @@
<?PHP
use yii\widgets\Breadcrumbs;
?>
<?php if (!empty($this->title)): ?>
<h1><?= $this->title ?><?php if (isset($this->params['subtitle'])): ?><small><?= $this->params['subtitle'] ?></small><?php endif ?></h1>
<?php endif ?>
<?php
echo Breadcrumbs::widget([
'tag' => 'ol',
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);
?>

7
backend/views/layouts/footer.php

@ -0,0 +1,7 @@
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 0.1.0
</div>
<strong>Copyright &copy; 2014-2019 <a href="https://kuaichuangkeji.com">KcAdmin</a>.</strong> All rights
reserved.
</footer>

88
backend/views/layouts/header.php

@ -0,0 +1,88 @@
<?php
use yii\helpers\Html;
?>
<header class="main-header">
<!-- Logo -->
<a href="/" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>K</b>c</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg"><b>KC</b>admin</span>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top">
<div class="navbar-menu">
<ul class="nav navbar-nav">
<li>
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
</li>
<!-- TODO:后续处理 -->
<!--li class="user user-menu">
<a href="#">
<i class="fa fa-dashboard"></i>
<span class="hidden-xs">面板</span>
</a>
</li>
<li class="user user-menu">
<a href="#">
<i class="fa fa-shopping-cart"></i>
<span class="hidden-xs">商城</span>
</a>
</li>
<li class="user user-menu">
<a href="#">
<i class="fa fa-wechat"></i>
<span class="hidden-xs">微信</span>
</a>
</li>
<li class="user user-menu">
<a href="#">
<i class="fa fa-cubes"></i>
<span class="hidden-xs">进销存</span>
</a>
</li>
<li class="user user-menu">
<a href="#">
<i class="fa fa-cogs"></i>
<span class="hidden-xs">系统</span>
</a>
</li-->
</ul>
</div>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs"><?= yii::$app->user->identity->username ?></span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p>
<?= yii::$app->user->identity->username ?>
<small>Member since <?= date('m-d-Y', yii::$app->user->identity->created_at) ?></small>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<?= Html::a('个人设置', ['/site/profile'], ['class' => 'btn btn-default btn-flat']) ?>
</div>
<div class="pull-right">
<?= Html::a('退出', ['/site/logout'], ['data-method' => 'post', 'class' => 'btn btn-default btn-flat']) ?>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>

45
backend/views/layouts/main.php

@ -0,0 +1,45 @@
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use kcadmin\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body class="hold-transition skin-blue-light sidebar-mini">
<?php $this->beginBody() ?>
<div class="wrapper">
<?= $this->render('header') ?>
<?= $this->render('sidebar') ?>
<div class="content-wrapper">
<section class="content-header">
<?= $this->render('breadcrumb') ?>
</section>
<section class="content">
<?= $content ?>
</section>
</div>
<?= $this->render('footer') ?>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

27
backend/views/layouts/sidebar.php

@ -0,0 +1,27 @@
<?php
use blobt\widgets\Menu;
?>
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<?php
echo Menu::widget([
'items' => [
['label' => 'MAIN NAVIGATION', 'is_header' => true],
['label' => 'IndexController', 'url' => '#', 'icon' => 'fa-hand-o-right', 'items' => [
['label' => 'Index', 'url' => ['site/index', 'tag' => 'new']],
['label' => 'Test', 'url' => ['site/test']],
]
],
['label' => 'Category', 'url' => '#', 'icon' => 'fa-barcode', 'items' => [
['label' => 'List', 'url' => ['category/index', 'tag' => 'new']],
['label' => 'Create', 'url' => ['category/create', 'tag' => 'popular']],
]
]
]
]);
?>
</section>
<!-- /.sidebar -->
</aside>

27
backend/views/site/error.php

@ -0,0 +1,27 @@
<?php
/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
use yii\helpers\Html;
$this->title = $name;
?>
<div class="site-error">
<h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>

6
backend/views/site/index.php

@ -0,0 +1,6 @@
<?php
/* @var $this yii\web\View */
$this->title = 'Dashboard';
$this->params['subtitle'] = 'Control panel';
$this->params['breadcrumbs'][] = $this->title;
?>

34
backend/views/site/login.php

@ -0,0 +1,34 @@
<?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
$this->title = '系统登录';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="login-body">
<div class="login-form col-md-3 offset-md-4">
<h2><?= Html::encode($this->title) ?></h2>
<h6 class="login-tips font-small-3 line text-muted"><span>Login with Blobt Admin</span></h6>
<div class="row">
<div class="col-lg-12">
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
</div>

68
backend/views/site/test.php

@ -0,0 +1,68 @@
<?PHP
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use blobt\widgets\DateRangePicker;
$this->title = '测试';
$this->params['subtitle'] = '这是一个小小的测试';
$this->params['breadcrumbs'][] = $this->title;
/* @var $this yii\web\View */
/* @var $model common\models\CategorySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="col-sm-11">
<div class="dataTables_filter">
<?=
$form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索的id",
"class" => "form-control"
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?=
$form->field($model, 'cat_name', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索类名",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?=
$form->field($model, "created_at", [
"template" => "{input}{error}",
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
</div>
<div class="col-sm-1" style="padding: 0;">
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>

2
backend/web/assets/.gitignore

@ -0,0 +1,2 @@
*
!.gitignore

48
backend/web/css/reset.css

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

52
backend/web/css/site.css

@ -0,0 +1,52 @@
/*公共样式*/
/*登录页*/
.login-body{
display: flex;
align-items: center;
height: 100vh;
}
.login-body .line {
border-bottom: 1px solid #dadada;
line-height: 0.1em;
margin: 10px 0 20px;
}
.login-body .line span {
background: #fff;
padding: 0 10px;
}
.login-form {
box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin: 0 auto;
}
.login-form h2{
text-align: center;
margin-bottom: 20px;
}
.login-form h6 {
text-align: center;
}
/*修复select2插件 from表框颜色不生效*/
.form-group.has-error .select2-selection, .form-group.has-error .select2-selection {
border-color: #dd4b39;
box-shadow: none;
}
.form-group.has-success .select2-selection, .form-group.has-success .select2-selection {
border-color: #00a65a;
box-shadow: none;
}
.icheck-label-group {
padding-top: 2px;
}
.icheck-label-group label{
margin-right: 20px;
}

BIN
backend/web/favicon.ico

BIN
backend/web/img/avatar.png

After

Width: 215  |  Height: 215  |  Size: 7.9 KiB

BIN
backend/web/img/avatar04.png

After

Width: 215  |  Height: 215  |  Size: 13 KiB

BIN
backend/web/img/avatar2.png

After

Width: 215  |  Height: 215  |  Size: 8.1 KiB

BIN
backend/web/img/avatar3.png

After

Width: 215  |  Height: 215  |  Size: 9.0 KiB

BIN
backend/web/img/avatar5.png

After

Width: 215  |  Height: 215  |  Size: 7.4 KiB

BIN
backend/web/img/credit/american-express.png

After

Width: 51  |  Height: 32  |  Size: 2.1 KiB

BIN
backend/web/img/credit/cirrus.png

After

Width: 51  |  Height: 32  |  Size: 1.5 KiB

BIN
backend/web/img/credit/mastercard.png

After

Width: 51  |  Height: 32  |  Size: 1.6 KiB

BIN
backend/web/img/credit/mestro.png

After

Width: 52  |  Height: 32  |  Size: 1.5 KiB

BIN
backend/web/img/credit/paypal.png

After

Width: 101  |  Height: 64  |  Size: 2.0 KiB

BIN
backend/web/img/credit/paypal2.png

After

Width: 51  |  Height: 32  |  Size: 1.2 KiB

BIN
backend/web/img/credit/visa.png

After

Width: 51  |  Height: 32  |  Size: 1.0 KiB

BIN
backend/web/img/default-50x50.gif

After

Width: 50  |  Height: 50  |  Size: 184 B

BIN
backend/web/img/icons.png

After

Width: 61  |  Height: 37  |  Size: 1.1 KiB

BIN
backend/web/img/photo1.png

After

Width: 1250  |  Height: 835  |  Size: 656 KiB

BIN
backend/web/img/photo2.png

After

Width: 1254  |  Height: 836  |  Size: 412 KiB

BIN
backend/web/img/photo3.jpg

After

Width: 2000  |  Height: 1333  |  Size: 383 KiB

BIN
backend/web/img/photo4.jpg

After

Width: 2000  |  Height: 1320  |  Size: 1.1 MiB

BIN
backend/web/img/user1-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 2.8 KiB

BIN
backend/web/img/user2-160x160.jpg

After

Width: 160  |  Height: 160  |  Size: 6.9 KiB

BIN
backend/web/img/user3-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 3.4 KiB

BIN
backend/web/img/user4-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 3.4 KiB

BIN
backend/web/img/user5-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 6.3 KiB

BIN
backend/web/img/user6-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 4.2 KiB

BIN
backend/web/img/user7-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 6.3 KiB

BIN
backend/web/img/user8-128x128.jpg

After

Width: 128  |  Height: 128  |  Size: 4.9 KiB

20
backend/web/index.php

@ -0,0 +1,20 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();

0
backend/web/js/common.js

Loading…
Cancel
Save