Fix palette choices, template drawer, and canvas layer labels

This commit is contained in:
2026-11-28 11:59:15 +08:00
parent 5c37952bca
commit f9af7af86c
16 changed files with 141 additions and 81 deletions
+6 -2
View File
@@ -32,9 +32,9 @@ final class SiteDesign
}
public static function saveGeneral(string $name, string $origin, int $version, array $systemPages, bool $maintenance,
?string $head = null, ?string $icon = null): void
?string $head = null, ?string $icon = null, mixed $palette = null): void
{
Database::write(function (PDO $pdo) use ($name, $origin, $version, $systemPages, $maintenance, $head, $icon): void {
Database::write(function (PDO $pdo) use ($name, $origin, $version, $systemPages, $maintenance, $head, $icon, $palette): void {
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
if (($site['revisions']['general'] ?? 0) !== $version) {
throw new RuntimeException('站点设置已更新,请重新打开后再保存。');
@@ -48,6 +48,10 @@ final class SiteDesign
if ($maintenance && !isset($systemPages['maintenance'])) {
throw new RuntimeException('请先发布并选择维护页,再开启维护模式。');
}
if ($palette !== null) {
$site['palette_id'] = DesignLibrary::selection('palette', $palette)
?? throw new RuntimeException('请选择站点默认配色。');
}
$site['name'] = $name;
$site['cdn'] = ['origin' => $origin];
$site['system_pages'] = $systemPages;