From a96251cab43db554caf50bd5226686110b425b04 Mon Sep 17 00:00:00 2001 From: yumo Date: Tue, 14 Nov 2023 20:08:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E5=86=99?= =?UTF-8?q?=E5=85=A5=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/common.php | 48 +++++++++++++-------------------- app/admin/model/AdminNotify.php | 4 +-- app/common.php | 32 +++++++++++----------- 3 files changed, 38 insertions(+), 46 deletions(-) diff --git a/app/admin/common.php b/app/admin/common.php index 06b66f2..8f41f1e 100644 --- a/app/admin/common.php +++ b/app/admin/common.php @@ -1,8 +1,5 @@ has('store_' . $adminId); + return cache('store_' . $adminId); } } if (!function_exists('remove_cache')) { /** * 删除缓存 + * @param string $path * @return bool * @throws \Psr\SimpleCache\InvalidArgumentException */ @@ -53,9 +51,11 @@ if (!function_exists('remove_cache')) { } } + if (!function_exists('to_int_array')) { /** * 字符串数组转int数组 + * @param array $str * @return array */ function to_int_array(array $str): array @@ -79,9 +79,10 @@ if (!function_exists('tag_options')) { } } + if (!function_exists('type_options')) { /** - * 获取form标签 + * 获取form type类型 * @return array */ function type_options(): array @@ -100,6 +101,7 @@ if (!function_exists('type_options')) { } } + if (!function_exists('get_dir')) { /** * 获取文件目录列表,该方法返回数组 @@ -107,7 +109,7 @@ if (!function_exists('get_dir')) { * @return mixed * @date 2021-02-17 21:27 */ - function get_dir($dir) + function get_dir($dir): mixed { $dirArray[] = NULL; if (false != ($handle = opendir($dir))) { @@ -127,8 +129,15 @@ if (!function_exists('get_dir')) { } if (!function_exists('get_tree_list')) { - /*无限分类*/ - function get_tree_list(&$list, $pid = 0, $level = 0, $html = '|—') + /** + * 无限分类 + * @param $list + * @param $pid + * @param $level + * @param $html + * @return array + */ + function get_tree_list(&$list, $pid = 0, $level = 0, $html = '|—'): array { static $tree = array(); foreach ($list as $v) { @@ -175,25 +184,6 @@ if (!function_exists('html2mb_str')) { } } -/** - * 截取中文指定字节 - * @param string $str - * @param int $utf8len - * @param string $charset - * @param string $file - * @return string - */ - -if (!function_exists('substr_utf8')) { - function substr_utf8($str, int $utf8len = 100, string $charset = 'UTF-8', string $file = '....'): string - { - if (mb_strlen($str, $charset) > $utf8len) { - $str = mb_substr($str, 0, $utf8len, $charset) . $file; - } - return $str; - } -} - /** * 获取本季度 time * @param int|string $time diff --git a/app/admin/model/AdminNotify.php b/app/admin/model/AdminNotify.php index 8b096b8..76ef019 100644 --- a/app/admin/model/AdminNotify.php +++ b/app/admin/model/AdminNotify.php @@ -42,7 +42,7 @@ class AdminNotify extends BaseModel * @param array $data * @return int|string */ - public static function addLog(array $data) + public static function addLog(array $data): int|string { return self::create($data); } @@ -55,7 +55,7 @@ class AdminNotify extends BaseModel * @throws DbException * @throws ModelNotFoundException */ - public static function pageList(int $num) + public static function pageList(int $num): array { $model = new self; $model = $model->where("is_read", 0); diff --git a/app/common.php b/app/common.php index 2c1c968..f3225a2 100644 --- a/app/common.php +++ b/app/common.php @@ -116,20 +116,22 @@ if (!function_exists('unicode_decode')) { * * @return string */ -function server_url() -{ - if (isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) { - $http = 'https://'; - } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) { - $http = 'https://'; - } else { - $http = 'http://'; +if (!function_exists('file_cdn')) { + function server_url(): string + { + if (isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) { + $http = 'https://'; + } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) { + $http = 'https://'; + } else { + $http = 'http://'; + } + + $host = $_SERVER['HTTP_HOST']; + $res = $http . $host; + + return $res; } - - $host = $_SERVER['HTTP_HOST']; - $res = $http . $host; - - return $res; } if (!function_exists('file_cdn')) { @@ -140,7 +142,7 @@ if (!function_exists('file_cdn')) { * @author 木子的忧伤 * @date 2021-02-17 23:32 */ - function file_cdn($path) + function file_cdn($path): string { if (empty($path)) { return ''; @@ -173,7 +175,7 @@ if (!function_exists('get_rand_str')) { * @author 木子的忧伤 * @date 2022-04-11 18:26 */ - function get_rand_str($length) + function get_rand_str($length): string { //字符组合 $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';