初始化

缺陷:主题配色需要优化整体的同风格
This commit is contained in:
2026-08-14 23:21:21 +08:00
parent 6e2769c528
commit bcf54c2727
152 changed files with 13521 additions and 141 deletions

View File

@@ -71,4 +71,31 @@ class UploadService extends BaseService
]);
return $result;
}
/**
* 上传文档(商品图册的 PDF、订单转账凭证的 PDF 等)
*
* 驱动层的 uploadVideo 就是通用的 put图册 PDF 之前只能借 video 通道上传,
* 结果 key 落在 spa/video 下,素材库按目录归类时全错位,故单独开一路。
*
* @param mixed $file 上传文件对象
*/
public function uploadDocument($file): array|bool
{
$ext = strtolower($file->getClientOriginalExtension());
$allowed = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'csv', 'zip'];
if (!in_array($ext, $allowed, true)) {
$this->utils->errorThrow('不支持的文件类型:' . $ext);
}
$key = 'spa/file/' . date('Ymd') . '/' . 'cc_upload_' . Str::random() . uniqid() . '.' . $ext;
$result = $this->uploadService->uploadVideo($file, $key);
if (!$result) {
$this->utils->errorThrow('文件上传失败');
}
FileService::getInstance()->create([
'user_id' => $this->userId,
'url' => $result['url'],
]);
return $result;
}
}