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