diff --git a/.env.example b/.env.example index 032b4ec..43d9853 100644 --- a/.env.example +++ b/.env.example @@ -27,7 +27,7 @@ SIMPLE_JWT_PREFIX=jwt # ---- 项目配置 ---- WEB_URL=http://im.gzydong.club -IMG_URL=http://im-img0.gzydong.club +IMG_URL=http://127.0.0.1:9504 UPLOAD_PATH=/www/data/lumenim ## 管理员邮箱 ADMIN_EMAIL= diff --git a/app/Helpers/HashIdsHelper.php b/app/Helpers/HashIdsHelper.php index 897f97e..a66de3e 100644 --- a/app/Helpers/HashIdsHelper.php +++ b/app/Helpers/HashIdsHelper.php @@ -44,7 +44,7 @@ class HashIdsHelper * @param mixed ...$numbers * @return string */ - public static function encode(...$numbers) + public static function encode(...$numbers): string { return self::getHashIds()->encode(...$numbers); } @@ -71,7 +71,7 @@ class HashIdsHelper * * @return Hashids */ - private static function getHashIds() + private static function getHashIds(): Hashids { if (!self::$hashIds instanceof Hashids) { self::$hashIds = new Hashids(self::$secretKey, self::$length); diff --git a/app/Helpers/JsonHelper.php b/app/Helpers/JsonHelper.php new file mode 100644 index 0000000..7abd169 --- /dev/null +++ b/app/Helpers/JsonHelper.php @@ -0,0 +1,34 @@ +event_name, $event->data)); + Message::publish(Message::create($event->event_name, $event->data)); } } diff --git a/app/Support/Mail.php b/app/Support/Mail.php index 6a8f337..e0a56cb 100644 --- a/app/Support/Mail.php +++ b/app/Support/Mail.php @@ -1,9 +1,9 @@ CharSet = 'UTF-8'; // 设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 - $mail->IsSMTP(); // 设定使用SMTP服务 - $mail->SMTPDebug = 0; // 关闭SMTP调试功能 - $mail->SMTPAuth = true; // 启用 SMTP 验证功能 - $mail->SMTPSecure = 'ssl'; // 使用安全协议 - $mail->Host = $config['host']; // SMTP 服务器 - $mail->Port = $config['port']; // SMTP服务器的端口号 - $mail->Username = $config['username']; // SMTP服务器用户名 - $mail->Password = $config['password']; // SMTP服务器密码 - $mail->SetFrom($config['from'], $config['name']); // 邮箱,昵称 + // PHPMailer对象 + $mail = new PHPMailer(); + + // 设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 + $mail->CharSet = 'UTF-8'; + + // 设定使用SMTP服务 + $mail->IsSMTP(); + + // 关闭SMTP调试功能 + $mail->SMTPDebug = 0; + + // 启用 SMTP 验证功能 + $mail->SMTPAuth = true; + + // 使用安全协议 + $mail->SMTPSecure = 'ssl'; + + // SMTP 服务器 + $mail->Host = $config['host']; + $mail->Port = $config['port']; + $mail->Username = $config['username']; + $mail->Password = $config['password']; + + // 邮箱,昵称 + $mail->SetFrom($config['from'], $config['name']); $mail->Subject = $subject; $mail->MsgHTML($view); $mail->AddAddress($address); // 收件人 diff --git a/app/Support/MessageProducer.php b/app/Support/Message.php similarity index 97% rename from app/Support/MessageProducer.php rename to app/Support/Message.php index 821ff75..4af7424 100644 --- a/app/Support/MessageProducer.php +++ b/app/Support/Message.php @@ -5,7 +5,7 @@ namespace App\Support; use App\Constants\RedisSubscribeChan; -class MessageProducer +class Message { /** * @param string $event diff --git a/app/Support/Packet.php b/app/Support/Packet.php deleted file mode 100644 index 5b94b09..0000000 --- a/app/Support/Packet.php +++ /dev/null @@ -1,168 +0,0 @@ - 'OPEN', - 1 => 'CLOSE', - 2 => 'PING', - 3 => 'PONG', - 4 => 'MESSAGE', - 5 => 'UPGRADE', - 6 => 'NOOP', - ]; - - /** - * Engine.io packet types. - */ - public static $engineTypes = [ - 0 => 'CONNECT', - 1 => 'DISCONNECT', - 2 => 'EVENT', - 3 => 'ACK', - 4 => 'ERROR', - 5 => 'BINARY_EVENT', - 6 => 'BINARY_ACK', - ]; - - /** - * Get socket packet type of a raw payload. - * - * @param string $packet - * @return int|null - */ - public static function getSocketType(string $packet) - { - $type = $packet[0] ?? null; - - if (!array_key_exists($type, static::$socketTypes)) { - return null; - } - - return (int)$type; - } - - /** - * Get data packet from a raw payload. - * - * @param string $packet - * @return array|null - */ - public static function getPayload(string $packet) - { - $packet = trim($packet); - $start = strpos($packet, '['); - - if ($start === false || substr($packet, -1) !== ']') { - return null; - } - - $data = substr($packet, $start, strlen($packet) - $start); - $data = json_decode($data, true); - - if (is_null($data)) { - return null; - } - - return [ - 'event' => $data[0], - 'data' => $data[1] ?? null, - ]; - } - - /** - * Return if a socket packet belongs to specific type. - * - * @param $packet - * @param string $typeName - * @return bool - */ - public static function isSocketType($packet, string $typeName) - { - $type = array_search(strtoupper($typeName), static::$socketTypes); - - if ($type === false) { - return false; - } - - return static::getSocketType($packet) === $type; - } -} diff --git a/app/Support/SocketIOParser.php b/app/Support/SocketIOParser.php deleted file mode 100644 index 9e9218d..0000000 --- a/app/Support/SocketIOParser.php +++ /dev/null @@ -1,39 +0,0 @@ - $payload['event'] ?? null, - 'data' => $payload['data'] ?? null, - ]; - } -}