questions-json-import.blade.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <x-filament::page>
  2. <div class="space-y-6">
  3. <x-filament::section
  4. description="上传题目 JSON 后,点击页面右上角「一键导入」或下方绿色按钮,即可写入本地 questions 并生成可复制到服务器的 SQL 文件。"
  5. >
  6. {{ $this->form }}
  7. <div class="mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:flex-wrap">
  8. <x-filament::button
  9. type="button"
  10. wire:click="runImport"
  11. color="success"
  12. size="lg"
  13. class="w-full sm:w-auto font-semibold"
  14. >
  15. 一键导入
  16. </x-filament::button>
  17. <span class="text-sm text-gray-600 dark:text-gray-400">
  18. 与右上角「一键导入」相同操作
  19. </span>
  20. </div>
  21. </x-filament::section>
  22. <x-filament::section heading="命令行(可选)">
  23. <pre class="overflow-x-auto rounded-lg bg-gray-950 p-4 text-xs text-gray-100 dark:bg-gray-900"><code># 本地:从文件导入并生成 SQL
  24. php artisan questions:import /绝对路径/题目.json
  25. # 仅生成 SQL、不写本地库(适合只在服务器执行)
  26. php artisan questions:import /path/to/x.json --sql-only
  27. # 从本地库按 id 导出 SQL(默认不含 id,由服务器自增主键)
  28. php artisan questions:export-sql --ids=101,102,103
  29. # 若必须在目标库对齐原 id:
  30. php artisan questions:export-sql --ids=101,102 --with-id</code></pre>
  31. </x-filament::section>
  32. @if ($this->lastSqlPath)
  33. <x-filament::section heading="本次生成的 SQL 文件">
  34. <p class="break-all font-mono text-sm text-gray-700 dark:text-gray-300">{{ $this->lastSqlPath }}</p>
  35. @if ($this->lastMessage)
  36. <p class="mt-2 whitespace-pre-wrap text-sm text-gray-600 dark:text-gray-400">{{ $this->lastMessage }}</p>
  37. @endif
  38. </x-filament::section>
  39. @endif
  40. </div>
  41. </x-filament::page>