增加管理员相关控制器及基础页面视图

*内容后续建设
This commit is contained in:
Chenx221 2024-03-21 14:01:44 +08:00
parent dcc7e23bab
commit cb75247978
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
5 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,80 @@
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
class AdminController extends Controller
{
/**
* @inheritDoc
*/
public function behaviors(): array
{
return array_merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'actions' => ['index', 'system', 'user', 'info'],
'roles' => ['admin'], // only admin can do these
]
],
],
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'index' => ['GET'],
'system' => ['GET'],
'user' => ['GET'],
'info' => ['GET'],
],
],
]
);
}
public function init(): void
{
parent::init();
$this->layout = 'admin_main';
}
/**
* @return string
*/
public function actionIndex(): string
{
return $this->render('index');
}
/**
* @return string
*/
public function actionSystem(): string
{
return $this->render('system');
}
/**
* @return string
*/
public function actionUser(): string
{
return $this->render('user');
}
/**
* @return string
*/
public function actionInfo(): string
{
return $this->render('info');
}
}

8
views/admin/index.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/** @var yii\web\View $this */
?>
<h1>admin/index</h1>
<p>
这里是管理员页面.建设中
</p>

8
views/admin/info.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/** @var yii\web\View $this */
?>
<h1>admin/index</h1>
<p>
这里是管理员页面.建设中
</p>

8
views/admin/system.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/** @var yii\web\View $this */
?>
<h1>admin/index</h1>
<p>
这里是管理员页面.建设中
</p>

8
views/admin/user.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/** @var yii\web\View $this */
?>
<h1>admin/index</h1>
<p>
这里是管理员页面.建设中
</p>