diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql old mode 100644 new mode 100755 diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index d6a6c0da..056d7a3b 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -73,6 +73,7 @@ class Index extends Backend $this->error($validate->getError(), $url, ['token' => $this->request->token()]); return; } + \app\admin\model\AdminLog::setTitle(__('Login')); $result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0); if ($result === true) { diff --git a/application/admin/controller/wechat/Autoreply.php b/application/admin/controller/wechat/Autoreply.php index fe1977cb..0de21275 100644 --- a/application/admin/controller/wechat/Autoreply.php +++ b/application/admin/controller/wechat/Autoreply.php @@ -14,6 +14,7 @@ class Autoreply extends Backend { protected $model = null; + protected $noNeedRight = ['check_text_unique']; public function _initialize() { @@ -46,4 +47,28 @@ class Autoreply extends Backend return $this->view->fetch(); } + /** + * 判断文本是否唯一 + * @internal + */ + public function check_text_unique() + { + $row = $this->request->post("row/a"); + $except = $this->request->post("except"); + $text = isset($row['text']) ? $row['text'] : ''; + if ($this->model->where('text', $text)->where(function($query) use($except) { + if ($except) + { + $query->where('text', '<>', $except); + } + })->count() == 0) + { + return json(['ok' => '']); + } + else + { + return json(['error' => __('Text already exists')]); + } + } + } diff --git a/application/admin/controller/wechat/Response.php b/application/admin/controller/wechat/Response.php index 295fe96b..d1bbb1a7 100644 --- a/application/admin/controller/wechat/Response.php +++ b/application/admin/controller/wechat/Response.php @@ -14,6 +14,7 @@ class Response extends Backend { protected $model = null; + protected $searchFields = 'id,title'; public function _initialize() { @@ -38,7 +39,7 @@ class Response extends Backend { $this->code = -1; $params = $this->request->post("row/a"); - $params['eventkey'] = $params['eventkey'] ? $params['eventkey'] : uniqid(); + $params['eventkey'] = isset($params['eventkey']) && $params['eventkey'] ? $params['eventkey'] : uniqid(); $params['content'] = json_encode($params['content']); $params['createtime'] = time(); if ($params) @@ -67,7 +68,7 @@ class Response extends Backend { $this->code = -1; $params = $this->request->post("row/a"); - $params['eventkey'] = $params['eventkey'] ? $params['eventkey'] : uniqid(); + $params['eventkey'] = isset($params['eventkey']) && $params['eventkey'] ? $params['eventkey'] : uniqid(); $params['content'] = json_encode($params['content']); if ($params) { diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index 76b1335a..a55c770f 100644 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -1,9 +1,6 @@ '保持会话', - 'Sign in' => '登入', - 'Username' => '用户名', 'User id' => '会员ID', 'Username' => '用户名', 'Nickname' => '昵称', @@ -49,6 +46,7 @@ return [ 'None' => '无', 'Home' => '主页', 'Online' => '在线', + 'Login' => '登录', 'Logout' => '注销', 'Profile' => '个人资料', 'Index' => '首页', diff --git a/application/admin/lang/zh-cn/wechat/autoreply.php b/application/admin/lang/zh-cn/wechat/autoreply.php index 883aed2c..6ba7061c 100644 --- a/application/admin/lang/zh-cn/wechat/autoreply.php +++ b/application/admin/lang/zh-cn/wechat/autoreply.php @@ -1,7 +1,8 @@ '文本', - 'Event key' => '响应标识', - 'Remark' => '备注', + 'Text' => '文本', + 'Event key' => '响应标识', + 'Remark' => '备注', + 'Text already exists' => '文本已经存在', ]; diff --git a/application/admin/model/AdminLog.php b/application/admin/model/AdminLog.php index 8177a233..b4f36687 100644 --- a/application/admin/model/AdminLog.php +++ b/application/admin/model/AdminLog.php @@ -12,29 +12,52 @@ class AdminLog extends Model // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = ''; + //自定义日志标题 + protected static $title = ''; + //自定义日志内容 + protected static $content = ''; + + public static function setTitle($title) + { + self::$title = $title; + } + + public static function setContent($content) + { + self::$content = $content; + } public static function record($title = '') { $admin = \think\Session::get('admin'); $admin_id = $admin ? $admin->id : 0; $username = $admin ? $admin->username : __('Unknown'); - $content = request()->param(); - foreach ($content as $k => $v) + $content = self::$content; + if (!$content) { - if (is_string($v) && strlen($v) > 200 || stripos($k, 'password') !== false) + $content = request()->param(); + foreach ($content as $k => $v) { - unset($content[$k]); + if (is_string($v) && strlen($v) > 200 || stripos($k, 'password') !== false) + { + unset($content[$k]); + } } } - $title = []; - $breadcrumb = \app\admin\library\Auth::instance()->getBreadcrumb(); - foreach ($breadcrumb as $k => $v) + $title = self::$title; + if (!$title) { - $title[] = $v['title']; + $title = []; + $breadcrumb = \app\admin\library\Auth::instance()->getBreadcrumb(); + foreach ($breadcrumb as $k => $v) + { + $title[] = $v['title']; + } + $title = implode(' ', $title); } self::create([ - 'title' => implode(' ', $title), - 'content' => json_encode($content), + 'title' => $title, + 'content' => !is_scalar($content) ? json_encode($content) : $content, 'url' => request()->url(), 'admin_id' => $admin_id, 'username' => $username, diff --git a/application/admin/view/wechat/autoreply/add.html b/application/admin/view/wechat/autoreply/add.html index 2f92c82f..118cd13f 100644 --- a/application/admin/view/wechat/autoreply/add.html +++ b/application/admin/view/wechat/autoreply/add.html @@ -9,19 +9,19 @@