mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-09 04:19:32 +08:00
✨ Introducing new features.
This commit is contained in:
parent
edc61f42d9
commit
e2e0a2ce9a
@ -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' => '![e212bc43771ad6d391952732a1713e31.png](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)',
|
||||
'markdown_with_link' => '[![e212bc43771ad6d391952732a1713e31.png](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)',
|
||||
];
|
||||
$status = true;
|
||||
$message = '上传失败,储存空间不足';
|
||||
return compact('status', 'data', 'message');
|
||||
}
|
||||
}
|
||||
|
11
app/Http/Controllers/User/ProfileController.php
Normal file
11
app/Http/Controllers/User/ProfileController.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
15
app/Http/Controllers/User/UserController.php
Normal file
15
app/Http/Controllers/User/UserController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function dashboard(): View
|
||||
{
|
||||
return view('dashboard');
|
||||
}
|
||||
}
|
@ -33,6 +33,22 @@ class Group extends Model
|
||||
'configs' => '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');
|
||||
|
@ -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', // 上传成功是否自动删除预览图
|
||||
|
8
app/Service/UploadService.php
Normal file
8
app/Service/UploadService.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
class UploadService
|
||||
{
|
||||
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
<x-app-layout>
|
||||
<x-upload/>
|
||||
仪表盘
|
||||
</x-app-layout>
|
||||
|
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="flex flex-col space-y-2 mb-5">
|
||||
<p class="text-gray-400 text-sm mx-4">我的</p>
|
||||
<x-nav-link :active="request()->routeIs('upload')">
|
||||
<x-nav-link :href="route('upload')" :active="request()->routeIs('upload')">
|
||||
<x-slot name="icon"><i class="fas fa-cloud-upload-alt text-blue-500"></i></x-slot>
|
||||
<x-slot name="name">上传图片</x-slot>
|
||||
</x-nav-link>
|
||||
|
3
resources/views/upload.blade.php
Normal file
3
resources/views/upload.blade.php
Normal file
@ -0,0 +1,3 @@
|
||||
<x-app-layout>
|
||||
<x-upload/>
|
||||
</x-app-layout>
|
@ -13,25 +13,14 @@ use Illuminate\Support\Facades\Route;
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
})->name('/');
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\User\UserController;
|
||||
|
||||
Route::post('/upload', function () {
|
||||
$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' => '![e212bc43771ad6d391952732a1713e31.png](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)',
|
||||
'markdown_with_link' => '[![e212bc43771ad6d391952732a1713e31.png](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)](https://pic.iqy.ink/2021/12/12/e8cfd03eb787f.png)',
|
||||
];
|
||||
$status = true;
|
||||
$message = '上传失败,储存空间不足';
|
||||
return compact('status', 'data', 'message');
|
||||
Route::get('/', fn () => view('welcome'))->name('/');
|
||||
Route::post('/upload', [Controller::class, 'upload']);
|
||||
Route::group(['middleware' => ['auth'],], function () {
|
||||
Route::get('/dashboard', [UserController::class, 'dashboard'])->name('dashboard');
|
||||
Route::get('/upload', fn () => view('upload'))->name('upload');
|
||||
});
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('dashboard');
|
||||
})->middleware(['auth'])->name('dashboard');
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
|
Loading…
Reference in New Issue
Block a user