|
...
|
...
|
@@ -10,6 +10,7 @@ use App\Models\News\NewsCategory; |
|
|
|
use App\Models\News\NewsCategory as NewsCategoryModel;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Services\CosService;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use mysql_xdevapi\Exception;
|
|
|
|
|
|
...
|
...
|
@@ -186,7 +187,9 @@ class NewsLogic extends BaseLogic |
|
|
|
if(isset($param['image'])){
|
|
|
|
$param['image'] = str_replace_url($param['image'] ?? '');
|
|
|
|
}
|
|
|
|
if(isset($this->param['text'])){
|
|
|
|
|
|
|
|
}
|
|
|
|
if(isset($this->param['id'])){
|
|
|
|
$param['operator_id'] = $this->user['id'];
|
|
|
|
}else{
|
|
...
|
...
|
@@ -209,6 +212,49 @@ class NewsLogic extends BaseLogic |
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processBase64Image($inputString) {
|
|
|
|
// 正则匹配Base64图片流文件
|
|
|
|
$pattern = '/data:image\/(png|jpg|jpeg|gif);base64,([a-zA-Z0-9\/+\=]+)/';
|
|
|
|
$outputString = $inputString;
|
|
|
|
// 找到所有符合条件的Base64图片流
|
|
|
|
if (preg_match_all($pattern, $inputString, $matches)) {
|
|
|
|
// 遍历匹配的Base64流文件
|
|
|
|
foreach ($matches[0] as $index => $base64String) {
|
|
|
|
$imageType = $matches[1][$index]; // 图片类型
|
|
|
|
$base64Data = $matches[2][$index]; // Base64数据
|
|
|
|
// 解码Base64图片
|
|
|
|
$decodedData = base64_decode($base64Data);
|
|
|
|
if ($decodedData === false) {
|
|
|
|
continue; // 如果解码失败,则跳过
|
|
|
|
}
|
|
|
|
// 设置文件名
|
|
|
|
$outputFile = 'images/' . uniqid() . '.' . $imageType;
|
|
|
|
$filePath = __DIR__ . '/' . $outputFile;
|
|
|
|
// 保存图片到服务器
|
|
|
|
if (file_put_contents($filePath, $decodedData)) {
|
|
|
|
// 生成图片URL
|
|
|
|
$imageUrl = 'http://your-domain.com/' . $outputFile;
|
|
|
|
// 替换原字符串中的Base64流为图片链接
|
|
|
|
$outputString = str_replace($base64String, $imageUrl, $outputString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $outputString;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :自调用
|
|
|
|
* @name :manager_uploads
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/11/7 11:00
|
|
|
|
*/
|
|
|
|
public function manager_uploads($files){
|
|
|
|
$this->uploads = config('upload.default_image');
|
|
|
|
$path = $this->uploads['path_b'].'/'.$this->user['project_id'].'/image_news/'.date('Y-m');
|
|
|
|
$cosService = new CosService();
|
|
|
|
$fileName = md5(uniqid() . '_' . time() . '.' . $this->user['project_id'].rand(1,10000));
|
|
|
|
return $cosService->uploadFile($files,$path,$fileName);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :获取分类(字符串)
|
|
|
|
* @name :getLastCategory
|
...
|
...
|
|