pref: 增加服务类优化UI版面

This commit is contained in:
Ying
2023-06-19 14:32:30 +08:00
parent 27eda6f37f
commit 2b8f874450
148 changed files with 3933 additions and 9286 deletions

View File

@@ -26,7 +26,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\facade\Cache;
use support\Cache;
use Webman\Http\Request;
/**
@@ -155,14 +155,13 @@ class Admin extends AdminController
return $this->error('该用户名或邮箱已被注册!');
}
// 管理员加密
$post['pwd'] = encryptPwd($post['pwd']);
$post['create_ip'] = request()->getRealIp();
$data = $this->model->create($post);
if (!is_empty($data->id)) {
$access['admin_id'] = $data->id;
$access['group_id'] = $data->group_id;
if (!is_empty($data['id'])) {
$access['admin_id'] = $data['id'];
$access['group_id'] = $data['group_id'];
AdminAccessModel::insert($access);
return $this->success('添加管理员成功!');
} else {
@@ -182,95 +181,84 @@ class Admin extends AdminController
if (request()->isPost()) {
$id = request()->input('id');
if (!empty($id) && is_numeric($id)) {
// 验证数据
$post = request()->all();
$post = request_validate_rules($post, get_class($this->model), 'edit');
if (!is_array($post)) {
return $this->error($post);
$retError = request_validate_rules($post, get_class($this->model), 'edit');
if (!is_array($retError)) {
return $this->error($retError);
}
if (!empty($post['pwd'])) {
if (isset($post['pwd']) && !empty($post['pwd'])) {
$post['pwd'] = encryptPwd($post['pwd']);
} else {
// 清空避免被覆盖
unset($post['pwd']);
}
if ($this->model->update($post)) {
$access['group_id'] = $post['group_id'];
AdminAccessModel::where('admin_id', $id)->update($access);
return $this->success('更新管理员成功!');
} else {
return $this->error('更新管理员失败');
}
}
}
return $this->error('更新管理员失败');
}
/**
* 编辑权限
* @return Response
*/
public function editRules()
public function editRules(): Response
{
if (request()->isPost()) {
return $this->_update_RuleCates();
}
return $this->updateRuleCates();
}
/**
* 编辑栏目权限
* @return Response
*/
public function editCates()
public function editCates(): Response
{
return $this->_update_RuleCates(AUTH_CATE);
return $this->updateRuleCates(AUTH_CATE);
}
/**
* 更新权限函数
* @access protected
* @param string $type
* @return \support\Response|void
* @return Response
*/
protected function _update_RuleCates(string $type = AUTH_RULES)
protected function updateRuleCates(string $type = AUTH_RULES): Response
{
if (request()->isPost()) {
$admin_id = input('admin_id');
$rules = request()->post($type) ?? [];
$access = $this->auth->getRulesNode($admin_id, $type);
$rules = array_diff($rules, $access[$this->auth->authGroup]);
$admin_id = input('admin_id');
$rules = request()->post($type) ?? [];
if (!empty($admin_id) && $admin_id > 0) {
$access = $this->auth->getRulesNode($admin_id, $type);
$rules = array_diff($rules, $access[$this->auth->authGroup]);
// 权限验证
if (!$this->auth->checkRuleOrCateNodes($rules, $type, $this->auth->authPrivate)) {
return $this->error('没有权限!');
}
// 获取个人节点
$differ = array_diff($access[$this->auth->authPrivate], $access[$this->auth->authGroup]);
$current = [];
if (!$this->auth->superAdmin()) {
$current = $this->auth->getRulesNode();
$current = array_diff($differ, $current[$this->auth->authPrivate]);
}
$rules = array_unique(array_merge($rules, $current));
$AdminAccessModel = new AdminAccessModel();
$data = [
"$type" => implode(',', $rules)
];
if ($AdminAccessModel->where('admin_id', $admin_id)->save($data)) {
return $this->success('更新权限成功!');
}
return $this->error('更新权限失败!');
}
// 权限验证
if (!$this->auth->checkRuleOrCateNodes($rules, $type, $this->auth->authPrivate)) {
return $this->error('没有权限!');
}
// 获取个人节点
$differ = array_diff($access[$this->auth->authPrivate], $access[$this->auth->authGroup]);
$current = [];
if (!$this->auth->superAdmin()) {
$current = $this->auth->getRulesNode();
$current = array_diff($differ, $current[$this->auth->authPrivate]);
}
$rules = array_unique(array_merge($rules, $current));
$AdminAccessModel = new AdminAccessModel();
$data = ["$type" => implode(',', $rules)];
if ($AdminAccessModel->update($data, ['admin_id' => $admin_id])) {
return $this->success('更新权限成功!');
}
return $this->error('更新权限失败!');
}
/**
@@ -278,7 +266,7 @@ class Admin extends AdminController
* getAdminRules
* @return mixed
*/
public function getPermissions()
public function getPermissions(): mixed
{
$list = [];
if (\request()->isAjax()) {
@@ -666,7 +654,7 @@ class Admin extends AdminController
// 清理内容
if ($type == 'all' || $type == 'content') {
$session = session(AdminSession);
\think\facade\Cache::clear();
\support\Cache::clear();
request()->session()->set(AdminSession, $session);
}

View File

@@ -50,34 +50,14 @@ class AdminRules extends AdminController
}
// 获取总数
$total = $this->model->count();
$total = $this->model->where($where)->count();
$list = $this->model->where($where)->order('sort asc')->select()->toArray();
foreach ($list as $key => $value) {
$list[$key]['title'] = __($value['title']);
}
// 自定义查询
if (count($list) < $total) {
$parentNode = []; // 查找父节点
foreach ($list as $key => $value) {
if ($value['pid'] !== 0 && !list_search($list,['id'=>$value['pid']])) {
$parentNode[] = $this->parentNode($value['pid']);
}
}
foreach ($parentNode as $key => $value) {
$list = array_merge($list,$value);
}
}
$rules = $this->model->getListTree();
return $this->success('获取成功', '',[
'item'=> $list,
'rules'=> $rules
],
count($list),0);
$rules = list_to_tree($list,'id','pid','children',0);
return $this->success('获取成功', '/',$rules, $total);
}

View File

@@ -73,11 +73,7 @@ class Department extends AdminController
}
$depart = $this->model->getListTree();
return $this->success('获取成功', '',[
'item'=> $list,
'depart'=> $depart
],
count($list));
return $this->success('获取成功', '',$depart, $total);
}
return view('system/department/index');

