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
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+45
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,
]);
}
}
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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');
}
};
+25
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),
]
);
}
}
+16
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,
]);
}
}
+324
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'],
]
);
}
}
}
}