diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index a0a2a8a3..ccae62d7 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,12 +2,35 @@
namespace App\Http\Controllers;
+use App\Service\UploadService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
+
+ public function upload(Request $request, UploadService $service): array
+ {
+ // TODO 如果关闭了游客上传,返回404
+ // TODO 检测IP是否超出上传限制
+ // TODO 获取用户组
+ // TODO 判断储存容量
+ // TODO 获取策略列表,根据用户所选的策略上传
+ // TODO 检测是否存在该图片,有则直接返回
+ // TODO 图片保存至默认相册(若有)
+ $data = [
+ 'url' => 'https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png',
+ 'html' => '<img src="https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png" alt="e212bc43771ad6d391952732a1713e31.png" title="e212bc43771ad6d391952732a1713e31.png" />',
+ 'bbcode' => '[img]https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png[/img]',
+ 'markdown' => '',
+ 'markdown_with_link' => '[](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)',
+ ];
+ $status = true;
+ $message = '上传失败,储存空间不足';
+ return compact('status', 'data', 'message');
+ }
}
diff --git a/app/Http/Controllers/User/ProfileController.php b/app/Http/Controllers/User/ProfileController.php
new file mode 100644
index 00000000..331c3bd6
--- /dev/null
+++ b/app/Http/Controllers/User/ProfileController.php
@@ -0,0 +1,11 @@
+ 'collection',
];
+ protected static function booted()
+ {
+ static::creating(function (self $group) {
+ $group->configs = collect([
+ 'upload_max_size' => 5120, // 最大上传大小
+ 'upload_single_num' => 3, // 单次同时上传数量
+ 'is_need_review' => false, // 上传是否需要审查
+ 'limit_per_day' => 0, // 每天可以上传数量,0 为不限制
+ 'upload_allowed_types' => ['jpg', 'jpeg', 'gif', 'png', 'ico'], // 允许上传的文件类型
+ 'path_naming_rule' => '{Y}/{m}/{d}', // 路径命名规则
+ 'file_naming_rule' => '{uniqid}', // 文件命名规则
+ 'user_initial_capacity' => 1048576, // 用户初始容量
+ ])->merge($group->configs ?: []);
+ });
+ }
+
public function users(): HasMany
{
return $this->hasMany(User::class, 'user_id', 'id');
diff --git a/app/Models/User.php b/app/Models/User.php
index 71485612..07ce7dca 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -80,7 +80,7 @@ class User extends Authenticatable
{
static::creating(function (self $user) {
$user->configs = collect([
- 'upload_default_album' => 0, // 默认上传文件夹
+ 'upload_default_album' => 0, // 默认上传相册
'upload_default_strategy' => 0, // 默认上传策略
'is_upload_show_preview', // 是否显示上传预览
'is_upload_auto_clear_preview', // 上传成功是否自动删除预览图
diff --git a/app/Service/UploadService.php b/app/Service/UploadService.php
new file mode 100644
index 00000000..9d4f5552
--- /dev/null
+++ b/app/Service/UploadService.php
@@ -0,0 +1,8 @@
+
-
我的
-