first commit

This commit is contained in:
浪子 2026-03-19 16:44:38 +08:00
commit ff2af385b9
100 changed files with 16826 additions and 0 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[compose.yaml]
indent_size = 4

65
.env.example Normal file
View File

@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
# PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db

59
README.md Normal file
View File

@ -0,0 +1,59 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
### Premium Partners
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StoreCategoryRequest;
use App\Models\Category;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
public function index(Request $request): JsonResponse
{
$query = Category::query()->orderByDesc('sort_order')->orderBy('id');
if ($type = $request->query('type')) {
$query->where('type', $type);
}
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%')
->orWhere('description', 'like', '%' . $keyword . '%');
});
}
$items = $query->get()->map(fn (Category $category) => $this->format($category))->values()->all();
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'items' => $items,
],
]);
}
public function store(StoreCategoryRequest $request): JsonResponse
{
$category = Category::query()->create([
'type' => $request->validated('type'),
'name' => $request->validated('name'),
'slug' => $request->validated('slug'),
'description' => $request->validated('description', ''),
'sort_order' => (int) $request->validated('sort_order', 0),
]);
return response()->json([
'code' => 0,
'message' => 'category created',
'data' => $this->format($category),
], 201);
}
public function update(StoreCategoryRequest $request, int $id): JsonResponse
{
$category = Category::query()->find($id);
if (!$category) {
return response()->json([
'code' => 404,
'message' => 'category not found',
'data' => null,
], 404);
}
$category->fill([
'type' => $request->validated('type'),
'name' => $request->validated('name'),
'slug' => $request->validated('slug'),
'description' => $request->validated('description', ''),
'sort_order' => (int) $request->validated('sort_order', 0),
]);
$category->save();
return response()->json([
'code' => 0,
'message' => 'category updated',
'data' => $this->format($category),
]);
}
public function destroy(int $id): JsonResponse
{
$category = Category::query()->find($id);
if (!$category) {
return response()->json([
'code' => 404,
'message' => 'category not found',
'data' => null,
], 404);
}
$category->packages()->detach();
$category->delete();
return response()->json([
'code' => 0,
'message' => 'category deleted',
'data' => null,
]);
}
private function format(Category $category): array
{
return [
'id' => $category->id,
'type' => $category->type,
'name' => $category->name,
'slug' => $category->slug,
'description' => $category->description,
'sort_order' => (int) $category->sort_order,
'package_count' => $category->packages()->count(),
'created_at' => optional($category->created_at)->toAtomString(),
'updated_at' => optional($category->updated_at)->toAtomString(),
];
}
}

View File

@ -0,0 +1,123 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StorePackageRequest;
use App\Models\Package;
use App\Services\AdminPackageService;
use App\Services\RepoFormatter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
class PackageController extends Controller
{
public function __construct(private readonly AdminPackageService $service)
{
}
public function index(Request $request): JsonResponse
{
$query = Package::query()->with(['categories', 'latestStableVersion']);
if ($type = $request->query('type')) {
$query->where('type', $type);
}
if ($status = $request->query('status')) {
$query->where('status', $status);
}
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%')
->orWhere('summary', 'like', '%' . $keyword . '%');
});
}
$result = $query->orderByDesc('sort_order')->orderByDesc('updated_at')
->paginate(min(max((int) $request->query('size', 20), 1), 100));
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'page' => $result->currentPage(),
'size' => $result->perPage(),
'total' => $result->total(),
'items' => collect($result->items())->map(fn ($package) => RepoFormatter::packageDetail($package))->values()->all(),
],
]);
}
public function store(StorePackageRequest $request): JsonResponse
{
$package = $this->service->createPackage($request->validated());
return response()->json([
'code' => 0,
'message' => 'package created',
'data' => RepoFormatter::packageDetail($package->load(['versions', 'screenshots', 'categories'])),
], 201);
}
public function update(StorePackageRequest $request, string $type, string $slug): JsonResponse
{
$package = $this->findPackage($type, $slug);
$package = $this->service->updatePackage($package, $request->validated());
return response()->json([
'code' => 0,
'message' => 'package updated',
'data' => RepoFormatter::packageDetail($package->load(['versions', 'screenshots', 'categories'])),
]);
}
public function updateStatus(Request $request, string $type, string $slug): JsonResponse
{
$validated = $request->validate([
'status' => ['required', Rule::in(['draft', 'published', 'hidden', 'deprecated'])],
]);
$package = $this->findPackage($type, $slug);
$package = $this->service->updateStatus($package, $validated['status']);
return response()->json([
'code' => 0,
'message' => 'package status updated',
'data' => RepoFormatter::packageDetail($package->load(['versions', 'screenshots', 'categories'])),
]);
}
public function destroy(string $type, string $slug): JsonResponse
{
$package = $this->findPackage($type, $slug);
$package->delete();
return response()->json([
'code' => 0,
'message' => 'package deleted',
'data' => null,
]);
}
private function findPackage(string $type, string $slug): Package
{
$package = Package::query()
->where('type', $type)
->where('slug', $slug)
->first();
if (!$package) {
abort(response()->json([
'code' => 404,
'message' => 'package not found',
'data' => null,
], 404));
}
return $package;
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\PublishZipVersionRequest;
use App\Http\Requests\Admin\StoreVersionRequest;
use App\Models\Package;
use App\Models\Version;
use App\Services\AdminPackageService;
use App\Services\RepoFormatter;
use App\Services\VersionPublishService;
use Illuminate\Http\JsonResponse;
class VersionController extends Controller
{
public function __construct(
private readonly AdminPackageService $service,
private readonly VersionPublishService $publishService,
) {
}
public function index(string $type, string $slug): JsonResponse
{
$package = $this->findPackage($type, $slug);
$versions = $package->versions()->orderByDesc('published_at')->orderByDesc('id')->get();
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'package' => [
'type' => $package->type,
'slug' => $package->slug,
'name' => $package->name,
],
'items' => $versions->map(fn ($version) => RepoFormatter::versionDetail($version))->values()->all(),
],
]);
}
public function store(StoreVersionRequest $request, string $type, string $slug): JsonResponse
{
$package = $this->findPackage($type, $slug);
$version = $this->service->createVersion($package, $request->validated());
return response()->json([
'code' => 0,
'message' => 'version created',
'data' => RepoFormatter::versionDetail($version),
], 201);
}
public function publish(PublishZipVersionRequest $request, string $type, string $slug): JsonResponse
{
$package = $this->findPackage($type, $slug);
$version = $this->publishService->publishFromZip(
$package,
$request->file('package_file'),
$request->validated()
);
return response()->json([
'code' => 0,
'message' => 'version published',
'data' => RepoFormatter::versionDetail($version),
], 201);
}
public function destroy(int $id): JsonResponse
{
$version = Version::query()->with('package')->find($id);
if (!$version) {
return response()->json([
'code' => 404,
'message' => 'version not found',
'data' => null,
], 404);
}
$this->service->deleteVersion($version);
return response()->json([
'code' => 0,
'message' => 'version deleted',
'data' => null,
]);
}
private function findPackage(string $type, string $slug): Package
{
$package = Package::query()
->where('type', $type)
->where('slug', $slug)
->first();
if (!$package) {
abort(response()->json([
'code' => 404,
'message' => 'package not found',
'data' => null,
], 404));
}
return $package;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Category;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
public function index(Request $request): JsonResponse
{
$query = Category::query()->orderByDesc('sort_order')->orderBy('id');
if ($type = $request->query('type')) {
$query->where('type', $type);
}
$categories = $query->get()->map(function ($item) {
return [
'slug' => $item->slug,
'name' => $item->name,
'type' => $item->type,
'package_count' => $item->packages()->count(),
];
})->values()->all();
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'categories' => $categories,
],
]);
}
}

View File

@ -0,0 +1,317 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\DownloadLog;
use App\Models\Package;
use App\Services\RepoFormatter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class RepoController extends Controller
{
public function index(Request $request): JsonResponse
{
$allowPrerelease = (string) $request->query('allow_prerelease', '0') === '1';
$relation = $allowPrerelease ? 'latestVersion' : 'latestStableVersion';
$query = Package::query()
->with([$relation, 'categories'])
->where('status', 'published');
if ($type = $request->query('type')) {
$query->where('type', $type);
}
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('summary', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%');
});
}
if ($category = $request->query('category')) {
$query->whereHas('categories', function ($q) use ($category) {
$q->where('slug', $category);
});
}
$sort = $request->query('sort', 'latest');
if ($sort === 'downloads') {
$query->orderByDesc('download_count')->orderByDesc('sort_order');
} elseif ($sort === 'name') {
$query->orderBy('name');
} else {
$query->orderByDesc('sort_order')->orderByDesc('updated_at');
}
$size = min(max((int) $request->query('size', 20), 1), 100);
$page = max((int) $request->query('page', 1), 1);
$result = $query->paginate($size, ['*'], 'page', $page);
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'page' => $result->currentPage(),
'size' => $result->perPage(),
'total' => $result->total(),
'items' => collect($result->items())->map(function ($package) use ($allowPrerelease) {
return RepoFormatter::packageListItem($package, $allowPrerelease);
})->values()->all(),
],
]);
}
public function detail(string $type, string $slug): JsonResponse
{
$package = Package::query()
->with([
'categories',
'screenshots',
'versions' => function ($q) {
$q->orderByDesc('published_at')->orderByDesc('id');
},
])
->where('status', 'published')
->where('type', $type)
->where('slug', $slug)
->first();
if (!$package) {
return response()->json([
'code' => 404,
'message' => 'package not found',
'data' => null,
], 404);
}
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => RepoFormatter::packageDetail($package, false),
]);
}
public function checkUpdates(Request $request): JsonResponse
{
$installed = $request->input('installed', []);
$typechoVersion = (string) $request->input('typecho_version', '');
$phpVersion = (string) $request->input('php_version', '');
$allowPrerelease = (bool) $request->input('allow_prerelease', false);
$updates = [];
$upToDate = [];
$incompatible = [];
$unknown = [];
foreach ($installed as $item) {
$type = $item['type'] ?? '';
$slug = $item['slug'] ?? '';
$currentVersion = $item['version'] ?? '';
$package = Package::query()
->with(['latestStableVersion', 'latestVersion'])
->where('status', 'published')
->where('type', $type)
->where('slug', $slug)
->first();
$latest = $allowPrerelease
? ($package?->latestVersion ?: $package?->latestStableVersion)
: $package?->latestStableVersion;
if (!$package || !$latest) {
$unknown[] = [
'type' => $type,
'slug' => $slug,
'current_version' => $currentVersion,
];
continue;
}
if (version_compare($currentVersion, $latest->version, '>=')) {
$upToDate[] = [
'type' => $type,
'slug' => $slug,
'current_version' => $currentVersion,
'latest_version' => $latest->version,
];
continue;
}
$compatibilityOk = $this->isCompatible($latest, $typechoVersion, $phpVersion);
if (!$compatibilityOk) {
$incompatible[] = [
'type' => $type,
'slug' => $slug,
'current_version' => $currentVersion,
'latest_version' => $latest->version,
];
continue;
}
$updates[] = [
'type' => $type,
'slug' => $slug,
'name' => $package->name,
'current_version' => $currentVersion,
'latest_version' => $latest->version,
'changelog' => $latest->changelog,
'compatibility_ok' => true,
'package' => [
'size' => (int) $latest->package_size,
'sha256' => $latest->sha256,
'download_url' => $latest->package_url,
],
];
}
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'updates' => $updates,
'up_to_date' => $upToDate,
'incompatible' => $incompatible,
'unknown' => $unknown,
'store_plugin_update' => null,
],
]);
}
public function download(Request $request, string $type, string $slug, string $version): JsonResponse|BinaryFileResponse|RedirectResponse
{
$pluginToken = (string) config('store.plugin_access_token', '');
$requestToken = (string) ($request->header('X-Store-Plugin-Token') ?: $request->query('access_token', ''));
if ($pluginToken !== '' && $requestToken !== $pluginToken) {
return response()->json([
'code' => 403,
'message' => 'download forbidden',
'data' => null,
], 403);
}
$package = Package::query()
->where('status', 'published')
->where('type', $type)
->where('slug', $slug)
->first();
if (!$package) {
return response()->json([
'code' => 404,
'message' => 'package not found',
'data' => null,
], 404);
}
$versionModel = $version === 'latest'
? $package->versions()->where('is_stable', 1)->where('is_latest', 1)->first()
: $package->versions()->where('version', $version)->first();
if (!$versionModel) {
return response()->json([
'code' => 404,
'message' => 'version not found',
'data' => null,
], 404);
}
$filePath = storage_path('app/packages/' . $type . '/' . $slug . '/' . $versionModel->version . '.zip');
$hasLocalFile = is_file($filePath);
$redirect = (string) $request->query('redirect', '0') === '1';
if ($redirect) {
DownloadLog::create([
'package_id' => $package->id,
'version_id' => $versionModel->id,
'site_url' => (string) $request->query('site_url', ''),
'typecho_version' => (string) $request->query('typecho_version', ''),
'php_version' => (string) $request->query('php_version', ''),
'ip' => (string) $request->ip(),
'user_agent' => (string) $request->userAgent(),
'created_at' => now(),
]);
$package->increment('download_count');
$versionModel->increment('download_count');
if ($hasLocalFile) {
return response()->download($filePath, $slug . '-' . $versionModel->version . '.zip', [
'Content-Type' => 'application/zip',
]);
}
if (!empty($versionModel->package_url)) {
return redirect()->away($versionModel->package_url);
}
return response()->json([
'code' => 404,
'message' => 'package file not found',
'data' => null,
], 404);
}
return response()->json([
'code' => 0,
'message' => 'ok',
'data' => [
'type' => $type,
'slug' => $slug,
'version' => $versionModel->version,
'package' => [
'download_url' => $this->buildDownloadUrl($request, $type, $slug, $versionModel->version),
'size' => (int) $versionModel->package_size,
'sha256' => $versionModel->sha256,
'filename' => $slug . '-' . $versionModel->version . '.zip',
'storage' => [
'driver' => $hasLocalFile ? 'local' : 'remote',
'exists' => $hasLocalFile,
],
],
],
]);
}
private function isCompatible($version, string $typechoVersion, string $phpVersion): bool
{
if ($typechoVersion !== '' && $version->typecho_min !== '' && version_compare($typechoVersion, $version->typecho_min, '<')) {
return false;
}
if ($typechoVersion !== '' && $version->typecho_max !== '') {
$max = str_replace('*', '999', $version->typecho_max);
if (version_compare($typechoVersion, $max, '>')) {
return false;
}
}
if ($phpVersion !== '' && $version->php_min !== '' && version_compare($phpVersion, $version->php_min, '<')) {
return false;
}
if ($phpVersion !== '' && $version->php_max !== '') {
$max = str_replace('*', '999', $version->php_max);
if (version_compare($phpVersion, $max, '>')) {
return false;
}
}
return true;
}
private function buildDownloadUrl(Request $request, string $type, string $slug, string $version): string
{
$path = '/api/v1/repo/download/' . $type . '/' . $slug . '/' . $version . '?redirect=1';
$appUrl = rtrim((string) config('app.url', ''), '/');
if ($appUrl !== '') {
return $appUrl . $path;
}
return $request->getSchemeAndHttpHost() . $path;
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

View File

@ -0,0 +1,122 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Package;
use App\Services\RepoFormatter;
use Illuminate\Http\Request;
use Illuminate\View\View;
class StorefrontController extends Controller
{
public function home(): View
{
$featuredPlugins = Package::query()
->with(['categories', 'latestStableVersion'])
->where('status', 'published')
->where('type', 'plugin')
->orderByDesc('is_featured')
->orderByDesc('sort_order')
->orderByDesc('updated_at')
->limit(6)
->get();
$featuredThemes = Package::query()
->with(['categories', 'latestStableVersion'])
->where('status', 'published')
->where('type', 'theme')
->orderByDesc('is_featured')
->orderByDesc('sort_order')
->orderByDesc('updated_at')
->limit(6)
->get();
$stats = [
'packages' => Package::query()->where('status', 'published')->count(),
'plugins' => Package::query()->where('status', 'published')->where('type', 'plugin')->count(),
'themes' => Package::query()->where('status', 'published')->where('type', 'theme')->count(),
'categories' => Category::count(),
];
return view('storefront.home', compact('featuredPlugins', 'featuredThemes', 'stats'));
}
public function packages(Request $request, string $type): View
{
abort_unless(in_array($type, ['plugin', 'theme'], true), 404);
$query = Package::query()
->with(['categories', 'latestStableVersion'])
->where('status', 'published')
->where('type', $type);
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%')
->orWhere('summary', 'like', '%' . $keyword . '%');
});
}
if ($category = (string) $request->query('category', '')) {
$query->whereHas('categories', fn ($q) => $q->where('slug', $category));
}
$sort = (string) $request->query('sort', 'latest');
if ($sort === 'name') {
$query->orderBy('name');
} else {
$query->orderByDesc('is_featured')->orderByDesc('sort_order')->orderByDesc('updated_at');
}
$packages = $query->paginate(12)->withQueryString();
$categories = Category::query()->where('type', $type)->orderByDesc('sort_order')->get();
return view('storefront.packages', [
'type' => $type,
'packages' => $packages,
'categories' => $categories,
'filters' => [
'keyword' => (string) $request->query('keyword', ''),
'category' => (string) $request->query('category', ''),
'sort' => $sort,
],
]);
}
public function show(string $type, string $slug): View
{
abort_unless(in_array($type, ['plugin', 'theme'], true), 404);
$package = Package::query()
->with([
'categories',
'screenshots',
'versions' => fn ($q) => $q->orderByDesc('published_at')->orderByDesc('id'),
])
->where('status', 'published')
->where('type', $type)
->where('slug', $slug)
->firstOrFail();
$detail = RepoFormatter::packageDetail($package, false);
$related = Package::query()
->with(['categories', 'latestStableVersion'])
->where('status', 'published')
->where('type', $type)
->where('id', '!=', $package->id)
->orderByDesc('is_featured')
->orderByDesc('updated_at')
->limit(4)
->get();
return view('storefront.show', [
'package' => $package,
'detail' => $detail,
'related' => $related,
]);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\WebAdmin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\View\View;
class AuthController extends Controller
{
public function showLogin(Request $request): View
{
return view('admin.login', [
'redirect' => (string) $request->query('redirect', route('webadmin.home')),
]);
}
public function login(Request $request): RedirectResponse
{
$validated = $request->validate([
'email' => ['required', 'email'],
'password' => ['required', 'string'],
'redirect' => ['nullable', 'string'],
'remember' => ['nullable', 'boolean'],
]);
$user = User::query()->where('email', $validated['email'])->first();
if (!$user || !Hash::check($validated['password'], $user->password)) {
return back()->withInput($request->except('password'))->with('error', '账号或密码不正确');
}
Auth::login($user, (bool) ($validated['remember'] ?? false));
$request->session()->regenerate();
$redirect = $validated['redirect'] ?: route('webadmin.home');
return redirect()->to($redirect);
}
public function logout(Request $request): RedirectResponse
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('webadmin.login')->with('success', '已退出后台');
}
}