View File

@@ -81,7 +81,7 @@ class Plugin extends AdminController
return $this->error('请勿重复安装插件');
}
// try {
try {
$pluginZip = self::downLoad($name, ['name' => $name, 'token' => input('token')]);
ZipArchives::unzip($pluginZip, plugin_path(), '', true);
@@ -95,10 +95,10 @@ class Plugin extends AdminController
self::pluginMenu($name);
self::executeSql($name);
self::enabled($name);
// } catch (\Throwable $th) {
// recursive_delete($pluginPath);
// return $this->error($th->getMessage(), null, self::$ServerBody, $th->getCode());
// }
} catch (\Throwable $th) {
recursive_delete($pluginPath);
return $this->error($th->getMessage(), null, self::$ServerBody, $th->getCode());
}
return $this->success('插件安装成功', null, get_plugin_config($name, true));
}
@@ -295,17 +295,15 @@ class Plugin extends AdminController
if (request()->isPost()) {
$post['extends'] = input('extends');
$post['rewrite'] = input('rewrite');
foreach ($post['rewrite'] as $kk=>$vv)
{
if($kk[0]!='/')return $this->error('伪静态变量名称“'.$kk.'" 必须以“/”开头');
$post['rewrite'][$kk]=str_replace('\\','/',trim($vv,'/\\'));
$value=explode('/',$post['rewrite'][$kk]);
if(count($value)<2){
return $this->error('伪静态规则变量值,不符合规则');
foreach ($post['rewrite'] as $kk => $vv) {
if ($kk[0] != '/') return $this->error('伪静态变量名称“' . $kk . '" 必须以“/”开头');
$post['rewrite'][$kk] = str_replace('\\', '/', trim($vv, '/\\'));
$value = explode('/', $post['rewrite'][$kk]);
if (count($value) < 2) {
return $this->error('伪静态不符合规则');
}
if(strtoupper($value[count($value)-2][0]) !== $value[count($value)-2][0])
{
return $this->error('伪静态规则变量值中,控制器首字母必须大写哦');
if (strtoupper($value[count($value) - 2][0]) !== $value[count($value) - 2][0]) {
return $this->error('控制器首字母必须大写');
}
}
$config = array_merge($config, $post);

View File

@@ -21,7 +21,6 @@ use system\Random;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use Webman\Http\Request;
/**
* 用户管理