Add live canvas layers, element styles and undo history

This commit is contained in:
2026-11-23 19:36:55 +08:00
parent bd1890c0dd
commit 3e842aa35c
21 changed files with 906 additions and 104 deletions
+9 -1
View File
@@ -11,7 +11,7 @@ use Throwable;
final class Database
{
private const SCHEMA_VERSION = 2;
private const SCHEMA_VERSION = 3;
// Avoid reusing a deleted ID that may still be open in an editing form.
public const NEXT_ARTICLE_ID = 'MAX(COALESCE((SELECT MAX(id) FROM articles), 0),
COALESCE((SELECT MAX(article_id) FROM article_deletions), 0)) + 1';
@@ -54,6 +54,14 @@ final class Database
throw new RuntimeException('当前 SQLite 数据库需要更新版本的 LaySite。');
}
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
if ($version < 3) {
foreach (['pages', 'sections'] as $table) {
$columns = $pdo->query('PRAGMA table_info(' . $table . ')')->fetchAll();
if (!in_array('presentation', array_column($columns, 'name'), true)) {
$pdo->exec("ALTER TABLE $table ADD COLUMN presentation TEXT NOT NULL DEFAULT '{}'");
}
}
}
$pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)')->execute([self::json(['name' => '我的网站'])]);
$pdo->prepare("INSERT OR IGNORE INTO pages
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)