View File

@ -0,0 +1,276 @@
<?php
namespace App\Http\Controllers\WebAdmin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StoreCategoryRequest;
use App\Http\Requests\Admin\StorePackageRequest;
use App\Models\Category;
use App\Models\Package;
use App\Models\Version;
use App\Services\AdminPackageService;
use App\Services\VersionPublishService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class DashboardController extends Controller
{
public function __construct(
private readonly AdminPackageService $service,
private readonly VersionPublishService $publishService,
) {
}
public function home(): View
{
$stats = [
'packages' => Package::count(),
'plugins' => Package::where('type', 'plugin')->count(),
'themes' => Package::where('type', 'theme')->count(),
'versions' => Version::count(),
'downloads' => (int) Package::sum('download_count'),
'categories' => Category::count(),
];
$recentPackages = Package::query()
->with(['categories', 'latestStableVersion'])
->latest('updated_at')
->limit(6)
->get();
$recentVersions = Version::query()
->with('package')
->latest('published_at')
->limit(8)
->get();
return view('admin.dashboard', compact('stats', 'recentPackages', 'recentVersions'));
}
public function packages(Request $request): View
{
$query = Package::query()->with(['categories', 'latestStableVersion']);
if ($type = $request->query('type')) {
$query->where('type', $type);
}
if ($status = $request->query('status')) {
$query->where('status', $status);
}
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%')
->orWhere('summary', 'like', '%' . $keyword . '%');
});
}
$packages = $query->orderByDesc('sort_order')->orderByDesc('updated_at')->paginate(15)->withQueryString();
return view('admin.packages.index', [
'packages' => $packages,
'filters' => [
'type' => (string) $request->query('type', ''),
'status' => (string) $request->query('status', ''),
'keyword' => (string) $request->query('keyword', ''),
],
]);
}
public function storePackage(StorePackageRequest $request): RedirectResponse
{
$data = $request->validated();
$data['categories'] = $this->normalizeCategories($request);
$package = $this->service->createPackage($data);
return redirect()->route('webadmin.packages.show', [$package->type, $package->slug])->with('success', '扩展已创建');
}
public function updatePackage(StorePackageRequest $request, string $type, string $slug): RedirectResponse
{
$package = $this->findPackage($type, $slug);
$data = $request->validated();
$data['categories'] = $this->normalizeCategories($request);
$this->service->updatePackage($package, $data);
return redirect()->route('webadmin.packages.show', [$type, $slug])->with('success', '扩展已更新');
}
public function updatePackageStatus(Request $request, string $type, string $slug): RedirectResponse
{
$validated = $request->validate([
'status' => ['required', 'in:draft,published,hidden,deprecated'],
]);
$package = $this->findPackage($type, $slug);
$this->service->updateStatus($package, $validated['status']);
return redirect()->route('webadmin.packages')->with('success', '状态已更新');
}
public function categories(Request $request): View
{
$query = Category::query()->withCount('packages');
if ($type = $request->query('type')) {
$query->where('type', $type);
}
if ($keyword = trim((string) $request->query('keyword', ''))) {
$query->where(function ($q) use ($keyword) {
$q->where('name', 'like', '%' . $keyword . '%')
->orWhere('slug', 'like', '%' . $keyword . '%')
->orWhere('description', 'like', '%' . $keyword . '%');
});
}
$categories = $query->orderBy('type')->orderByDesc('sort_order')->paginate(20)->withQueryString();
return view('admin.categories.index', [
'categories' => $categories,
'filters' => [
'type' => (string) $request->query('type', ''),
'keyword' => (string) $request->query('keyword', ''),
],
]);
}
public function storeCategory(StoreCategoryRequest $request): RedirectResponse
{
Category::create($request->validated());
return redirect()->route('webadmin.categories')->with('success', '分类已创建');
}
public function updateCategory(StoreCategoryRequest $request, int $id): RedirectResponse
{
$category = Category::findOrFail($id);
$category->update($request->validated());
return redirect()->route('webadmin.categories')->with('success', '分类已更新');
}
public function destroyCategory(int $id): RedirectResponse
{
$category = Category::findOrFail($id);
$category->packages()->detach();
$category->delete();
return redirect()->route('webadmin.categories')->with('success', '分类已删除');
}
public function showPackage(string $type, string $slug): View
{
$package = Package::query()
->with(['categories', 'screenshots', 'versions' => fn ($q) => $q->latest('published_at')])
->where('type', $type)
->where('slug', $slug)
->firstOrFail();
return view('admin.packages.show', [
'package' => $package,
]);
}
public function storeVersion(Request $request, string $type, string $slug): RedirectResponse
{
$package = $this->findPackage($type, $slug);
$validated = $request->validate([
'version' => ['required', 'string', 'max:32'],
'changelog' => ['nullable', 'string'],
'typecho_min' => ['nullable', 'string', 'max:32'],
'typecho_max' => ['nullable', 'string', 'max:32'],
'php_min' => ['nullable', 'string', 'max:32'],
'php_max' => ['nullable', 'string', 'max:32'],
'package_url' => ['nullable', 'url', 'max:512'],
'package_size' => ['nullable', 'integer', 'min:0'],
'sha256' => ['nullable', 'string', 'max:64'],
'is_stable' => ['nullable', 'boolean'],
'is_latest' => ['nullable', 'boolean'],
'published_at' => ['nullable', 'date'],
'php_extensions' => ['nullable', 'string'],
]);
$payload = [
'version' => $validated['version'],
'changelog' => $validated['changelog'] ?? '',
'typecho_min' => $validated['typecho_min'] ?? '1.2.0',
'typecho_max' => $validated['typecho_max'] ?? '',
'php_min' => $validated['php_min'] ?? '7.4',
'php_max' => $validated['php_max'] ?? '',
'php_extensions' => collect(explode(',', (string) ($validated['php_extensions'] ?? '')))
->map(fn ($item) => trim($item))
->filter()
->values()
->all(),
'package_url' => $validated['package_url'] ?? '',
'package_size' => (int) ($validated['package_size'] ?? 0),
'sha256' => $validated['sha256'] ?? str_repeat('0', 64),
'is_stable' => (bool) ($validated['is_stable'] ?? false),
'mark_as_latest' => (bool) ($validated['is_latest'] ?? false),
'published_at' => $validated['published_at'] ?? now(),
];
$version = $this->service->createVersion($package, $payload);
return redirect()->route('webadmin.packages.show', [$type, $slug])->with('success', '版本已添加v' . $version->version);
}
public function publishVersion(Request $request, string $type, string $slug): RedirectResponse
{
$package = $this->findPackage($type, $slug);
$validated = $request->validate([
'package_file' => ['required', 'file', 'mimes:zip', 'max:51200'],
'is_stable' => ['nullable', 'boolean'],
'mark_as_latest' => ['nullable', 'boolean'],
'changelog' => ['nullable', 'string'],
'published_at' => ['nullable', 'date'],
]);
try {
$version = $this->publishService->publishFromZip($package, $request->file('package_file'), $validated);
} catch (\Throwable $e) {
return back()->withInput()->with('error', 'zip 发布失败:' . $e->getMessage());
}
$msg = 'zip 发布成功v' . $version->version;
$msg .= $version->is_stable ? ' · stable' : ' · prerelease';
$msg .= $version->is_latest ? ' · latest' : '';
return redirect()->route('webadmin.packages.show', [$type, $slug])->with('success', $msg);
}
public function destroyVersion(string $type, string $slug, int $id): RedirectResponse
{
$package = $this->findPackage($type, $slug);
$version = $package->versions()->where('id', $id)->firstOrFail();
$label = $version->version;
$this->service->deleteVersion($version);
return redirect()->route('webadmin.packages.show', [$type, $slug])->with('success', '版本已删除v' . $label);
}
private function findPackage(string $type, string $slug): Package
{
return Package::query()
->where('type', $type)
->where('slug', $slug)
->firstOrFail();
}
private function normalizeCategories(Request $request): array
{
$raw = (string) $request->input('categories_text', '');
return collect(preg_split('/[,\s]+/u', $raw))
->map(fn ($item) => trim((string) $item))
->filter()
->values()
->all();
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class AdminTokenAuth
{
public function handle(Request $request, Closure $next): Response
{
$configuredToken = (string) config('store.admin_token', env('STORE_ADMIN_TOKEN', ''));
if ($configuredToken === '') {
return response()->json([
'code' => 500,
'message' => 'admin token not configured',
'data' => null,
], 500);
}
$incomingToken = $this->extractToken($request);
if (!hash_equals($configuredToken, $incomingToken)) {
return response()->json([
'code' => 401,
'message' => 'unauthorized',
'data' => null,
], 401);
}
return $next($request);
}
private function extractToken(Request $request): string
{
$header = (string) $request->header('Authorization', '');
if (preg_match('/^Bearer\s+(.+)$/i', $header, $matches)) {
return trim($matches[1]);
}
return (string) ($request->header('X-Admin-Token')
?: $request->query('admin_token')
?: $request->input('admin_token', ''));
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class WebAdminTokenAuth
{
public function handle(Request $request, Closure $next): Response
{
if (!Auth::check()) {
return redirect()->route('webadmin.login', [
'redirect' => $request->fullUrl(),
])->with('error', '请先登录后台账号');
}
return $next($request);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class PublishZipVersionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'package_file' => ['required', 'file', 'mimes:zip', 'max:51200'],
'is_stable' => ['nullable', 'boolean'],
'mark_as_latest' => ['nullable', 'boolean'],
'changelog' => ['nullable', 'string'],
'published_at' => ['nullable', 'date'],
];
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreCategoryRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'type' => ['required', Rule::in(['plugin', 'theme'])],
'name' => ['required', 'string', 'max:64'],
'slug' => ['required', 'string', 'max:64', 'regex:/^[a-z0-9-]+$/'],
'description' => ['nullable', 'string', 'max:255'],
'sort_order' => ['nullable', 'integer'],
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StorePackageRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'type' => ['required', Rule::in(['plugin', 'theme'])],
'slug' => ['required', 'string', 'max:64', 'regex:/^[A-Za-z][A-Za-z0-9_-]*$/'],
'name' => ['required', 'string', 'max:128'],
'summary' => ['nullable', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'author' => ['nullable', 'string', 'max:64'],
'homepage' => ['nullable', 'url', 'max:512'],
'icon_url' => ['nullable', 'url', 'max:512'],
'license' => ['nullable', 'string', 'max:32'],
'status' => ['nullable', Rule::in(['draft', 'published', 'hidden', 'deprecated'])],
'is_featured' => ['nullable', 'boolean'],
'sort_order' => ['nullable', 'integer'],
'categories' => ['nullable', 'array'],
'categories.*' => ['string', 'max:64'],
];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreVersionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'version' => ['required', 'string', 'max:32'],
'changelog' => ['nullable', 'string'],
'typecho_min' => ['nullable', 'string', 'max:16'],
'typecho_max' => ['nullable', 'string', 'max:16'],
'php_min' => ['nullable', 'string', 'max:16'],
'php_max' => ['nullable', 'string', 'max:16'],
'php_extensions' => ['nullable', 'array'],
'php_extensions.*' => ['string', 'max:32'],
'package_url' => ['required', 'url', 'max:1024'],
'package_size' => ['nullable', 'integer', 'min:0'],
'sha256' => ['required', 'string', 'size:64'],
'is_stable' => ['nullable', 'boolean'],
'published_at' => ['nullable', 'date'],
'mark_as_latest' => ['nullable', 'boolean'],
];
}
}

23
app/Models/Category.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
protected $table = 'store_categories';
protected $fillable = [
'type',
'name',
'slug',
'description',
'sort_order',
];
public function packages()
{
return $this->belongsToMany(Package::class, 'store_package_categories', 'category_id', 'package_id');
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DownloadLog extends Model
{
protected $table = 'store_download_logs';
public $timestamps = false;
protected $fillable = [
'package_id',
'version_id',
'site_url',
'typecho_version',
'php_version',
'ip',
'user_agent',
'created_at',
];
}

59
app/Models/Package.php Normal file
View File

@ -0,0 +1,59 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Package extends Model
{
protected $table = 'store_packages';
protected $fillable = [
'type',
'slug',
'name',
'summary',
'description',
'author',
'homepage',
'icon_url',
'license',
'status',
'is_featured',
'sort_order',
'download_count',
'latest_version',
];
protected $casts = [
'is_featured' => 'boolean',
];
public function versions()
{
return $this->hasMany(Version::class, 'package_id');
}
public function latestStableVersion()
{
return $this->hasOne(Version::class, 'package_id')
->where('is_stable', 1)
->where('is_latest', 1);
}
public function latestVersion()
{
return $this->hasOne(Version::class, 'package_id')
->where('is_latest', 1);
}
public function screenshots()
{
return $this->hasMany(Screenshot::class, 'package_id')->orderBy('sort_order')->orderBy('id');
}
public function categories()
{
return $this->belongsToMany(Category::class, 'store_package_categories', 'package_id', 'category_id');
}
}

22
app/Models/Screenshot.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Screenshot extends Model
{
protected $table = 'store_screenshots';
protected $fillable = [
'package_id',
'image_url',
'caption',
'sort_order',
];
public function package()
{
return $this->belongsTo(Package::class, 'package_id');
}
}

49
app/Models/User.php Normal file
View File

@ -0,0 +1,49 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

49
app/Models/Version.php Normal file
View File

@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Version extends Model
{
protected $table = 'store_versions';
protected $fillable = [
'package_id',
'version',
'changelog',
'typecho_min',
'typecho_max',
'php_min',
'php_max',
'php_extensions',
'package_url',
'package_size',
'sha256',
'is_stable',
'is_latest',
'download_count',
'published_at',
];
protected $casts = [
'is_stable' => 'boolean',
'is_latest' => 'boolean',
'published_at' => 'datetime',
];
public function package()
{
return $this->belongsTo(Package::class, 'package_id');
}
public function getPhpExtensionsArrayAttribute()
{
$value = $this->php_extensions;
if (empty($value)) {
return [];
}
$decoded = json_decode($value, true);
return is_array($decoded) ? $decoded : [];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}

View File

@ -0,0 +1,159 @@
<?php
namespace App\Services;
use App\Models\Category;
use App\Models\Package;
use App\Models\Version;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
class AdminPackageService
{
public function createPackage(array $data): Package
{
return DB::transaction(function () use ($data) {
$package = Package::query()->create([
'type' => $data['type'],
'slug' => $data['slug'],
'name' => $data['name'],
'summary' => $data['summary'] ?? '',
'description' => $data['description'] ?? '',
'author' => $data['author'] ?? '',
'homepage' => $data['homepage'] ?? '',
'icon_url' => $data['icon_url'] ?? '',
'license' => $data['license'] ?? '',
'status' => $data['status'] ?? 'draft',
'is_featured' => (bool) ($data['is_featured'] ?? false),
'sort_order' => (int) ($data['sort_order'] ?? 0),
'download_count' => 0,
'latest_version' => '',
]);
$this->syncCategories($package, Arr::get($data, 'categories', []));
return $package->load(['categories', 'latestStableVersion']);
});
}
public function updatePackage(Package $package, array $data): Package
{
return DB::transaction(function () use ($package, $data) {
$package->fill([
'name' => $data['name'] ?? $package->name,
'summary' => $data['summary'] ?? $package->summary,
'description' => $data['description'] ?? $package->description,
'author' => $data['author'] ?? $package->author,
'homepage' => $data['homepage'] ?? $package->homepage,
'icon_url' => $data['icon_url'] ?? $package->icon_url,
'license' => $data['license'] ?? $package->license,
'status' => $data['status'] ?? $package->status,
'is_featured' => array_key_exists('is_featured', $data) ? (bool) $data['is_featured'] : $package->is_featured,
'sort_order' => array_key_exists('sort_order', $data) ? (int) $data['sort_order'] : $package->sort_order,
]);
$package->save();
if (array_key_exists('categories', $data)) {
$this->syncCategories($package, Arr::get($data, 'categories', []));
}
$this->refreshLatestVersion($package->fresh());
return $package->fresh(['categories', 'latestStableVersion']);
});
}
public function updateStatus(Package $package, string $status): Package
{
$package->status = $status;
$package->save();
return $package->fresh(['categories', 'latestStableVersion']);
}
public function createVersion(Package $package, array $data): Version
{
return DB::transaction(function () use ($package, $data) {
$markAsLatest = array_key_exists('mark_as_latest', $data) ? (bool) $data['mark_as_latest'] : true;
if ($markAsLatest) {
$package->versions()->update(['is_latest' => false]);
}
$version = $package->versions()->create([
'version' => $data['version'],
'changelog' => $data['changelog'] ?? '',
'typecho_min' => $data['typecho_min'] ?? '1.2.0',
'typecho_max' => $data['typecho_max'] ?? '',
'php_min' => $data['php_min'] ?? '7.4',
'php_max' => $data['php_max'] ?? '',
'php_extensions' => json_encode($data['php_extensions'] ?? [], JSON_UNESCAPED_UNICODE),
'package_url' => $data['package_url'],
'package_size' => (int) ($data['package_size'] ?? 0),
'sha256' => strtolower($data['sha256']),
'is_stable' => array_key_exists('is_stable', $data) ? (bool) $data['is_stable'] : true,
'is_latest' => $markAsLatest,
'download_count' => 0,
'published_at' => $data['published_at'] ?? now(),
]);
$this->refreshLatestVersion($package->fresh());
return $version->fresh();
});
}
public function deleteVersion(Version $version): void
{
DB::transaction(function () use ($version) {
$package = $version->package;
$version->delete();
if ($package) {
$this->refreshLatestVersion($package->fresh());
}
});
}
public function refreshLatestVersion(Package $package): void
{
$latestStable = $package->versions()
->where('is_stable', true)
->orderByDesc('is_latest')
->orderByDesc('published_at')
->orderByDesc('id')
->first();
if ($latestStable) {
$package->latest_version = $latestStable->version;
$package->save();
return;
}
$latestAny = $package->versions()
->orderByDesc('is_latest')
->orderByDesc('published_at')
->orderByDesc('id')
->first();
$package->latest_version = $latestAny?->version ?: '';
$package->save();
}
private function syncCategories(Package $package, array $categorySlugs): void
{
$categorySlugs = array_values(array_unique(array_filter(array_map('strval', $categorySlugs))));
if (empty($categorySlugs)) {
$package->categories()->sync([]);
return;
}
$categoryIds = Category::query()
->where('type', $package->type)
->whereIn('slug', $categorySlugs)
->pluck('id')
->all();
$package->categories()->sync($categoryIds);
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace App\Services;
use App\Models\Package;
use App\Models\Version;
class RepoFormatter
{
public static function packageListItem(Package $package, bool $allowPrerelease = false): array
{
$latest = $allowPrerelease
? ($package->latestVersion ?: $package->latestStableVersion)
: $package->latestStableVersion;
return [
'type' => $package->type,
'slug' => $package->slug,
'name' => $package->name,
'summary' => $package->summary,
'author' => $package->author,
'icon_url' => $package->icon_url,
'latest_version' => $latest?->version ?: $package->latest_version,
'download_count' => (int) $package->download_count,
'is_featured' => (bool) $package->is_featured,
'categories' => $package->categories->pluck('slug')->values()->all(),
'compatibility' => $latest ? self::compatibility($latest) : [
'typecho_min' => '',
'typecho_max' => '',
'php_min' => '',
'php_max' => '',
],
'updated_at' => optional($package->updated_at)->toAtomString(),
];
}
public static function packageDetail(Package $package, bool $includeDownloadMeta = true): array
{
return [
'type' => $package->type,
'slug' => $package->slug,
'name' => $package->name,
'summary' => $package->summary,
'description' => $package->description,
'author' => $package->author,
'homepage' => $package->homepage,
'icon_url' => $package->icon_url,
'license' => $package->license,
'is_featured' => (bool) $package->is_featured,
'download_count' => (int) $package->download_count,
'categories' => $package->categories->pluck('slug')->values()->all(),
'screenshots' => $package->screenshots->map(function ($item) {
return [
'url' => $item->image_url,
'caption' => $item->caption,
];
})->values()->all(),
'versions' => $package->versions->map(function ($version) use ($includeDownloadMeta) {
return self::versionDetail($version, $includeDownloadMeta);
})->values()->all(),
'created_at' => optional($package->created_at)->toAtomString(),
'updated_at' => optional($package->updated_at)->toAtomString(),
];
}
public static function versionDetail(Version $version, bool $includeDownloadMeta = true): array
{
$payload = [
'version' => $version->version,
'is_stable' => (bool) $version->is_stable,
'is_latest' => (bool) $version->is_latest,
'changelog' => $version->changelog,
'compatibility' => self::compatibility($version),
'published_at' => optional($version->published_at)->toAtomString(),
];
if ($includeDownloadMeta) {
$payload['package'] = [
'size' => (int) $version->package_size,
'sha256' => $version->sha256,
'download_url' => $version->package_url,
];
}
return $payload;
}
public static function compatibility(Version $version): array
{
return [
'typecho_min' => $version->typecho_min,
'typecho_max' => $version->typecho_max,
'php_min' => $version->php_min,
'php_max' => $version->php_max,
'php_extensions' => $version->php_extensions_array,
];
}
}

View File

@ -0,0 +1,215 @@
<?php
namespace App\Services;
use App\Models\Package;
use App\Models\Version;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use RuntimeException;
use ZipArchive;
class VersionPublishService
{
public function __construct(private readonly AdminPackageService $packageService)
{
}
public function publishFromZip(Package $package, UploadedFile $file, array $options = []): Version
{
$tmpDir = storage_path('app/tmp/store-publish/' . Str::uuid()->toString());
$extractDir = $tmpDir . '/extract';
$incomingPath = $tmpDir . '/incoming.zip';
File::ensureDirectoryExists($tmpDir);
File::ensureDirectoryExists($extractDir);
try {
File::copy($file->getRealPath(), $incomingPath);
$sha256 = hash_file('sha256', $incomingPath);
$size = filesize($incomingPath) ?: 0;
$manifest = $this->extractAndValidate($incomingPath, $extractDir, $package, $sha256);
$versionNumber = (string) $manifest['version'];
if ($package->versions()->where('version', $versionNumber)->exists()) {
throw new RuntimeException('version already exists');
}
$relativePath = 'packages/' . $package->type . '/' . $package->slug . '/' . $versionNumber . '.zip';
$storagePath = storage_path('app/' . $relativePath);
File::ensureDirectoryExists(dirname($storagePath));
File::copy($incomingPath, $storagePath);
$payload = [
'version' => $versionNumber,
'changelog' => $options['changelog'] ?? ($manifest['changelog'] ?? ''),
'typecho_min' => data_get($manifest, 'compatibility.typecho_min', '1.2.0'),
'typecho_max' => data_get($manifest, 'compatibility.typecho_max', ''),
'php_min' => data_get($manifest, 'compatibility.php_min', '7.4'),
'php_max' => data_get($manifest, 'compatibility.php_max', ''),
'php_extensions' => data_get($manifest, 'compatibility.php_extensions', []),
'package_url' => $this->buildPackageUrl($package, $versionNumber),
'package_size' => $size,
'sha256' => $sha256,
'is_stable' => array_key_exists('is_stable', $options)
? (bool) $options['is_stable']
: !Str::contains($versionNumber, ['-beta', '-alpha', '-rc']),
'published_at' => $options['published_at'] ?? now(),
'mark_as_latest' => array_key_exists('mark_as_latest', $options)
? (bool) $options['mark_as_latest']
: true,
];
return DB::transaction(function () use ($package, $payload) {
return $this->packageService->createVersion($package, $payload);
});
} finally {
if (is_dir($tmpDir)) {
File::deleteDirectory($tmpDir);
}
}
}
private function extractAndValidate(string $zipPath, string $extractDir, Package $package, string $sha256): array
{
$zip = new ZipArchive();
$opened = $zip->open($zipPath);
if ($opened !== true) {
throw new RuntimeException('failed to open zip package');
}
$topLevel = [];
$manifestRaw = null;
$rootDirExists = false;
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
$name = $stat['name'] ?? '';
$this->assertSafeEntry($name);
$trimmed = trim($name, '/');
if ($trimmed === '') {
continue;
}
$first = explode('/', $trimmed)[0];
$topLevel[$first] = true;
if ($trimmed === 'manifest.json') {
$manifestRaw = $zip->getFromIndex($i);
}
}
if ($manifestRaw === null) {
$zip->close();
throw new RuntimeException('manifest.json not found at zip root');
}
$manifest = json_decode($manifestRaw, true);
if (!is_array($manifest)) {
$zip->close();
throw new RuntimeException('invalid manifest.json');
}
$this->validateManifest($manifest, $package, $sha256);
$allowedTopLevel = ['manifest.json', $package->slug];
$topLevelNames = array_keys($topLevel);
sort($topLevelNames);
sort($allowedTopLevel);
if ($topLevelNames !== $allowedTopLevel) {
$zip->close();
throw new RuntimeException('zip root structure must contain only manifest.json and package root dir');
}
if (!$zip->extractTo($extractDir)) {
$zip->close();
throw new RuntimeException('failed to extract zip package');
}
$zip->close();
$rootDir = $extractDir . DIRECTORY_SEPARATOR . $package->slug;
$rootDirExists = is_dir($rootDir);
if (!$rootDirExists) {
throw new RuntimeException('package root dir missing after extraction');
}
return $manifest;
}
private function validateManifest(array $manifest, Package $package, string $sha256): void
{
if (($manifest['schema_version'] ?? '') !== '1.0') {
throw new RuntimeException('unsupported manifest schema_version');
}
if (($manifest['type'] ?? '') !== $package->type) {
throw new RuntimeException('manifest type does not match package type');
}
if (($manifest['slug'] ?? '') !== $package->slug) {
throw new RuntimeException('manifest slug does not match package slug');
}
if (!preg_match('/^[A-Za-z][A-Za-z0-9]*$/', (string) ($manifest['slug'] ?? ''))) {
throw new RuntimeException('manifest slug format invalid');
}
if (empty($manifest['name']) || empty($manifest['author']) || empty($manifest['version'])) {
throw new RuntimeException('manifest missing required fields');
}
if (!preg_match('/^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$/', (string) $manifest['version'])) {
throw new RuntimeException('manifest version is not valid semver');
}
if (($manifest['install']['root_dir'] ?? '') !== $package->slug) {
throw new RuntimeException('manifest install.root_dir invalid');
}
$expectedTargetDir = $package->type === 'plugin'
? 'usr/plugins/' . $package->slug
: 'usr/themes/' . $package->slug;
if (($manifest['install']['target_dir'] ?? '') !== $expectedTargetDir) {
throw new RuntimeException('manifest install.target_dir invalid');
}
if (empty($manifest['compatibility']['typecho_min']) || empty($manifest['compatibility']['php_min'])) {
throw new RuntimeException('manifest compatibility fields missing');
}
$manifestSha = strtolower((string) data_get($manifest, 'package.sha256', ''));
if ($manifestSha === '' || $manifestSha !== strtolower($sha256)) {
throw new RuntimeException('manifest package sha256 mismatch');
}
}
private function assertSafeEntry(string $name): void
{
if ($name === '' || str_contains($name, '../') || str_contains($name, '..\\')) {
throw new RuntimeException('zip contains unsafe path');
}
if (preg_match('#^[A-Za-z]:[\\/]#', $name) || str_starts_with($name, '/') || str_starts_with($name, '\\')) {
throw new RuntimeException('zip contains absolute path');
}
$blockedExt = ['phar', 'sh', 'bat', 'exe', 'cmd', 'com', 'ps1'];
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if ($ext !== '' && in_array($ext, $blockedExt, true)) {
throw new RuntimeException('zip contains blocked file type');
}
}
private function buildPackageUrl(Package $package, string $version): string
{
$path = '/api/v1/repo/download/' . $package->type . '/' . $package->slug . '/' . $version . '?redirect=1';
$base = rtrim(config('app.url', ''), '/');
return $base === '' ? $path : $base . $path;
}
}

18
artisan Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput);
exit($status);

22
bootstrap/app.php Normal file
View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: [__DIR__.'/../routes/api.php', __DIR__.'/../routes/admin.php'],
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->alias([
'store.admin' => App\Http\Middleware\AdminTokenAuth::class,
'store.webadmin' => App\Http\Middleware\WebAdminTokenAuth::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

7
bootstrap/providers.php Normal file
View File

@ -0,0 +1,7 @@
<?php
use App\Providers\AppServiceProvider;
return [
AppServiceProvider::class,
];

86
composer.json Normal file
View File

@ -0,0 +1,86 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.50"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

8389
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

126
config/app.php Normal file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];

117
config/auth.php Normal file
View File

@ -0,0 +1,117 @@
<?php
use App\Models\User;
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the number of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];

117
config/cache.php Normal file
View File

@ -0,0 +1,117 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "array", "database", "file", "memcached",
| "redis", "dynamodb", "octane",
| "failover", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
'table' => env('DB_CACHE_TABLE', 'cache'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
];

184
config/database.php Normal file
View File

@ -0,0 +1,184 @@
<?php
use Illuminate\Support\Str;
use Pdo\Mysql;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => env('DB_SSLMODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];

80
config/filesystems.php Normal file
View File

@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'serve' => true,
'throw' => false,
'report' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

132
config/logging.php Normal file
View File

@ -0,0 +1,132 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'handler_with' => [
'stream' => 'php://stderr',
],
'formatter' => env('LOG_STDERR_FORMATTER'),
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

118
config/mail.php Normal file
View File

@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "resend", "log", "array",
| "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
],
'resend' => [
'transport' => 'resend',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
'retry_after' => 60,
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
'retry_after' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails sent by your application to be sent from
| the same address. Here you may specify a name and address that is
| used globally for all emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
],
];

129
config/queue.php Normal file
View File

@ -0,0 +1,129 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "background", "failover", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];

38
config/services.php Normal file
View File

@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'postmark' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];

