加载站点配置信息并返回到前端页

This commit is contained in:
Chenx221 2024-03-30 13:46:05 +08:00
parent 5b2c2564c9
commit e10f119811
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -2,6 +2,7 @@
namespace app\controllers; namespace app\controllers;
use app\models\SiteConfig;
use app\models\User; use app\models\User;
use app\models\UserSearch; use app\models\UserSearch;
use app\utils\AdminSword; use app\utils\AdminSword;
@ -14,6 +15,7 @@ use yii\db\StaleObjectException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\web\Controller; use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\Response; use yii\web\Response;
@ -72,10 +74,17 @@ class AdminController extends Controller
/** /**
* @return string * @return string
* @throws HttpException
*/ */
public function actionSystem(): string public function actionSystem(): string
{ {
return $this->render('system'); $siteConfig = new SiteConfig();
if(!$siteConfig->loadFromEnv()){
throw new HttpException(500, 'Fatal error, Unable to load site configuration from .env file.');
}
return $this->render('system',[
'siteConfig' => $siteConfig
]);
} }
/** /**