feat: 富文本编辑

This commit is contained in:
2026-04-16 16:20:52 +08:00
parent 295cf12899
commit 6acd0ccad0
8 changed files with 150 additions and 40 deletions

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::table('guide_pages', function (Blueprint $table) {
$table->dropColumn('html_url');
$table->longText('content')->nullable()->after('title')->comment('富文本正文HTML');
});
}
public function down(): void
{
Schema::table('guide_pages', function (Blueprint $table) {
$table->dropColumn('content');
$table->string('html_url', 500)->after('title')->comment('HTML页面链接');
});
}
};

View File

@@ -11,8 +11,6 @@ use Illuminate\Database\Seeder;
class GuideSeeder extends Seeder
{
private const BASE_URL = 'https://ssrf.9z.work/guides';
/**
* Run the database seeds.
*/
@@ -46,6 +44,11 @@ class GuideSeeder extends Seeder
$this->command->info(' - 关联线站数量: ' . $stations->count());
}
private function placeholder(string $title): string
{
return '<p>本步骤说明待补充。管理员可在 Filament 后台使用富文本编辑器完善「' . e($title) . '」的操作指引。</p>';
}
private function createHowToUseBeamGuide(User $admin): Guide
{
$this->command->info('创建指引: 如何用光...');
@@ -60,49 +63,47 @@ class GuideSeeder extends Seeder
'published_at' => now(),
]);
$baseUrl = self::BASE_URL . '/how-to-use-beam';
$step1 = GuidePage::create([
'guide_id' => $guide->id,
'title' => '打开光子光闸 PS1',
'html_url' => "{$baseUrl}/step-1.html",
'content' => $this->placeholder('打开光子光闸 PS1'),
]);
$step2 = GuidePage::create([
'guide_id' => $guide->id,
'title' => '搜索光学棚屋',
'html_url' => "{$baseUrl}/step-2.html",
'content' => $this->placeholder('搜索光学棚屋'),
'options' => ['前门12', '后门'],
]);
$step3a = GuidePage::create([
'guide_id' => $guide->id,
'title' => '前门12路径 - 检查设备状态',
'html_url' => "{$baseUrl}/step-3a.html",
'content' => $this->placeholder('前门12路径 - 检查设备状态'),
]);
$step3b = GuidePage::create([
'guide_id' => $guide->id,
'title' => '后门路径 - 安全确认',
'html_url' => "{$baseUrl}/step-3b.html",
'content' => $this->placeholder('后门路径 - 安全确认'),
]);
$step4a = GuidePage::create([
'guide_id' => $guide->id,
'title' => '前门12路径 - 打开实验站光闸',
'html_url' => "{$baseUrl}/step-4a.html",
'content' => $this->placeholder('前门12路径 - 打开实验站光闸'),
]);
$step4b = GuidePage::create([
'guide_id' => $guide->id,
'title' => '后门路径 - 设备检查',
'html_url' => "{$baseUrl}/step-4b.html",
'content' => $this->placeholder('后门路径 - 设备检查'),
]);
$step5 = GuidePage::create([
'guide_id' => $guide->id,
'title' => '完成',
'html_url' => "{$baseUrl}/step-5.html",
'content' => $this->placeholder('完成'),
]);
// step1 → step2 (sequential)
@@ -185,21 +186,20 @@ class GuideSeeder extends Seeder
'published_at' => now(),
]);
$baseUrl = self::BASE_URL . '/vacuum-valve-issue';
$steps = [
['title' => '检查真空度', 'file' => 'step-1.html'],
['title' => '检查联锁状态', 'file' => 'step-2.html'],
['title' => '尝试手动复位', 'file' => 'step-3.html'],
['title' => '检查气动系统', 'file' => 'step-4.html'],
['title' => '联系维护人员', 'file' => 'step-5.html'],
'检查真空度',
'检查联锁状态',
'尝试手动复位',
'检查气动系统',
'联系维护人员',
];
$pages = [];
foreach ($steps as $i => $step) {
foreach ($steps as $title) {
$pages[] = GuidePage::create([
'guide_id' => $guide->id,
'title' => $step['title'],
'html_url' => "{$baseUrl}/{$step['file']}",
'title' => $title,
'content' => $this->placeholder($title),
]);
}
@@ -231,21 +231,20 @@ class GuideSeeder extends Seeder
'published_at' => now(),
]);
$baseUrl = self::BASE_URL . '/water-leak-alarm';
$steps = [
['title' => '确认报警位置', 'file' => 'step-1.html'],
['title' => '搜索光学棚屋', 'file' => 'step-2.html'],
['title' => '定位并处理漏水点', 'file' => 'step-3.html'],
['title' => '复位报警', 'file' => 'step-4.html'],
['title' => '完成', 'file' => 'step-5.html'],
'确认报警位置',
'搜索光学棚屋',
'定位并处理漏水点',
'复位报警',
'完成',
];
$pages = [];
foreach ($steps as $i => $step) {
foreach ($steps as $title) {
$pages[] = GuidePage::create([
'guide_id' => $guide->id,
'title' => $step['title'],
'html_url' => "{$baseUrl}/{$step['file']}",
'title' => $title,
'content' => $this->placeholder($title),
]);
}