'fastchat', 'title' => '即时通信管理', 'icon' => 'fa fa-comments', 'sublist' => [ [ 'name' => 'fastchat/pushmessage', 'title' => '推送消息', 'icon' => 'fa fa-circle-o', 'sublist' => [ ['name' => 'fastchat/pushmessage/index', 'title' => '推送消息'] ] ], [ 'name' => 'fastchat/serviceuser', 'title' => '服务账号管理', 'icon' => 'fa fa-circle-o', 'sublist' => [ ['name' => 'fastchat/serviceuser/index', 'title' => '查看'], ['name' => 'fastchat/serviceuser/add', 'title' => '添加'], ['name' => 'fastchat/serviceuser/edit', 'title' => '编辑'], ['name' => 'fastchat/serviceuser/del', 'title' => '删除'], ['name' => 'fastchat/serviceuser/multi', 'title' => '批量更新'], ['name' => 'fastchat/serviceuser/recyclebin', 'title' => '回收站'], ['name' => 'fastchat/serviceuser/destroy', 'title' => '真实删除'], ['name' => 'fastchat/serviceuser/restore', 'title' => '还原'], ] ], ] ] ]; Menu::create($menu); return true; } /** * 插件卸载方法 * @return bool */ public function uninstall() { // 删除命令 $command_file = APP_PATH . 'command.php'; $command_item = 'addons\fastchat\library\GatewayWorker\start'; if (is_file($command_file)) { $fullConfigArr = include $command_file; } $command_existing = false; foreach ($fullConfigArr as $key => $value) { if ($value == $command_item) { $command_existing = true; unset($fullConfigArr[$key]); } } if ($command_existing) { if (is_really_writable($command_file)) { if ($handle = fopen($command_file, 'w')) { fwrite($handle, "isCli()) { \think\Console::addDefaultCommands([ 'addons\fastchat\library\GatewayWorker\start' ]); } } /** * 插件启用方法 * @return bool */ public function enable() { return true; } /** * 插件禁用方法 * @return bool */ public function disable() { return true; } /* * 管理员登陆时的行为事件 */ public function adminLoginAfter($admin_request) { try { $username = $admin_request->post('username'); if ($username) { $admin = Admin::get(['username' => $username]); if ($admin) { $keeptime = 864000; $expiretime = time() + $keeptime; $key = md5(md5($admin->id) . md5($keeptime) . md5($expiretime) . $admin->token); $data = [$admin->id, $keeptime, $expiretime, $key]; Cookie::set('fastchat_admin', implode('|', $data), $keeptime); } } } catch (\think\exception\PDOException $e) { } catch (\think\Exception $e) { // 防止出现异常造成管理员无法登录 } } }