217
config/session.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "memcached",
| "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain without subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];

6
config/store.php Normal file
View File

@ -0,0 +1,6 @@
<?php
return [
'admin_token' => env('STORE_ADMIN_TOKEN', ''),
'plugin_access_token' => env('STORE_PLUGIN_ACCESS_TOKEN', ''),
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_packages', function (Blueprint $table) {
$table->id();
$table->enum('type', ['plugin', 'theme']);
$table->string('slug', 64);
$table->string('name', 128);
$table->string('summary', 255)->default('');
$table->text('description')->nullable();
$table->string('author', 64)->default('');
$table->string('homepage', 512)->default('');
$table->string('icon_url', 512)->default('');
$table->string('license', 32)->default('');
$table->enum('status', ['draft', 'published', 'hidden', 'deprecated'])->default('draft');
$table->boolean('is_featured')->default(false);
$table->integer('sort_order')->default(0);
$table->unsignedInteger('download_count')->default(0);
$table->string('latest_version', 32)->default('');
$table->timestamps();
$table->unique(['type', 'slug']);
$table->index(['type', 'status']);
$table->index(['is_featured', 'sort_order']);
});
}
public function down(): void
{
Schema::dropIfExists('store_packages');
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_versions', function (Blueprint $table) {
$table->id();
$table->foreignId('package_id')->constrained('store_packages')->cascadeOnDelete();
$table->string('version', 32);
$table->text('changelog')->nullable();
$table->string('typecho_min', 16)->default('1.2.0');
$table->string('typecho_max', 16)->default('');
$table->string('php_min', 16)->default('7.4');
$table->string('php_max', 16)->default('');
$table->string('php_extensions', 512)->default('');
$table->string('package_url', 1024);
$table->unsignedInteger('package_size')->default(0);
$table->char('sha256', 64);
$table->boolean('is_stable')->default(true);
$table->boolean('is_latest')->default(false);
$table->unsignedInteger('download_count')->default(0);
$table->dateTime('published_at')->useCurrent();
$table->timestamps();
$table->unique(['package_id', 'version']);
$table->index(['package_id', 'is_latest']);
});
}
public function down(): void
{
Schema::dropIfExists('store_versions');
}
};

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_screenshots', function (Blueprint $table) {
$table->id();
$table->foreignId('package_id')->constrained('store_packages')->cascadeOnDelete();
$table->string('image_url', 1024);
$table->string('caption', 255)->default('');
$table->integer('sort_order')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('store_screenshots');
}
};

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_categories', function (Blueprint $table) {
$table->id();
$table->enum('type', ['plugin', 'theme']);
$table->string('name', 64);
$table->string('slug', 64);
$table->string('description', 255)->default('');
$table->integer('sort_order')->default(0);
$table->timestamps();
$table->unique(['type', 'slug']);
});
}
public function down(): void
{
Schema::dropIfExists('store_categories');
}
};

