mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
新增dataBrage用法;
This commit is contained in:
@@ -40,7 +40,11 @@ class Admin extends AdminController
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new SystemAdmin();
|
||||
$this->assign('auth_list', $this->model->getAuthList());
|
||||
$this->assign('auth_list', $this->model->getAuthList(),true);
|
||||
|
||||
$this->dataBrage['count'] = 10;
|
||||
$this->dataBrage['tips'] = '请谨慎操作';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{:sysconfig('site','site_name')}</title>
|
||||
@@ -26,7 +27,10 @@
|
||||
<script src="__STATIC__/plugs/require-2.3.6/require.js?v={$version}" charset="utf-8"></script>
|
||||
<script src="__STATIC__/config-admin.js?v={$version}" charset="utf-8"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{__CONTENT__}
|
||||
{__CONTENT__}
|
||||
<script style="display: none;" id="data-brage" type="text/plain">{$data_brage|raw|default='[]'}</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -90,6 +90,13 @@ class AdminController extends BaseController
|
||||
*/
|
||||
protected $isDemo = false;
|
||||
|
||||
/**
|
||||
* 多元传参
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dataBrage = [];
|
||||
|
||||
|
||||
/**
|
||||
* 初始化方法
|
||||
@@ -109,8 +116,13 @@ class AdminController extends BaseController
|
||||
* @param mixed $value 变量值
|
||||
* @return mixed
|
||||
*/
|
||||
public function assign($name, $value = null)
|
||||
public function assign($name, $value = null, $isAppendToDataBrage = false)
|
||||
{
|
||||
|
||||
if ($isAppendToDataBrage) {
|
||||
$this->dataBrage[$name] = $value;
|
||||
}
|
||||
|
||||
return $this->app->view->assign($name, $value);
|
||||
}
|
||||
|
||||
@@ -122,6 +134,9 @@ class AdminController extends BaseController
|
||||
*/
|
||||
public function fetch($template = '', $vars = [])
|
||||
{
|
||||
|
||||
$this->assign('data_brage', json_encode($this->dataBrage));
|
||||
|
||||
return $this->app->view->fetch($template, $vars);
|
||||
}
|
||||
|
||||
@@ -215,7 +230,8 @@ class AdminController extends BaseController
|
||||
/**
|
||||
* 初始化视图参数
|
||||
*/
|
||||
private function viewInit(){
|
||||
private function viewInit()
|
||||
{
|
||||
$request = app()->request;
|
||||
list($thisModule, $thisController, $thisAction) = [app('http')->getName(), app()->request->controller(), $request->action()];
|
||||
list($thisControllerArr, $jsPath) = [explode('.', $thisController), null];
|
||||
@@ -246,7 +262,8 @@ class AdminController extends BaseController
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function checkAuth(){
|
||||
private function checkAuth()
|
||||
{
|
||||
$adminConfig = config('admin');
|
||||
$adminId = session('admin.id');
|
||||
$expireTime = session('admin.expire_time');
|
||||
@@ -256,8 +273,10 @@ class AdminController extends BaseController
|
||||
$currentController = parse_name(app()->request->controller());
|
||||
|
||||
// 验证登录
|
||||
if (!in_array($currentController, $adminConfig['no_login_controller']) &&
|
||||
!in_array($currentNode, $adminConfig['no_login_node'])) {
|
||||
if (
|
||||
!in_array($currentController, $adminConfig['no_login_controller']) &&
|
||||
!in_array($currentNode, $adminConfig['no_login_node'])
|
||||
) {
|
||||
empty($adminId) && $this->error('请先登录后台', [], __url('admin/login/index'));
|
||||
|
||||
// 判断是否登录过期
|
||||
@@ -268,26 +287,27 @@ class AdminController extends BaseController
|
||||
}
|
||||
|
||||
// 验证权限
|
||||
if (!in_array($currentController, $adminConfig['no_auth_controller']) &&
|
||||
!in_array($currentNode, $adminConfig['no_auth_node'])) {
|
||||
if (
|
||||
!in_array($currentController, $adminConfig['no_auth_controller']) &&
|
||||
!in_array($currentNode, $adminConfig['no_auth_node'])
|
||||
) {
|
||||
$check = $authService->checkNode($currentNode);
|
||||
!$check && $this->error('无权限访问');
|
||||
|
||||
// 判断是否为演示环境
|
||||
if(env('adminsystem.is_demo', false) && app()->request->isPost()){
|
||||
if (env('adminsystem.is_demo', false) && app()->request->isPost()) {
|
||||
$this->error('演示环境下不允许修改');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 严格校验接口是否为POST请求
|
||||
*/
|
||||
protected function checkPostRequest(){
|
||||
protected function checkPostRequest()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error("当前请求不合法!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ define(["jquery", "easy-admin"], function ($, ea) {
|
||||
password_url: 'system.admin/password',
|
||||
};
|
||||
|
||||
var authList = ea.getDataBrage('auth_list',[]);
|
||||
var count = ea.getDataBrage('count',0);
|
||||
var tips = ea.getDataBrage('tips','');
|
||||
|
||||
console.log(authList);
|
||||
console.log(count);
|
||||
console.log(tips);
|
||||
|
||||
var Controller = {
|
||||
|
||||
index: function () {
|
||||
|
||||
@@ -464,7 +464,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
||||
} else {
|
||||
for (k in item) {
|
||||
var v = item[k];
|
||||
if(v.auth == undefined){
|
||||
if (v.auth == undefined) {
|
||||
v.auth = 'add'
|
||||
}
|
||||
if (admin.checkAuth(v.auth, elem)) {
|
||||
@@ -1587,7 +1587,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
||||
if (typeof defaultValue == 'undefined') {
|
||||
defaultValue = undefined;
|
||||
}
|
||||
|
||||
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
@@ -1595,8 +1595,25 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
||||
if (pair[0] == variable) { return decodeURIComponent(pair[1]); }
|
||||
}
|
||||
return defaultValue;
|
||||
},
|
||||
dataBrage: null,
|
||||
getDataBrage(name, defaultValue) {
|
||||
if (this.dataBrage == null) {
|
||||
this.dataBrage = JSON.parse($('#data-brage').text());
|
||||
}
|
||||
|
||||
if (typeof defaultValue == 'undefined') {
|
||||
defaultValue = undefined;
|
||||
}
|
||||
|
||||
if (typeof this.dataBrage[name] == 'undefined') {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return this.dataBrage[name];
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
return admin;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user