first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

45
app/Helpers/AppHelper.php Executable file
View File

@ -0,0 +1,45 @@
<?php
namespace App\Helpers;
use function Hyperf\Config\config;
class AppHelper
{
public static function getImageBaseUrl(): string
{
return config('upload.qiniu.base_url');
}
public static function setImageUrl(string $imageUrl)
{
$imageUrl = self::extractImagePath($imageUrl);
return self::getImageBaseUrl() . $imageUrl;
}
public static function extractImagePath(string $url): string
{
// 解析URL
$parsedUrl = parse_url($url);
// 获取路径部分
$path = $parsedUrl['path'];
// 去除路径前的 "/"
return ltrim($path, '/');
}
public static function generateAid(): string
{
return strtr(uniqid(more_entropy: true), [
'.' => ''
]);
}
public static function getYear(string $title)
{
preg_match('/([0-9]+)/', $title, $y);
return $y[1] ?? date('Y');
}
}