View File

@ -0,0 +1,21 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_package_categories', function (Blueprint $table) {
$table->foreignId('package_id')->constrained('store_packages')->cascadeOnDelete();
$table->foreignId('category_id')->constrained('store_categories')->cascadeOnDelete();
$table->primary(['package_id', 'category_id']);
});
}
public function down(): void
{
Schema::dropIfExists('store_package_categories');
}
};

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('store_download_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('package_id')->constrained('store_packages')->cascadeOnDelete();
$table->foreignId('version_id')->constrained('store_versions')->cascadeOnDelete();
$table->string('site_url', 512)->default('');
$table->string('typecho_version', 16)->default('');
$table->string('php_version', 16)->default('');
$table->string('ip', 45)->default('');
$table->string('user_agent', 512)->default('');
$table->dateTime('created_at')->useCurrent();
});
}
public function down(): void
{
Schema::dropIfExists('store_download_logs');
}
};

View File

@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class AdminUserSeeder extends Seeder
{
public function run(): void
{
$email = env('ADMIN_EMAIL', 'admin@tstore.local');
$password = env('ADMIN_PASSWORD', 'Admin@123456');
$name = env('ADMIN_NAME', 'Tstore Admin');
User::query()->updateOrCreate(
['email' => $email],
[
'name' => $name,
'password' => Hash::make($password),
]
);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call([
AdminUserSeeder::class,
StoreDemoSeeder::class,
]);
}
}

View File

@ -0,0 +1,324 @@
<?php
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Package;
use App\Models\Screenshot;
use App\Models\Version;
use Illuminate\Database\Seeder;
class StoreDemoSeeder extends Seeder
{
public function run(): void
{
$pluginCategories = [
[
'type' => 'plugin',
'name' => 'SEO',
'slug' => 'seo',
'description' => 'SEO 与搜索优化相关插件',
'sort_order' => 100,
],
[
'type' => 'plugin',
'name' => '编辑器',
'slug' => 'editor',
'description' => '编辑器与内容增强插件',
'sort_order' => 90,
],
[
'type' => 'plugin',
'name' => '性能优化',
'slug' => 'performance',
'description' => '缓存、压缩、性能增强插件',
'sort_order' => 80,
],
];
$themeCategories = [
[
'type' => 'theme',
'name' => '博客',
'slug' => 'blog',
'description' => '适合个人博客的主题',
'sort_order' => 100,
],
[
'type' => 'theme',
'name' => '极简',
'slug' => 'minimal',
'description' => '简洁、轻量的主题风格',
'sort_order' => 90,
],
[
'type' => 'theme',
'name' => '作品集',
'slug' => 'portfolio',
'description' => '适合作品展示与个人主页',
'sort_order' => 80,
],
];
foreach (array_merge($pluginCategories, $themeCategories) as $category) {
Category::query()->updateOrCreate(
[
'type' => $category['type'],
'slug' => $category['slug'],
],
$category
);
}
$packages = [
[
'type' => 'plugin',
'slug' => 'SeoToolkit',
'name' => 'SEO Toolkit',
'summary' => 'Typecho SEO 增强插件,支持 Sitemap、Meta、OG 标签。',
'description' => "SEO Toolkit 提供完整的站点 SEO 配置能力,包括首页/文章 Meta 管理、Open Graph 标签、站点地图生成以及基础结构化数据支持。\n\n适合希望提升搜索引擎可见性的 Typecho 站点。",
'author' => 'Tstore Team',
'homepage' => 'https://store.example.com/packages/plugin/SeoToolkit',
'icon_url' => 'https://picsum.photos/seed/seotoolkit/128/128',
'license' => 'MIT',
'status' => 'published',
'is_featured' => true,
'sort_order' => 1000,
'download_count' => 1284,
'latest_version' => '1.2.0',
'categories' => ['seo', 'performance'],
'screenshots' => [
[
'image_url' => 'https://picsum.photos/seed/seotoolkit-1/1200/800',
'caption' => 'SEO 设置页面',
'sort_order' => 100,
],
[
'image_url' => 'https://picsum.photos/seed/seotoolkit-2/1200/800',
'caption' => 'Sitemap 生成配置',
'sort_order' => 90,
],
],
'versions' => [
[
'version' => '1.2.0',
'changelog' => "- 新增 Sitemap 配置项\n- 优化 OG 标签输出\n- 修复首页 description 为空的问题",
'typecho_min' => '1.2.0',
'typecho_max' => '1.3.*',
'php_min' => '7.4',
'php_max' => '8.3',
'php_extensions' => ['curl', 'json'],
'package_url' => 'https://downloads.example.com/typecho/plugin/SeoToolkit/1.2.0.zip',
'package_size' => 238000,
'sha256' => hash('sha256', 'SeoToolkit-1.2.0'),
'is_stable' => true,
'is_latest' => true,
'download_count' => 860,
'published_at' => '2026-03-13 10:00:00',
],
[
'version' => '1.1.0',
'changelog' => "- 增加基础 SEO 设置\n- 优化 canonical 输出",
'typecho_min' => '1.2.0',
'typecho_max' => '1.3.*',
'php_min' => '7.4',
'php_max' => '8.2',
'php_extensions' => ['curl'],
'package_url' => 'https://downloads.example.com/typecho/plugin/SeoToolkit/1.1.0.zip',
'package_size' => 210000,
'sha256' => hash('sha256', 'SeoToolkit-1.1.0'),
'is_stable' => true,
'is_latest' => false,
'download_count' => 424,
'published_at' => '2026-02-15 09:30:00',
],
],
],
[
'type' => 'plugin',
'slug' => 'MarkdownPlus',
'name' => 'Markdown Plus',
'summary' => '增强 Typecho Markdown 编辑体验,支持目录、提示块与快捷插入。',
'description' => "Markdown Plus 提供更友好的写作体验,包括常用 Markdown 片段、自动目录生成、提示块以及内容格式化能力。",
'author' => 'Tstore Team',
'homepage' => 'https://store.example.com/packages/plugin/MarkdownPlus',
'icon_url' => 'https://picsum.photos/seed/markdownplus/128/128',
'license' => 'GPL-2.0-or-later',
'status' => 'published',
'is_featured' => false,
'sort_order' => 900,
'download_count' => 768,
'latest_version' => '0.8.2',
'categories' => ['editor'],
'screenshots' => [
[
'image_url' => 'https://picsum.photos/seed/markdownplus-1/1200/800',
'caption' => '编辑器增强面板',
'sort_order' => 100,
],
],
'versions' => [
[
'version' => '0.9.0-beta.1',
'changelog' => "- 新增提示块\n- 支持自动目录\n- Beta 预发布测试",
'typecho_min' => '1.2.0',
'typecho_max' => '1.3.*',
'php_min' => '8.0',
'php_max' => '8.3',
'php_extensions' => ['json'],
'package_url' => 'https://downloads.example.com/typecho/plugin/MarkdownPlus/0.9.0-beta.1.zip',
'package_size' => 312000,
'sha256' => hash('sha256', 'MarkdownPlus-0.9.0-beta.1'),
'is_stable' => false,
'is_latest' => true,
'download_count' => 230,
'published_at' => '2026-03-12 14:20:00',
],
[
'version' => '0.8.2',
'changelog' => "- 修复快捷插入问题\n- 优化预览性能",
'typecho_min' => '1.2.0',
'typecho_max' => '1.2.*',
'php_min' => '7.4',
'php_max' => '8.2',
'php_extensions' => ['json'],
'package_url' => 'https://downloads.example.com/typecho/plugin/MarkdownPlus/0.8.2.zip',
'package_size' => 280000,
'sha256' => hash('sha256', 'MarkdownPlus-0.8.2'),
'is_stable' => true,
'is_latest' => false,
'download_count' => 538,
'published_at' => '2026-01-22 11:00:00',
],
],
],
[
'type' => 'theme',
'slug' => 'Aurora',
'name' => 'Aurora',
'summary' => '现代简洁的博客主题,支持深浅色切换与响应式布局。',
'description' => "Aurora 是一款面向个人博客和内容创作者的 Typecho 主题,强调阅读体验、响应式布局和清爽视觉。",
'author' => 'Tstore Team',
'homepage' => 'https://store.example.com/packages/theme/Aurora',
'icon_url' => 'https://picsum.photos/seed/aurora/128/128',
'license' => 'MIT',
'status' => 'published',
'is_featured' => true,
'sort_order' => 950,
'download_count' => 2033,
'latest_version' => '2.1.0',
'categories' => ['blog', 'minimal'],
'screenshots' => [
[
'image_url' => 'https://picsum.photos/seed/aurora-1/1440/900',
'caption' => '首页布局',
'sort_order' => 100,
],
[
'image_url' => 'https://picsum.photos/seed/aurora-2/1440/900',
'caption' => '文章详情页',
'sort_order' => 90,
],
],
'versions' => [
[
'version' => '2.1.0',
'changelog' => "- 新增暗色模式\n- 优化移动端导航\n- 提升首页加载性能",
'typecho_min' => '1.2.1',
'typecho_max' => '1.3.*',
'php_min' => '7.4',
'php_max' => '8.3',
'php_extensions' => ['json'],
'package_url' => 'https://downloads.example.com/typecho/theme/Aurora/2.1.0.zip',
'package_size' => 584000,
'sha256' => hash('sha256', 'Aurora-2.1.0'),
'is_stable' => true,
'is_latest' => true,
'download_count' => 1244,
'published_at' => '2026-03-10 16:00:00',
],
[
'version' => '2.0.0',
'changelog' => "- 全新首页设计\n- 新增归档页模板",
'typecho_min' => '1.2.0',
'typecho_max' => '1.3.*',
'php_min' => '7.4',
'php_max' => '8.2',
'php_extensions' => ['json'],
'package_url' => 'https://downloads.example.com/typecho/theme/Aurora/2.0.0.zip',
'package_size' => 548000,
'sha256' => hash('sha256', 'Aurora-2.0.0'),
'is_stable' => true,
'is_latest' => false,
'download_count' => 789,
'published_at' => '2026-01-18 10:00:00',
],
],
],
];
foreach ($packages as $item) {
$package = Package::query()->updateOrCreate(
[
'type' => $item['type'],
'slug' => $item['slug'],
],
[
'name' => $item['name'],
'summary' => $item['summary'],
'description' => $item['description'],
'author' => $item['author'],
'homepage' => $item['homepage'],
'icon_url' => $item['icon_url'],
'license' => $item['license'],
'status' => $item['status'],
'is_featured' => $item['is_featured'],
'sort_order' => $item['sort_order'],
'download_count' => $item['download_count'],
'latest_version' => $item['latest_version'],
]
);
$categoryIds = Category::query()
->where('type', $item['type'])
->whereIn('slug', $item['categories'])
->pluck('id')
->all();
$package->categories()->sync($categoryIds);
Screenshot::query()->where('package_id', $package->id)->delete();
foreach ($item['screenshots'] as $screenshot) {
Screenshot::query()->create([
'package_id' => $package->id,
'image_url' => $screenshot['image_url'],
'caption' => $screenshot['caption'],
'sort_order' => $screenshot['sort_order'],
]);
}
foreach ($item['versions'] as $version) {
Version::query()->updateOrCreate(
[
'package_id' => $package->id,
'version' => $version['version'],
],
[
'changelog' => $version['changelog'],
'typecho_min' => $version['typecho_min'],
'typecho_max' => $version['typecho_max'],
'php_min' => $version['php_min'],
'php_max' => $version['php_max'],
'php_extensions' => json_encode($version['php_extensions'], JSON_UNESCAPED_UNICODE),
'package_url' => $version['package_url'],
'package_size' => $version['package_size'],
'sha256' => $version['sha256'],
'is_stable' => $version['is_stable'],
'is_latest' => $version['is_latest'],
'download_count' => $version['download_count'],
'published_at' => $version['published_at'],
]
);
}
}
}
}

2484
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"$schema": "https://www.schemastore.org/package.json",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"tailwindcss": "^4.0.0",
"vite": "^7.0.7"
}
}

36
phpunit.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="BROADCAST_CONNECTION" value="null"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_URL" value=""/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="NIGHTWATCH_ENABLED" value="false"/>
</php>
</phpunit>

25
public/.htaccess Normal file
View File

@ -0,0 +1,25 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

0
public/favicon.ico Normal file
View File

20
public/index.php Normal file
View File

@ -0,0 +1,20 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->handleRequest(Request::capture());

2
public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow:

11
resources/css/app.css Normal file
View File

@ -0,0 +1,11 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
@theme {
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
}

1
resources/js/app.js Normal file
View File

@ -0,0 +1 @@
import './bootstrap';

4
resources/js/bootstrap.js vendored Normal file
View File

@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

View File

@ -0,0 +1,138 @@
@extends('admin.layout', [
'title' => 'Tstore Admin · 分类管理',
'pageTitle' => ($filters['type'] === 'plugin' ? '插件分类' : ($filters['type'] === 'theme' ? '主题分类' : '分类管理')),
'pageSubtitle' => ($filters['type'] === 'plugin'
? '维护插件分类,为插件 package 提供归类。'
: ($filters['type'] === 'theme'
? '维护主题分类,为主题 package 提供归类。'
: '统一维护插件与主题分类,为 package 提供归类。')),
])
@php
$currentType = $filters['type'] ?? '';
$entityLabel = $currentType === 'plugin' ? '插件分类' : ($currentType === 'theme' ? '主题分类' : '分类');
$listHint = $currentType === 'plugin' ? '按类型和关键词筛选插件分类。'
: ($currentType === 'theme' ? '按类型和关键词筛选主题分类。' : '按类型和关键词筛选分类列表。');
$createHint = $currentType === 'plugin' ? '新建一个插件分类,用于给插件 package 归类。'
: ($currentType === 'theme' ? '新建一个主题分类,用于给主题 package 归类。' : '新建一个分类,用于给 package 归类。');
@endphp
@section('content')
<div class="grid">
<div class="panel">
<div class="section-title">
<div>
<h2>筛选与查询</h2>
<p>{{ $listHint }}</p>
</div>
</div>
<form method="get" class="toolbar">
<div class="filters">
<div class="field">
<label>类型</label>
<select name="type" class="select">
<option value="">全部</option>
<option value="plugin" @selected($filters['type']==='plugin')>插件</option>
<option value="theme" @selected($filters['type']==='theme')>主题</option>
</select>
</div>
<div class="field" style="min-width:280px">
<label>关键词</label>
<input class="input" type="text" name="keyword" value="{{ $filters['keyword'] }}" placeholder="搜索 name / slug / description">
</div>
</div>
<div class="form-actions">
<button class="btn" type="submit">筛选</button>
<a class="btn secondary" href="{{ route('webadmin.categories') }}">重置</a>
</div>
</form>
</div>
<div class="split">
<div class="panel">
<div class="section-title">
<div>
<h2>{{ $entityLabel }}列表</h2>
<p>支持就地编辑名称、slug、类型、排序与描述。</p>
</div>
</div>
<div class="list">
@forelse ($categories as $category)
<div class="row-card">
<form method="post" action="{{ route('webadmin.categories.update', $category->id) }}" class="grid">
@csrf @method('PUT')
<div class="form-grid">
<div class="field"><label>名称</label><input class="input" name="name" value="{{ $category->name }}" required></div>
<div class="field"><label>Slug</label><input class="input" name="slug" value="{{ $category->slug }}" required></div>
<div class="field"><label>类型</label>
<select class="select" name="type">
<option value="plugin" @selected($category->type==='plugin')>插件</option>
<option value="theme" @selected($category->type==='theme')>主题</option>
</select>
</div>
<div class="field"><label>排序</label><input class="input" type="number" name="sort_order" value="{{ $category->sort_order }}"></div>
</div>
<div class="field"><label>描述</label><textarea name="description">{{ $category->description }}</textarea></div>
<div class="tags">
<span class="chip">关联扩展 {{ $category->packages_count }}</span>
</div>
<div class="form-actions">
<button class="btn small" type="submit">保存分类</button>
</div>
</form>
<div class="form-actions">
<form method="post" action="{{ route('webadmin.categories.destroy', $category->id) }}" onsubmit="return confirm('确认删除这个分类吗?');">
@csrf @method('DELETE')
<button class="btn danger small" type="submit">删除分类</button>
</form>
</div>
</div>
@empty
<div class="empty">当前还没有分类。</div>
@endforelse
</div>
<div style="margin-top:14px">{{ $categories->links() }}</div>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>新建{{ $entityLabel }}</h2>
<p>{{ $createHint }}</p>
</div>
</div>
<form method="post" action="{{ route('webadmin.categories.store') }}" class="grid">
@csrf
<div class="form-grid">
<div class="field">
<label>类型</label>
<select class="select" name="type" required>
<option value="plugin" @selected($currentType === 'plugin')>插件</option>
<option value="theme" @selected($currentType === 'theme')>主题</option>
</select>
</div>
<div class="field">
<label>排序</label>
<input class="input" name="sort_order" type="number" value="0">
</div>
<div class="field">
<label>名称</label>
<input class="input" name="name" placeholder="SEO" required>
</div>
<div class="field">
<label>Slug</label>
<input class="input" name="slug" placeholder="seo" required>
</div>
</div>
<div class="field">
<label>描述</label>
<textarea name="description" placeholder="补充说明这个分类的用途"></textarea>
</div>
<div class="form-actions">
<button class="btn" type="submit">创建{{ $entityLabel }}</button>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,72 @@
@extends('admin.layout', [
'title' => 'Tstore Admin · 概览',
'pageTitle' => '概览',
'pageSubtitle' => '先看整体状态,再进入扩展管理、分类管理和版本发布流程。',
])
@section('content')
<div class="grid">
<div class="stats">
<div class="stat"><span class="label">扩展总数</span><span class="value">{{ $stats['packages'] }}</span><span class="hint">插件 + 主题</span></div>
<div class="stat"><span class="label">插件</span><span class="value">{{ $stats['plugins'] }}</span><span class="hint">plugin</span></div>
<div class="stat"><span class="label">主题</span><span class="value">{{ $stats['themes'] }}</span><span class="hint">theme</span></div>
<div class="stat"><span class="label">版本记录</span><span class="value">{{ $stats['versions'] }}</span><span class="hint">已发布与手动录入版本</span></div>
<div class="stat"><span class="label">下载总量</span><span class="value">{{ $stats['downloads'] }}</span><span class="hint">累计下载次数</span></div>
<div class="stat"><span class="label">分类数</span><span class="value">{{ $stats['categories'] }}</span><span class="hint">插件 / 主题分类</span></div>
</div>
<div class="cards">
<div class="panel">
<div class="section-title">
<div>
<h2>最近更新的扩展</h2>
<p>可以直接进入详情页编辑信息、上传 zip或查看当前最新稳定版本。</p>
</div>
<a class="btn secondary small" href="{{ route('webadmin.packages') }}">查看全部</a>
</div>
<div class="list">
@forelse ($recentPackages as $package)
<div class="row-card">
<div class="row-top">
<div>
<h3>{{ $package->name }}</h3>
<p class="muted">{{ $package->type }} · {{ $package->slug }}</p>
</div>
<span class="chip {{ $package->status === 'published' ? 'ok' : ($package->status === 'draft' ? 'muted' : 'warn') }}">{{ $package->status }}</span>
</div>
<p class="muted">{{ $package->summary ?: '暂无摘要' }}</p>
<div class="tags">
@foreach ($package->categories as $category)
<span class="chip">{{ $category->name }}</span>
@endforeach
@if ($package->latestStableVersion)
<span class="chip ok">最新稳定版 v{{ $package->latestStableVersion->version }}</span>
@endif
</div>
<div class="form-actions">
<a class="btn secondary small" href="{{ route('webadmin.packages.show', [$package->type, $package->slug]) }}">查看详情</a>
</div>
</div>
@empty
<div class="empty">当前还没有扩展数据。</div>
@endforelse
</div>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>当前后台能力</h2>
<p>这一版已经能覆盖联调闭环里最关键的管理动作。</p>
</div>
</div>
<div class="list">
<div class="mini-card"><h3>扩展管理</h3><div class="muted">支持创建 package、编辑基础信息、切换发布状态。</div></div>
<div class="mini-card"><h3>分类管理</h3><div class="muted">支持新建、编辑、删除分类,并查看分类关联的扩展数量。</div></div>
<div class="mini-card"><h3>版本管理</h3><div class="muted">支持手动录入版本、zip 上传发布、删除历史版本。</div></div>
<div class="mini-card"><h3>下一步建议</h3><div class="muted">可以继续补截图管理、审核日志、下载统计细分和更严格的发布校验。</div></div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $title ?? 'Tstore Admin' }}</title>
<style>
:root{--bg:#f3f7fb;--panel:#ffffff;--panel-2:#f7fbff;--text:#16324f;--muted:#607489;--line:#dce6f1;--brand:#2f6ea6;--brand-2:#4f90c8;--ok:#1f8b4c;--warn:#b36b00;--danger:#c14f4f;--shadow:0 12px 30px rgba(16,36,64,.08)}
*{box-sizing:border-box}body{margin:0;background:linear-gradient(180deg,#f6f9fc 0,#eef4f9 100%);color:var(--text);font:14px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif}
a{color:inherit}.page{display:grid;grid-template-columns:260px minmax(0,1fr);min-height:100vh}
.sidebar{background:linear-gradient(180deg,#16324f 0,#1d456b 100%);color:#fff;padding:24px 18px;position:sticky;top:0;height:100vh}
.brand{font-size:22px;font-weight:800;letter-spacing:.02em;margin-bottom:6px}.brand-sub{font-size:12px;color:rgba(230,240,255,.72);margin-bottom:24px}
.nav{display:grid;gap:10px}.nav a{display:flex;align-items:center;padding:11px 14px;border-radius:14px;text-decoration:none;color:rgba(241,247,255,.9);font-weight:700;background:transparent;border:1px solid transparent}.nav a.active,.nav a:hover{background:rgba(255,255,255,.10);border-color:rgba(255,255,255,.08)}
.sidebar-foot{position:absolute;left:18px;right:18px;bottom:20px;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.08);border-radius:16px;padding:14px}.sidebar-foot p{margin:0;color:rgba(235,243,255,.84);font-size:12px;line-height:1.7}.sidebar-foot .muted-mini{display:block;margin-top:8px;color:rgba(224,236,251,.68);font-size:11px}
.content{padding:28px}.topbar{display:flex;justify-content:space-between;gap:16px;align-items:center;margin-bottom:20px}.title h1{margin:0 0 4px;font-size:28px;line-height:1.15}.title p{margin:0;color:var(--muted)}
.top-actions{display:flex;gap:10px;flex-wrap:wrap}.btn,.btn-link button{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 14px;border-radius:12px;border:1px solid transparent;background:linear-gradient(135deg,var(--brand),var(--brand-2));color:#fff;text-decoration:none;font-weight:700;cursor:pointer;box-shadow:0 10px 22px rgba(47,110,166,.18)}
.btn.secondary{background:#fff;color:var(--brand);border-color:#cfe0f1;box-shadow:none}.btn.small,.btn-link button.small{padding:8px 12px;font-size:12px;border-radius:10px}.btn.ghost,.btn-link button.ghost{background:#fff;border-color:var(--line);color:var(--text);box-shadow:none}.btn.danger,.btn-link button.danger{background:#fff2f2;border-color:#f1cccc;color:var(--danger);box-shadow:none}
.btn-link{display:inline}.btn-link form{display:inline}
.flash{margin-bottom:16px;padding:12px 14px;border-radius:14px;font-weight:700}.flash.success{background:#edf9f0;color:var(--ok);border:1px solid #cfead8}.flash.error{background:#fff4f3;color:var(--danger);border:1px solid #f1d2cf}
.panel{background:rgba(255,255,255,.92);border:1px solid var(--line);border-radius:22px;padding:18px;box-shadow:var(--shadow)}
.grid{display:grid;gap:18px}.stats{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:16px}.stat{background:linear-gradient(180deg,#fff 0,#f9fbfd 100%);border:1px solid var(--line);border-radius:20px;padding:18px}.stat .label{display:block;font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px}.stat .value{display:block;font-size:28px;font-weight:800;line-height:1.1}.stat .hint{display:block;margin-top:8px;color:var(--muted);font-size:12px}
.cards{display:grid;grid-template-columns:1.2fr .8fr;gap:18px}.section-title{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}.section-title h2{margin:0;font-size:18px}.section-title p{margin:0;color:var(--muted);font-size:13px}
.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:18px;background:#fff}.table{width:100%;border-collapse:separate;border-spacing:0}.table th,.table td{padding:14px 16px;border-bottom:1px solid #ecf1f6;text-align:left;vertical-align:top}.table th{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;background:#f8fbfd}.table tr:hover td{background:#fbfdff}
.chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700;background:#edf4fb;color:#2d689d;border:1px solid #d8e7f5}.chip.ok{background:#edf9f0;color:var(--ok);border-color:#cfead8}.chip.warn{background:#fff8eb;color:var(--warn);border-color:#f2dfb1}.chip.muted{background:#f3f6f9;color:#667a90;border-color:#e0e7ef}
.stack{display:grid;gap:14px}.mini-card{border:1px solid var(--line);border-radius:18px;padding:16px;background:linear-gradient(180deg,#fff 0,#fbfdff 100%)}.mini-card h3{margin:0 0 6px;font-size:16px}.muted{color:var(--muted)}
.toolbar{display:flex;justify-content:space-between;gap:12px;align-items:flex-end;flex-wrap:wrap;margin-bottom:16px}.filters{display:flex;gap:10px;flex-wrap:wrap}.field{display:grid;gap:6px}.field label{font-size:12px;color:var(--muted);font-weight:700}.input,.select,textarea{width:100%;padding:11px 13px;border:1px solid #cfdae8;border-radius:12px;background:#f9fbfd;color:var(--text);outline:none}.input:focus,.select:focus,textarea:focus{border-color:#77aee6;box-shadow:0 0 0 4px rgba(89,156,226,.14);background:#fff}textarea{min-height:96px;resize:vertical}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.form-grid.full{grid-template-columns:1fr}.form-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px}
.list{display:grid;gap:12px}.row-card{border:1px solid var(--line);border-radius:18px;padding:16px;background:linear-gradient(180deg,#fff 0,#fbfdff 100%)}.row-top{display:flex;justify-content:space-between;gap:16px;align-items:flex-start}.row-top h3{margin:0;font-size:18px}.row-top p{margin:6px 0 0}.tags{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.split{display:grid;grid-template-columns:1.2fr .8fr;gap:18px}.empty{padding:36px 18px;border:1px dashed var(--line);border-radius:18px;text-align:center;background:#fbfdff;color:var(--muted)}
@media (max-width:1200px){.stats{grid-template-columns:repeat(3,minmax(0,1fr))}.cards,.split{grid-template-columns:1fr}}@media (max-width:860px){.page{grid-template-columns:1fr}.sidebar{position:static;height:auto}.content{padding:18px}.stats{grid-template-columns:repeat(2,minmax(0,1fr))}.form-grid{grid-template-columns:1fr}}@media (max-width:560px){.stats{grid-template-columns:1fr}.topbar{flex-direction:column;align-items:flex-start}.filters{width:100%}.field{width:100%}}
</style>
</head>
<body>
<div class="page">
<aside class="sidebar">
<div class="brand">Tstore Admin</div>
<div class="brand-sub">Laravel management console</div>
<nav class="nav">
<a href="{{ route('webadmin.home') }}" class="{{ request()->routeIs('webadmin.home') ? 'active' : '' }}">概览</a>
<a href="{{ route('webadmin.packages') }}" class="{{ request()->routeIs('webadmin.packages*') && !request('type') ? 'active' : '' }}">扩展管理</a>
<a href="{{ route('webadmin.categories') }}" class="{{ request()->routeIs('webadmin.categories*') ? 'active' : '' }}">分类管理</a>
<a href="{{ route('webadmin.packages', ['type' => 'plugin']) }}" class="{{ request()->routeIs('webadmin.packages*') && request('type') === 'plugin' ? 'active' : '' }}">插件列表</a>
<a href="{{ route('webadmin.packages', ['type' => 'theme']) }}" class="{{ request()->routeIs('webadmin.packages*') && request('type') === 'theme' ? 'active' : '' }}">主题列表</a>
</nav>
<div class="sidebar-foot">
<p>当前后台已接入账号登录并支持分类维护、包管理、zip 上传发布、手动版本管理和版本删除。适合先维护 package 与分类,再进入详情页发布 zip 做联调。</p>
<span class="muted-mini">建议:先登录后台账号,维护 package 和分类,再进入详情页完成 zip 发布。</span>
</div>
</aside>
<main class="content">
<div class="topbar">
<div class="title">
<h1>{{ $pageTitle ?? 'Tstore Admin' }}</h1>
<p>{{ $pageSubtitle ?? '统一管理扩展、分类、版本与发布流程。' }}</p>
</div>
<div class="top-actions">
<a class="btn secondary" href="{{ route('webadmin.home') }}">后台首页</a>
<form method="post" action="{{ route('webadmin.logout') }}">@csrf<button class="btn ghost">退出</button></form>
</div>
</div>
@if (session('success'))
<div class="flash success">{{ session('success') }}</div>
@endif
@if (session('error'))
<div class="flash error">{{ session('error') }}</div>
@endif
@if ($errors->any())
<div class="flash error">{{ $errors->first() }}</div>
@endif
@yield('content')
</main>
</div>
</body>
</html>

View File

@ -0,0 +1,32 @@
@extends('admin.layout', [
'title' => 'Tstore Admin · 后台登录',
'pageTitle' => '后台登录',
'pageSubtitle' => '使用后台账号密码登录,不再直接依赖 token。',
])
@section('content')
<div class="panel" style="max-width:620px">
<form method="post" action="{{ route('webadmin.login.submit') }}" class="grid">
@csrf
<input type="hidden" name="redirect" value="{{ $redirect }}">
<div class="field">
<label>邮箱</label>
<input class="input" type="email" name="email" value="{{ old('email', 'admin@tstore.local') }}" placeholder="admin@tstore.local" required>
</div>
<div class="field">
<label>密码</label>
<input class="input" type="password" name="password" placeholder="输入后台密码" required>
</div>
<label><input type="checkbox" name="remember" value="1"> 记住登录状态</label>
<div class="form-actions">
<button class="btn" type="submit">进入后台</button>
</div>
<div class="mini-card">
<h3>默认管理员</h3>
<div class="muted">邮箱admin@tstore.local</div>
<div class="muted">密码Admin@123456</div>
<div class="muted">可以在 .env 中通过 ADMIN_EMAIL / ADMIN_PASSWORD 修改。</div>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,198 @@
@extends('admin.layout', [
'title' => 'Tstore Admin · 插件 / 主题管理',
'pageTitle' => $filters['type'] === 'plugin' ? '插件列表' : ($filters['type'] === 'theme' ? '主题列表' : '扩展列表'),
'pageSubtitle' => $filters['type'] === 'plugin'
? '查看、筛选、维护和发布插件,统一处理插件版本与状态。'
: ($filters['type'] === 'theme'
? '查看、筛选、维护和发布主题,统一处理主题版本与状态。'
: '查看全部插件与主题,统一管理扩展列表、详情页与发布版本。'),
])
@php
$currentType = $filters['type'] ?? '';
$entityLabel = $currentType === 'plugin' ? '插件' : ($currentType === 'theme' ? '主题' : '扩展');
$entityPluralLabel = $currentType === 'plugin' ? '插件列表' : ($currentType === 'theme' ? '主题列表' : '扩展列表');
$newEntityLabel = $currentType === 'plugin' ? '新建插件' : ($currentType === 'theme' ? '新建主题' : '新建扩展');
$filterHint = $currentType === 'plugin' ? '按类型、状态和关键词快速定位插件。'
: ($currentType === 'theme' ? '按类型、状态和关键词快速定位主题。' : '按类型、状态和关键词快速定位扩展。');
$listHint = $currentType === 'plugin' ? '支持查看插件详情、编辑元数据、上传 zip 发布版本,以及切换插件状态。'
: ($currentType === 'theme' ? '支持查看主题详情、编辑元数据、上传 zip 发布版本,以及切换主题状态。'
: '支持查看详情、编辑元数据、上传 zip 发布版本,以及切换扩展状态。');
$createHint = $currentType === 'plugin' ? '先创建插件 package再进入详情页补充版本或直接上传 zip 发布。'
: ($currentType === 'theme' ? '先创建主题 package再进入详情页补充版本或直接上传 zip 发布。'
: '先创建 package再进入详情页补充版本或直接上传 zip 发布。');
$emptyHint = '当前还没有' . $entityLabel . '。';
@endphp
@section('content')
<div class="grid">
<div class="panel">
<div class="section-title">
<div>
<h2>筛选与查询</h2>
<p>{{ $filterHint }}</p>
</div>
</div>
<form method="get" class="toolbar">
<div class="filters">
<div class="field">
<label>类型</label>
<select name="type" class="select">
<option value="">全部</option>
<option value="plugin" @selected($filters['type']==='plugin')>插件</option>
<option value="theme" @selected($filters['type']==='theme')>主题</option>
</select>
</div>
<div class="field">
<label>状态</label>
<select name="status" class="select">
<option value="">全部</option>
<option value="draft" @selected($filters['status']==='draft')>draft</option>
<option value="published" @selected($filters['status']==='published')>published</option>
<option value="hidden" @selected($filters['status']==='hidden')>hidden</option>
<option value="deprecated" @selected($filters['status']==='deprecated')>deprecated</option>
</select>
</div>
<div class="field" style="min-width:280px">
<label>关键词</label>
<input class="input" type="text" name="keyword" value="{{ $filters['keyword'] }}" placeholder="搜索 name / slug / summary">
</div>
</div>
<div class="form-actions">
<button class="btn" type="submit">筛选</button>
<a class="btn secondary" href="{{ route('webadmin.packages') }}">重置</a>
</div>
</form>
</div>
<div class="split">
<div class="panel">
<div class="section-title">
<div>
<h2>{{ $entityPluralLabel }}</h2>
<p>{{ $listHint }}</p>
</div>
</div>
<div class="table-wrap">
<table class="table">
<thead>
<tr>
<th>{{ $entityLabel }}</th>
<th>类型</th>
<th>状态</th>
<th>最新版本</th>
<th>分类</th>
<th>操作</th>
</tr>
</thead>
<tbody>
@forelse ($packages as $package)
<tr>
<td>
<strong>{{ $package->name }}</strong>
<div class="muted">{{ $package->slug }}</div>
<div class="muted">{{ $package->summary ?: '暂无摘要' }}</div>
</td>
<td>{{ $package->type }}</td>
<td><span class="chip {{ $package->status === 'published' ? 'ok' : ($package->status === 'draft' ? 'muted' : 'warn') }}">{{ $package->status }}</span></td>
<td>{{ $package->latestStableVersion?->version ?: ($package->latest_version ?: '-') }}</td>
<td>
<div class="tags">
@foreach ($package->categories as $category)
<span class="chip">{{ $category->slug }}</span>
@endforeach
</div>
</td>
<td>
<div class="form-actions">
<a class="btn secondary small" href="{{ route('webadmin.packages.show', [$package->type, $package->slug]) }}">详情 / 发布</a>
<form method="post" action="{{ route('webadmin.packages.status', [$package->type, $package->slug]) }}">
@csrf @method('PATCH')
<input type="hidden" name="status" value="{{ $package->status === 'published' ? 'hidden' : 'published' }}">
<button class="btn ghost small" type="submit">{{ $package->status === 'published' ? '隐藏' : '发布' }}</button>
</form>
</div>
</td>
</tr>
@empty
<tr><td colspan="6"><div class="empty">{{ $emptyHint }}</div></td></tr>
@endforelse
</tbody>
</table>
</div>
<div style="margin-top:14px">{{ $packages->links() }}</div>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>{{ $newEntityLabel }}</h2>
<p>{{ $createHint }}</p>
</div>
</div>
<form method="post" action="{{ route('webadmin.packages.store') }}" class="grid">
@csrf
<div class="form-grid">
<div class="field">
<label>类型</label>
<select class="select" name="type" required>
<option value="plugin" @selected($currentType === 'plugin')>插件</option>
<option value="theme" @selected($currentType === 'theme')>主题</option>
</select>
</div>
<div class="field">
<label>Slug</label>
<input class="input" name="slug" placeholder="HelloStore" required>
</div>
<div class="field">
<label>名称</label>
<input class="input" name="name" placeholder="Hello Store" required>
</div>
<div class="field">
<label>状态</label>
<select class="select" name="status">
<option value="published">published</option>
<option value="draft">draft</option>
<option value="hidden">hidden</option>
<option value="deprecated">deprecated</option>
</select>
</div>
<div class="field">
<label>作者</label>
<input class="input" name="author" placeholder="LT083">
</div>
<div class="field">
<label>License</label>
<input class="input" name="license" placeholder="MIT">
</div>
</div>
<div class="field">
<label>摘要</label>
<input class="input" name="summary" placeholder="一句话说明这个{{ $entityLabel }}是做什么的">
</div>
<div class="field">
<label>描述</label>
<textarea name="description" placeholder="详细描述这个{{ $entityLabel }}的用途与定位"></textarea>
</div>
<div class="form-grid">
<div class="field">
<label>主页</label>
<input class="input" name="homepage" placeholder="https://example.com/package">
</div>
<div class="field">
<label>图标 URL</label>
<input class="input" name="icon_url" placeholder="https://example.com/icon.png">
</div>
</div>
<div class="field">
<label>分类 slug多个用空格分隔</label>
<input class="input" name="categories_text" placeholder="seo performance">
</div>
<div class="form-actions">
<button class="btn" type="submit">创建{{ $entityLabel }}</button>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,171 @@
@extends('admin.layout', [
'title' => 'Tstore Admin · ' . $package->name,
'pageTitle' => $package->name,
'pageSubtitle' => ($package->type === 'plugin' ? '插件' : ($package->type === 'theme' ? '主题' : $package->type)) . ' · ' . $package->slug,
])
@php
$entityLabel = $package->type === 'plugin' ? '插件' : ($package->type === 'theme' ? '主题' : '扩展');
@endphp
@section('content')
<div class="grid">
<div class="split">
<div class="panel">
<div class="section-title">
<div>
<h2>{{ $entityLabel }}信息</h2>
<p>编辑基础元数据、分类、图标与发布状态。</p>
</div>
</div>
<form method="post" action="{{ route('webadmin.packages.update', [$package->type, $package->slug]) }}" class="grid">
@csrf @method('PUT')
<div class="form-grid">
<div class="field"><label>类型</label><input class="input" name="type" value="{{ $package->type }}" readonly></div>
<div class="field"><label>Slug</label><input class="input" name="slug" value="{{ $package->slug }}" readonly></div>
<div class="field"><label>名称</label><input class="input" name="name" value="{{ $package->name }}" required></div>
<div class="field"><label>状态</label>
<select class="select" name="status">
@foreach (['draft','published','hidden','deprecated'] as $status)
<option value="{{ $status }}" @selected($package->status === $status)>{{ $status }}</option>
@endforeach
</select>
</div>
<div class="field"><label>作者</label><input class="input" name="author" value="{{ $package->author }}"></div>
<div class="field"><label>License</label><input class="input" name="license" value="{{ $package->license }}"></div>
<div class="field"><label>主页</label><input class="input" name="homepage" value="{{ $package->homepage }}"></div>
<div class="field"><label>图标 URL</label><input class="input" name="icon_url" value="{{ $package->icon_url }}"></div>
</div>
<div class="field"><label>摘要</label><input class="input" name="summary" value="{{ $package->summary }}"></div>
<div class="field"><label>描述</label><textarea name="description">{{ $package->description }}</textarea></div>
<div class="field"><label>分类 slug多个用逗号或空格分隔</label><input class="input" name="categories_text" value="{{ $package->categories->pluck('slug')->implode(', ') }}"></div>
<div class="form-actions">
<button class="btn" type="submit">保存{{ $entityLabel }}信息</button>
<a class="btn secondary" href="{{ route('webadmin.packages', ['type' => $package->type]) }}">返回{{ $entityLabel }}列表</a>
</div>
</form>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>当前状态</h2>
<p>快速查看分类、版本、下载与截图信息。</p>
</div>
</div>
<div class="list">
<div class="mini-card"><h3>状态</h3><div class="tags"><span class="chip {{ $package->status === 'published' ? 'ok' : 'warn' }}">{{ $package->status }}</span><span class="chip">下载 {{ $package->download_count }}</span><span class="chip {{ $package->is_featured ? 'ok' : 'muted' }}">{{ $package->is_featured ? '推荐' : '普通' }}</span></div></div>
<div class="mini-card"><h3>分类</h3><div class="tags">@forelse($package->categories as $category)<span class="chip">{{ $category->name }}</span>@empty<span class="muted">尚未关联分类</span>@endforelse</div></div>
<div class="mini-card"><h3>截图</h3><div class="muted">{{ $package->screenshots->count() }} </div></div>
<div class="mini-card"><h3>最新版本</h3><div class="muted">{{ $package->latest_version ?: '尚未发布' }}</div></div>
</div>
</div>
</div>
<div class="split">
<div class="panel">
<div class="section-title">
<div>
<h2>版本记录</h2>
<p>查看版本状态,也可以直接删除历史版本。</p>
</div>
</div>
<div class="table-wrap">
<table class="table">
<thead>
<tr>
<th>版本</th>
<th>稳定版</th>
<th>最新</th>
<th>兼容性</th>
<th>发布时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
@forelse ($package->versions as $version)
<tr>
<td>
<strong>{{ $version->version }}</strong>
<div class="muted">{{ $version->package_url ?: '未设置 package_url' }}</div>
</td>
<td><span class="chip {{ $version->is_stable ? 'ok' : 'warn' }}">{{ $version->is_stable ? '是' : '否' }}</span></td>
<td><span class="chip {{ $version->is_latest ? 'ok' : 'muted' }}">{{ $version->is_latest ? '最新' : '历史' }}</span></td>
<td>
<div class="muted">Typecho {{ $version->typecho_min ?: '-' }} ~ {{ $version->typecho_max ?: '-' }}</div>
<div class="muted">PHP {{ $version->php_min ?: '-' }} ~ {{ $version->php_max ?: '-' }}</div>
</td>
<td>{{ optional($version->published_at)->format('Y-m-d H:i') }}</td>
<td>
<form method="post" action="{{ route('webadmin.packages.versions.destroy', [$package->type, $package->slug, $version->id]) }}" onsubmit="return confirm('确认删除这个版本吗?');">
@csrf @method('DELETE')
<button class="btn danger small" type="submit">删除</button>
</form>
</td>
</tr>
@empty
<tr><td colspan="6"><div class="empty">当前还没有版本记录。</div></td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>zip 上传发布</h2>
<p>直接调用 publishFromZip manifest 自动生成版本。</p>
</div>
</div>
<form method="post" action="{{ route('webadmin.packages.publish', [$package->type, $package->slug]) }}" class="grid" enctype="multipart/form-data">
@csrf
<div class="field"><label>zip 文件</label><input class="input" type="file" name="package_file" accept=".zip" required></div>
<div class="field"><label>发布说明(可选)</label><textarea name="changelog" placeholder="补充这次发布说明"></textarea></div>
<div class="form-grid">
<div class="field"><label>发布时间(可选)</label><input class="input" type="datetime-local" name="published_at"></div>
<div class="field"><label>发布选项</label>
<div class="tags">
<label><input type="checkbox" name="is_stable" value="1" checked> 设为稳定版</label>
<label><input type="checkbox" name="mark_as_latest" value="1" checked> 设为最新</label>
</div>
</div>
</div>
<div class="form-actions"><button class="btn" type="submit">上传并发布</button></div>
</form>
</div>
</div>
<div class="panel">
<div class="section-title">
<div>
<h2>手动添加版本</h2>
<p>调试阶段可以快速手动录入版本元数据。</p>
</div>
</div>
<form method="post" action="{{ route('webadmin.packages.versions.store', [$package->type, $package->slug]) }}" class="grid">
@csrf
<div class="form-grid">
<div class="field"><label>版本号</label><input class="input" name="version" placeholder="1.0.0" required></div>
<div class="field"><label>发布时间</label><input class="input" type="datetime-local" name="published_at"></div>
<div class="field"><label>Typecho Min</label><input class="input" name="typecho_min" placeholder="1.2.0"></div>
<div class="field"><label>Typecho Max</label><input class="input" name="typecho_max" placeholder="1.3.*"></div>
<div class="field"><label>PHP Min</label><input class="input" name="php_min" placeholder="7.4"></div>
<div class="field"><label>PHP Max</label><input class="input" name="php_max" placeholder="8.3"></div>
<div class="field"><label>Package URL</label><input class="input" name="package_url" placeholder="https://..."></div>
<div class="field"><label>Size</label><input class="input" name="package_size" type="number" placeholder="238000"></div>
<div class="field"><label>SHA256</label><input class="input" name="sha256" placeholder="可选,默认会补 64 位 0"></div>
<div class="field"><label>PHP Extensions</label><input class="input" name="php_extensions" placeholder="curl,json"></div>
</div>
<div class="field"><label>发布说明</label><textarea name="changelog" placeholder="输入更新内容"></textarea></div>
<div class="form-grid">
<label><input type="checkbox" name="is_stable" value="1"> 设为稳定版</label>
<label><input type="checkbox" name="is_latest" value="1"> 设为最新版本</label>
</div>
<div class="form-actions">
<button class="btn" type="submit">添加版本</button>
</div>
</form>
</div>
</div>
@endsection

View File

@ -0,0 +1,102 @@
@extends('storefront.layout', ['title' => 'Tstore · 扩展展示站'])
@section('hero')
<div class="hero-grid">
<div class="hero-card">
<h1>精选 Typecho 插件与主题展示</h1>
<p>这里是展示前台,只负责展示站点里的插件、主题、分类、截图和版本信息,不直接暴露下载地址。</p>
<div class="hero-meta">
<div class="hero-stat"><strong>{{ $stats['packages'] }}</strong><span>已发布扩展</span></div>
<div class="hero-stat"><strong>{{ $stats['plugins'] }}</strong><span>插件</span></div>
<div class="hero-stat"><strong>{{ $stats['themes'] }}</strong><span>主题</span></div>
<div class="hero-stat"><strong>{{ $stats['categories'] }}</strong><span>分类</span></div>
</div>
</div>
<div class="hero-card">
<h3 style="margin:0 0 10px;font-size:20px">当前站点定位</h3>
<p>前台面向访客展示内容,后台则面向管理员,通过账号密码登录后维护扩展、分类、版本和 zip 发布。</p>
<div class="card-actions" style="margin-top:18px">
<a class="btn" href="{{ route('storefront.plugins') }}">查看插件</a>
<a class="btn secondary" href="{{ route('storefront.themes') }}">查看主题</a>
</div>
</div>
</div>
@endsection
@section('content')
<div class="panel">
<div class="section-head">
<div>
<h2>推荐插件</h2>
<p>展示基础信息、版本兼容性与分类,不直接提供 zip 下载地址。</p>
</div>
<a class="btn secondary" href="{{ route('storefront.plugins') }}">查看全部插件</a>
</div>
<div class="grid">
@forelse($featuredPlugins as $package)
<div class="card">
<div class="card-top">
@if($package->icon_url)
<img class="icon" src="{{ $package->icon_url }}" alt="{{ $package->name }}">
@else
<div class="icon"></div>
@endif
<div>
<div class="title">{{ $package->name }}</div>
<div class="muted">{{ $package->author ?: '未知作者' }} · {{ $package->latestStableVersion?->version ?: $package->latest_version }}</div>
</div>
</div>
<div class="summary">{{ $package->summary ?: '暂无摘要' }}</div>
<div class="tags">
@foreach($package->categories as $category)
<span class="chip">{{ $category->name }}</span>
@endforeach
</div>
<div class="card-actions">
<a class="btn secondary" href="{{ route('storefront.show', [$package->type, $package->slug]) }}">查看详情</a>
</div>
</div>
@empty
<div class="empty">当前没有推荐插件。</div>
@endforelse
</div>
</div>
<div class="panel section">
<div class="section-head">
<div>
<h2>推荐主题</h2>
<p>适合做展示站首页,突出视觉风格、分类和版本信息。</p>
</div>
<a class="btn secondary" href="{{ route('storefront.themes') }}">查看全部主题</a>
</div>
<div class="grid">
@forelse($featuredThemes as $package)
<div class="card">
<div class="card-top">
@if($package->icon_url)
<img class="icon" src="{{ $package->icon_url }}" alt="{{ $package->name }}">
@else
<div class="icon"></div>
@endif
<div>
<div class="title">{{ $package->name }}</div>
<div class="muted">{{ $package->author ?: '未知作者' }} · {{ $package->latestStableVersion?->version ?: $package->latest_version }}</div>
</div>
</div>
<div class="summary">{{ $package->summary ?: '暂无摘要' }}</div>
<div class="tags">
@foreach($package->categories as $category)
<span class="chip">{{ $category->name }}</span>
@endforeach
</div>
<div class="card-actions">
<a class="btn secondary" href="{{ route('storefront.show', [$package->type, $package->slug]) }}">查看详情</a>
</div>
</div>
@empty
<div class="empty">当前没有推荐主题。</div>
@endforelse
</div>
</div>
@endsection

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $title ?? 'Tstore' }}</title>
<style>
:root{--bg:#0f172a;--panel:#ffffff;--soft:#f5f8fc;--line:#dbe5f0;--text:#16324f;--muted:#607489;--brand:#2f6ea6;--brand-2:#61a6e3;--shadow:0 18px 48px rgba(15,23,42,.08)}
*{box-sizing:border-box}body{margin:0;font:14px/1.7 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:#f4f8fb;color:var(--text)}a{text-decoration:none;color:inherit}
.container{max-width:1180px;margin:0 auto;padding:0 20px}.hero{background:linear-gradient(135deg,#10233a 0%,#16324f 42%,#24527c 100%);color:#fff;padding:24px 0 84px}.nav{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:18px 0}.brand{font-size:22px;font-weight:800}.nav-links{display:flex;gap:10px;flex-wrap:wrap}.nav-links a{padding:10px 14px;border-radius:999px;color:rgba(240,247,255,.88)}.nav-links a:hover,.nav-links a.active{background:rgba(255,255,255,.12)}
.hero-grid{display:grid;grid-template-columns:1.15fr .85fr;gap:18px;align-items:center;padding-top:10px}.hero-card{background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.12);border-radius:26px;padding:26px;backdrop-filter:blur(10px)}.hero h1{margin:0 0 12px;font-size:44px;line-height:1.08;letter-spacing:-.03em}.hero p{margin:0;color:rgba(230,239,249,.9);max-width:680px}.hero-meta{display:flex;gap:12px;flex-wrap:wrap;margin-top:20px}.hero-stat{min-width:120px;padding:14px 16px;border-radius:18px;background:rgba(255,255,255,.12)}.hero-stat strong{display:block;font-size:24px}.hero-stat span{display:block;font-size:12px;color:rgba(231,239,248,.78);margin-top:4px}
.shell{margin-top:-52px;padding-bottom:48px}.panel{background:#fff;border:1px solid var(--line);border-radius:24px;padding:22px;box-shadow:var(--shadow)}.section{margin-top:18px}.section-head{display:flex;justify-content:space-between;align-items:end;gap:16px;margin-bottom:14px}.section-head h2{margin:0;font-size:24px}.section-head p{margin:6px 0 0;color:var(--muted)}
.toolbar{display:flex;justify-content:space-between;gap:12px;align-items:flex-end;flex-wrap:wrap;margin-bottom:16px}.filters{display:flex;gap:10px;flex-wrap:wrap}.field{display:grid;gap:6px}.field label{font-size:12px;color:var(--muted);font-weight:700}.input,.select{padding:11px 13px;border:1px solid #cfdae8;border-radius:12px;background:#f9fbfd;min-width:180px}.input:focus,.select:focus{outline:none;border-color:#77aee6;box-shadow:0 0 0 4px rgba(89,156,226,.12);background:#fff}
.btn{display:inline-flex;align-items:center;justify-content:center;padding:11px 15px;border-radius:12px;background:linear-gradient(135deg,var(--brand),var(--brand-2));color:#fff;font-weight:700;border:none;cursor:pointer}.btn.secondary{background:#fff;color:var(--brand);border:1px solid #cfe0f1}
.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}.card{background:linear-gradient(180deg,#fff 0,#fbfdff 100%);border:1px solid var(--line);border-radius:22px;padding:18px;box-shadow:0 12px 28px rgba(15,23,42,.05)}.card-top{display:flex;gap:14px;align-items:flex-start}.icon{width:64px;height:64px;border-radius:18px;background:#edf4fb;object-fit:cover;border:1px solid #d9e6f3}.title{font-size:18px;font-weight:800;margin:0}.muted{color:var(--muted)}.summary{margin:14px 0;color:#4a6176;min-height:72px}.tags{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700;background:#edf4fb;color:#2d689d;border:1px solid #d8e7f5}.card-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
.stats-row{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.stat{padding:18px;border-radius:22px;background:linear-gradient(180deg,#ffffff 0,#f8fbfe 100%);border:1px solid var(--line)}.stat strong{display:block;font-size:30px;line-height:1.1}.stat span{display:block;margin-top:6px;color:var(--muted)}
.detail-grid{display:grid;grid-template-columns:1.2fr .8fr;gap:18px}.detail-card{background:#fff;border:1px solid var(--line);border-radius:22px;padding:20px;box-shadow:var(--shadow)}.detail-card h3{margin:0 0 12px;font-size:20px}.version-list{display:grid;gap:10px}.version{border:1px solid var(--line);border-radius:16px;padding:14px;background:#fbfdff}.version strong{font-size:16px}
.gallery{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.shot{border:1px solid var(--line);border-radius:16px;overflow:hidden;background:#fff}.shot img{width:100%;height:180px;object-fit:cover;display:block}.shot div{padding:10px 12px;color:var(--muted);font-size:13px}
.empty{padding:36px 18px;border:1px dashed var(--line);border-radius:18px;text-align:center;background:#fbfdff;color:var(--muted)}
@media (max-width:960px){.hero-grid,.detail-grid{grid-template-columns:1fr}.grid,.stats-row{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (max-width:640px){.grid,.stats-row,.gallery{grid-template-columns:1fr}.hero h1{font-size:34px}.shell{margin-top:-36px}.nav{flex-direction:column;align-items:flex-start}}
</style>
</head>
<body>
<header class="hero">
<div class="container">
<div class="nav">
<div class="brand"><a href="{{ route('storefront.home') }}">Tstore</a></div>
<div class="nav-links">
<a href="{{ route('storefront.home') }}" class="{{ request()->routeIs('storefront.home') ? 'active' : '' }}">首页</a>
<a href="{{ route('storefront.plugins') }}" class="{{ request()->routeIs('storefront.plugins') ? 'active' : '' }}">插件</a>
<a href="{{ route('storefront.themes') }}" class="{{ request()->routeIs('storefront.themes') ? 'active' : '' }}">主题</a>
<a href="{{ route('webadmin.login') }}">后台登录</a>
</div>
</div>
@yield('hero')
</div>
</header>
<main class="shell">
<div class="container">
@yield('content')
</div>
</main>
</body>
</html>

View File

@ -0,0 +1,79 @@
@extends('storefront.layout', ['title' => 'Tstore · ' . ($type === 'plugin' ? '插件' : '主题')])
@section('hero')
<div class="hero-grid">
<div class="hero-card">
<h1>{{ $type === 'plugin' ? '插件目录' : '主题目录' }}</h1>
<p>支持按分类和关键词浏览 {{ $type === 'plugin' ? '插件' : '主题' }},这里只展示信息,不直接提供下载地址。</p>
</div>
<div class="hero-card">
<form method="get" class="toolbar" style="margin:0">
<div class="filters" style="width:100%">
<div class="field" style="flex:1 1 220px">
<label>关键词</label>
<input class="input" type="text" name="keyword" value="{{ $filters['keyword'] }}" placeholder="搜索名称、slug 或摘要">
</div>
<div class="field">
<label>分类</label>
<select class="select" name="category">
<option value="">全部</option>
@foreach($categories as $category)
<option value="{{ $category->slug }}" @selected($filters['category'] === $category->slug)>{{ $category->name }}</option>
@endforeach
</select>
</div>
<div class="field">
<label>排序</label>
<select class="select" name="sort">
<option value="latest" @selected($filters['sort'] === 'latest')>最新更新</option>
<option value="name" @selected($filters['sort'] === 'name')>按名称</option>
</select>
</div>
</div>
<div class="card-actions">
<button class="btn" type="submit">筛选</button>
</div>
</form>
</div>
</div>
@endsection
@section('content')
<div class="panel">
<div class="section-head">
<div>
<h2>{{ $type === 'plugin' ? '插件列表' : '主题列表' }}</h2>
<p> {{ $packages->total() }} 项结果</p>
</div>
</div>
<div class="grid">
@forelse($packages as $package)
<div class="card">
<div class="card-top">
@if($package->icon_url)
<img class="icon" src="{{ $package->icon_url }}" alt="{{ $package->name }}">
@else
<div class="icon"></div>
@endif
<div>
<div class="title">{{ $package->name }}</div>
<div class="muted">{{ $package->author ?: '未知作者' }} · {{ $package->latestStableVersion?->version ?: $package->latest_version }}</div>
</div>
</div>
<div class="summary">{{ $package->summary ?: '暂无摘要' }}</div>
<div class="tags">
@foreach($package->categories as $category)
<span class="chip">{{ $category->name }}</span>
@endforeach
</div>
<div class="card-actions">
<a class="btn secondary" href="{{ route('storefront.show', [$package->type, $package->slug]) }}">查看详情</a>
</div>
</div>
@empty
<div class="empty">当前没有符合条件的{{ $type === 'plugin' ? '插件' : '主题' }}</div>
@endforelse
</div>
<div style="margin-top:18px">{{ $packages->links() }}</div>
</div>
@endsection

View File

@ -0,0 +1,99 @@
@extends('storefront.layout', ['title' => 'Tstore · ' . $package->name])
@section('hero')
<div class="hero-grid">
<div class="hero-card">
<h1>{{ $detail['name'] }}</h1>
<p>{{ $detail['summary'] ?: '暂无摘要' }}</p>
<div class="hero-meta">
<div class="hero-stat"><strong>{{ $detail['type'] }}</strong><span>类型</span></div>
<div class="hero-stat"><strong>{{ $detail['download_count'] }}</strong><span>累计下载</span></div>
<div class="hero-stat"><strong>{{ count($detail['versions']) }}</strong><span>版本数</span></div>
<div class="hero-stat"><strong>{{ count($detail['categories']) }}</strong><span>分类</span></div>
</div>
</div>
<div class="hero-card">
<h3 style="margin:0 0 10px;font-size:20px">说明</h3>
<p>这是前台展示页,只展示扩展信息、版本兼容性和截图,不直接暴露下载地址。需要维护请进入后台。</p>
<div class="card-actions" style="margin-top:18px">
<a class="btn secondary" href="{{ route('webadmin.login') }}">后台登录</a>
</div>
</div>
</div>
@endsection
@section('content')
<div class="detail-grid">
<div class="detail-card">
<h3>扩展说明</h3>
<div class="muted">作者:{{ $detail['author'] ?: '未知作者' }}</div>
<div class="muted">主页:{{ $detail['homepage'] ?: '未提供' }}</div>
<div class="tags">
@foreach($package->categories as $category)
<span class="chip">{{ $category->name }}</span>
@endforeach
</div>
<div style="margin-top:16px;white-space:pre-wrap">{{ $detail['description'] ?: '暂无详细描述。' }}</div>
</div>
<div class="detail-card">
<h3>版本信息</h3>
<div class="version-list">
@forelse($detail['versions'] as $version)
<div class="version">
<strong>v{{ $version['version'] }}</strong>
<div class="muted">{{ $version['is_latest'] ? '最新版本' : '历史版本' }} · {{ $version['is_stable'] ? '稳定版' : '预发布' }}</div>
<div class="muted">Typecho {{ $version['compatibility']['typecho_min'] ?: '-' }} ~ {{ $version['compatibility']['typecho_max'] ?: '-' }}</div>
<div class="muted">PHP {{ $version['compatibility']['php_min'] ?: '-' }} ~ {{ $version['compatibility']['php_max'] ?: '-' }}</div>
@if(!empty($version['changelog']))
<div style="margin-top:8px">{{ $version['changelog'] }}</div>
@endif
</div>
@empty
<div class="empty">当前没有版本记录。</div>
@endforelse
</div>
</div>
</div>
@if(count($detail['screenshots']))
<div class="panel section">
<div class="section-head">
<div>
<h2>截图展示</h2>
<p>只展示视觉效果,不提供下载入口。</p>
</div>
</div>
<div class="gallery">
@foreach($detail['screenshots'] as $shot)
<div class="shot">
<img src="{{ $shot['url'] }}" alt="{{ $shot['caption'] ?: $detail['name'] }}">
<div>{{ $shot['caption'] ?: '扩展截图' }}</div>
</div>
@endforeach
</div>
</div>
@endif
<div class="panel section">
<div class="section-head">
<div>
<h2>更多{{ $package->type === 'plugin' ? '插件' : '主题' }}</h2>
<p>继续浏览同类内容。</p>
</div>
</div>
<div class="grid">
@forelse($related as $item)
<div class="card">
<div class="title">{{ $item->name }}</div>
<div class="muted">{{ $item->summary ?: '暂无摘要' }}</div>
<div class="card-actions">
<a class="btn secondary" href="{{ route('storefront.show', [$item->type, $item->slug]) }}">查看详情</a>
</div>
</div>
@empty
<div class="empty">当前没有更多相关内容。</div>
@endforelse
</div>
</div>
@endsection

File diff suppressed because one or more lines are too long

30
routes/admin.php Normal file
View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\PackageController;
use App\Http\Controllers\Admin\VersionController;
Route::prefix('admin')->middleware('store.admin')->group(function () {
Route::get('/packages', [PackageController::class, 'index']);
Route::post('/packages', [PackageController::class, 'store']);
Route::put('/packages/{type}/{slug}', [PackageController::class, 'update'])
->where('type', 'plugin|theme');
Route::patch('/packages/{type}/{slug}/status', [PackageController::class, 'updateStatus'])
->where('type', 'plugin|theme');
Route::delete('/packages/{type}/{slug}', [PackageController::class, 'destroy'])
->where('type', 'plugin|theme');
Route::get('/packages/{type}/{slug}/versions', [VersionController::class, 'index'])
->where('type', 'plugin|theme');
Route::post('/packages/{type}/{slug}/versions', [VersionController::class, 'store'])
->where('type', 'plugin|theme');
Route::post('/packages/{type}/{slug}/versions/publish', [VersionController::class, 'publish'])
->where('type', 'plugin|theme');
Route::delete('/versions/{id}', [VersionController::class, 'destroy']);
Route::get('/categories', [CategoryController::class, 'index']);
Route::post('/categories', [CategoryController::class, 'store']);
Route::put('/categories/{id}', [CategoryController::class, 'update']);
Route::delete('/categories/{id}', [CategoryController::class, 'destroy']);
});

15
routes/api.php Normal file
View File

@ -0,0 +1,15 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\RepoController;
use App\Http\Controllers\Api\CategoryController;
Route::prefix('v1/repo')->group(function () {
Route::get('/index', [RepoController::class, 'index']);
Route::get('/packages/{type}/{slug}', [RepoController::class, 'detail'])
->where('type', 'plugin|theme');
Route::post('/updates/check', [RepoController::class, 'checkUpdates']);
Route::get('/download/{type}/{slug}/{version}', [RepoController::class, 'download'])
->where('type', 'plugin|theme');
Route::get('/categories', [CategoryController::class, 'index']);
});

8
routes/console.php Normal file
View File

@ -0,0 +1,8 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

33
routes/web.php Normal file
View File

@ -0,0 +1,33 @@
<?php
use App\Http\Controllers\Web\StorefrontController;
use App\Http\Controllers\WebAdmin\AuthController;
use App\Http\Controllers\WebAdmin\DashboardController;
use Illuminate\Support\Facades\Route;
Route::get('/', [StorefrontController::class, 'home'])->name('storefront.home');
Route::get('/plugins', [StorefrontController::class, 'packages'])->defaults('type', 'plugin')->name('storefront.plugins');
Route::get('/themes', [StorefrontController::class, 'packages'])->defaults('type', 'theme')->name('storefront.themes');
Route::get('/packages/{type}/{slug}', [StorefrontController::class, 'show'])->name('storefront.show');
Route::get('/admin/login', [AuthController::class, 'showLogin'])->name('webadmin.login');
Route::post('/admin/login', [AuthController::class, 'login'])->name('webadmin.login.submit');
Route::middleware('store.webadmin')->group(function () {
Route::get('/admin', [DashboardController::class, 'home'])->name('webadmin.home');
Route::post('/admin/logout', [AuthController::class, 'logout'])->name('webadmin.logout');
Route::get('/admin/packages', [DashboardController::class, 'packages'])->name('webadmin.packages');
Route::post('/admin/packages', [DashboardController::class, 'storePackage'])->name('webadmin.packages.store');
Route::put('/admin/packages/{type}/{slug}', [DashboardController::class, 'updatePackage'])->name('webadmin.packages.update');
Route::patch('/admin/packages/{type}/{slug}/status', [DashboardController::class, 'updatePackageStatus'])->name('webadmin.packages.status');
Route::get('/admin/packages/{type}/{slug}', [DashboardController::class, 'showPackage'])->name('webadmin.packages.show');
Route::post('/admin/packages/{type}/{slug}/versions', [DashboardController::class, 'storeVersion'])->name('webadmin.packages.versions.store');
Route::post('/admin/packages/{type}/{slug}/publish', [DashboardController::class, 'publishVersion'])->name('webadmin.packages.publish');
Route::delete('/admin/packages/{type}/{slug}/versions/{id}', [DashboardController::class, 'destroyVersion'])->name('webadmin.packages.versions.destroy');
Route::get('/admin/categories', [DashboardController::class, 'categories'])->name('webadmin.categories');
Route::post('/admin/categories', [DashboardController::class, 'storeCategory'])->name('webadmin.categories.store');
Route::put('/admin/categories/{id}', [DashboardController::class, 'updateCategory'])->name('webadmin.categories.update');
Route::delete('/admin/categories/{id}', [DashboardController::class, 'destroyCategory'])->name('webadmin.categories.destroy');
});

4
storage/app/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*
!private/
!public/
!.gitignore

2
storage/app/private/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/app/public/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

9
storage/framework/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
compiled.php
config.php
down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

3
storage/framework/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!data/
!.gitignore

View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/sessions/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/testing/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/views/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/logs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}

10
tests/TestCase.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}

View File

@ -0,0 +1,16 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}

18
vite.config.js Normal file
View File

@ -0,0 +1,18 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
tailwindcss(),
],
server: {
watch: {
ignored: ['**/storage/framework/views/**'],
},
},
});