forked from laysense/laysite
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93b58b87b0 | ||
|
|
913bf2f0d8 | ||
|
|
b22521fd90 | ||
|
|
70a94dd394 | ||
|
|
1aaf3908af | ||
|
|
fc4bcea127 |
@@ -48,7 +48,8 @@ php start.php start
|
||||
- 画布支持 Ctrl/⌘+Z 撤销和 Ctrl/⌘+Shift+Z 重做。页面设置的输入框保留浏览器原生撤销。每次成功保存都会开始一段新的画布编辑历史。
|
||||
- 选中按钮后可复制。在「属性」中选择纯色填充、线框、下划线或无样式,并选择是否在新标签页打开。首屏支持最多八个按钮。
|
||||
- 在「网站页面 → 新建页面」选择普通页面、页头、页脚、维护页或 404 页。它们共用同一个画布。页头页脚版式在「组件 → 页头/页脚」,也可添加封面、视频、文章等常规区块,或在页面设置中显示首屏。页脚组件默认附带可编辑的 Powered by LaySite 链接。
|
||||
- 新站点的「基础页头」和「基础页脚」已经设为站点默认,可在「网站页面」用画布编辑。也可将其他页头页脚设为站点默认,取消后会恢复相应的基础版式。普通页面各用一个下拉框选择隐藏、站点默认或指定方案。配色方案在「站点设计」管理,内置配色可直接编辑,「站点设置」可切换站点默认配色。列表和页面内的配色选择都会显示色样。整页模板可保留自带配色,也可改选站点默认或其他配色。
|
||||
- 新站点的「基础页头」和「基础页脚」已经设为站点默认,可在「网站页面」用画布编辑。也可将其他页头页脚设为站点默认,取消后会恢复相应的基础版式。普通页面各用一个下拉框选择隐藏、站点默认或指定方案。
|
||||
- 配色方案在「站点设计」管理,「站点设置」可切换站点默认配色。页面、页头和页脚都可在各自的「页面设置」选择配色。普通页头和页脚默认跟随所在页面,也可以固定使用一套方案。从整页模板新建页面时,会复制模板配色并自动应用。每份副本都可单独编辑。方案列表和选择器显示色样。删除方案后,引用它的页面会恢复各自的默认配色。删除站点默认方案时,站点会恢复系统配色。
|
||||
- 媒体库和媒体选择器只列出用户上传文件。编辑器图标、示例资产、字体、模板缩略图和产品标识随程序发布。
|
||||
- 发布后的站点具备独立标题、描述、canonical、Open Graph、站点地图和 robots.txt。可在「站点设置」配置站点名称和静态资源 CDN。
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ final class DesignLibrary
|
||||
public static function ensureDefaultPalette(PDO $pdo): void
|
||||
{
|
||||
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
|
||||
if (isset($site['palette_id'])) {
|
||||
if (array_key_exists('palette_id', $site)) {
|
||||
return;
|
||||
}
|
||||
$pdo->prepare("INSERT INTO design_presets (kind, name, preset, payload) VALUES ('palette', ?, 'custom', ?)")
|
||||
@@ -69,6 +69,38 @@ final class DesignLibrary
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function paletteUrl(int $id, int $version, bool $region = false): string
|
||||
{
|
||||
return '/palette/' . $id . ($region ? '/region' : '') . '.css?v=' . $version;
|
||||
}
|
||||
|
||||
public static function deletePalette(int $id, int $version): bool
|
||||
{
|
||||
return Database::write(static function (PDO $pdo) use ($id, $version): bool {
|
||||
$query = $pdo->prepare("SELECT version FROM design_presets WHERE id = ? AND kind = 'palette'");
|
||||
$query->execute([$id]);
|
||||
$currentVersion = $query->fetchColumn();
|
||||
$query->closeCursor();
|
||||
if ($currentVersion === false) {
|
||||
return false;
|
||||
}
|
||||
if ((int) $currentVersion !== $version) {
|
||||
throw new RuntimeException('配色方案已更新,请刷新后再删除。');
|
||||
}
|
||||
|
||||
$pdo->prepare('UPDATE pages SET palette_id = NULL, version = version + 1 WHERE palette_id = ?')->execute([$id]);
|
||||
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
|
||||
if (($site['palette_id'] ?? null) === $id) {
|
||||
$site['palette_id'] = null;
|
||||
$site['revisions']['general'] = ($site['revisions']['general'] ?? 0) + 1;
|
||||
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
||||
}
|
||||
$pdo->prepare("DELETE FROM design_presets WHERE id = ? AND kind = 'palette'")->execute([$id]);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public static function find(int $id, string $kind): ?array
|
||||
{
|
||||
if ($id < 1) {
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Content;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class PageTemplates
|
||||
{
|
||||
public static function groups(): array
|
||||
@@ -13,6 +15,23 @@ final class PageTemplates
|
||||
return $groups ??= require dirname(__DIR__, 2) . '/resources/page-templates.php';
|
||||
}
|
||||
|
||||
public static function palette(string $theme): array
|
||||
{
|
||||
static $css;
|
||||
$css ??= file_get_contents(dirname(__DIR__, 2) . '/public/assets/page-themes.css');
|
||||
// The opening rule for each theme is the same palette used in the live template preview.
|
||||
if ($css === false || !preg_match('/^\.theme-' . preg_quote($theme, '/') . '\s*\{([^{}]*)\}/m', $css, $rule)) {
|
||||
throw new RuntimeException('找不到整页模板的配色。');
|
||||
}
|
||||
preg_match_all('/--([a-z-]+):\s*(#[a-f0-9]{6})\s*;/i', $rule[1], $matches);
|
||||
$colors = array_intersect_key(array_combine($matches[1], $matches[2]), DesignLibrary::COLORS);
|
||||
if (count($colors) !== count(DesignLibrary::COLORS)) {
|
||||
throw new RuntimeException('整页模板的配色不完整。');
|
||||
}
|
||||
|
||||
return $colors;
|
||||
}
|
||||
|
||||
public static function find(string $key): ?array
|
||||
{
|
||||
foreach (self::groups() as $theme => $group) {
|
||||
|
||||
@@ -47,6 +47,12 @@ final class Repository
|
||||
public function createPage(string $slug, string $name, array $template = [], string $type = 'page'): void
|
||||
{
|
||||
Database::write(static function (PDO $pdo) use ($slug, $name, $template, $type): void {
|
||||
if (($template['palette_id'] ?? null) === null && ($template['theme'] ?? '') !== '') {
|
||||
$suffix = ' · 模板配色';
|
||||
$paletteName = mb_substr($name, 0, 100 - mb_strlen($suffix)) . $suffix;
|
||||
$template['palette_id'] = DesignLibrary::saveIn($pdo, 'palette', null, $paletteName, 'custom',
|
||||
PageTemplates::palette($template['theme']), 0, false);
|
||||
}
|
||||
$layout = in_array($type, ['header', 'footer'], true) ? LayoutPage::insertPreset($pdo, $type, $name) : null;
|
||||
self::insertPage($pdo, $slug, $name, $template, $layout, $layout === null ? $type : 'page');
|
||||
});
|
||||
|
||||
@@ -175,7 +175,7 @@ final class SiteBackup
|
||||
$site = ['name' => $settings['name'], 'cdn' => ['origin' => Assets::cdn($settings['cdn']['origin'] ?? '')], 'revisions' => ['general' => time()]];
|
||||
$site['head_html'] = PageHead::normalize($settings['head_html'] ?? '');
|
||||
$site['favicon'] = SiteIcon::normalize($settings['favicon'] ?? '');
|
||||
if (isset($settings['palette_id'])) {
|
||||
if (array_key_exists('palette_id', $settings)) {
|
||||
$site['palette_id'] = self::selection($designs, 'palette', $settings['palette_id']);
|
||||
}
|
||||
$layoutDefaults = $settings['layout_defaults'] ?? [];
|
||||
|
||||
@@ -49,8 +49,7 @@ final class SiteDesign
|
||||
throw new RuntimeException('请先发布并选择维护页,再开启维护模式。');
|
||||
}
|
||||
if ($palette !== null) {
|
||||
$site['palette_id'] = DesignLibrary::selection('palette', $palette)
|
||||
?? throw new RuntimeException('请选择站点默认配色。');
|
||||
$site['palette_id'] = DesignLibrary::selection('palette', $palette);
|
||||
}
|
||||
$site['name'] = $name;
|
||||
$site['cdn'] = ['origin' => $origin];
|
||||
|
||||
@@ -44,7 +44,12 @@ final class View
|
||||
$markup = self::fragment('page', [
|
||||
'page' => $repo->withSectionFeeds($region), 'site' => $data['site'], 'canvas' => false,
|
||||
]);
|
||||
$data[$kind . 'Markup'] = Html::sharedFragment($markup, $region['slug'], $account, $data['path'] ?? null);
|
||||
$data[$kind . 'Markup'] = self::fragment('shared-layout', [
|
||||
'kind' => $kind, 'visible' => $page['visibility'][$kind] ?? true,
|
||||
'content' => Html::sharedFragment($markup, $region['slug'], $account, $data['path'] ?? null),
|
||||
'palette' => DesignLibrary::find((int) ($region['palette_id'] ?? 0), 'palette'),
|
||||
'theme' => $region['theme'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,25 @@ final class DesignController extends AdminController
|
||||
|
||||
return $this->render($request, 'admin-design', [
|
||||
'title' => '站点设计', 'items' => DesignLibrary::palettes(), 'defaultPaletteId' => (new Repository())->site()['palette_id'] ?? null,
|
||||
'deleted' => $request->get('deleted') === '1',
|
||||
]);
|
||||
}
|
||||
|
||||
public function deletePalette(Request $request, string $id): Response
|
||||
{
|
||||
if ($failure = $this->guard($request)) {
|
||||
return $failure;
|
||||
}
|
||||
try {
|
||||
$deleted = DesignLibrary::deletePalette((int) $id, $this->version($request));
|
||||
} catch (RuntimeException $error) {
|
||||
return $this->error($request, $this->validationMessage($error), 422);
|
||||
}
|
||||
|
||||
return $deleted ? $this->success($request, '/admin/design?deleted=1#palettes')
|
||||
: $this->error($request, '找不到这项配色方案。', 404);
|
||||
}
|
||||
|
||||
public function edit(Request $request, string $kind, string $key): Response
|
||||
{
|
||||
if ($failure = $this->guard($request)) {
|
||||
@@ -171,7 +187,7 @@ final class DesignController extends AdminController
|
||||
return (new SiteController())->renderPage($repo, $page, true);
|
||||
}
|
||||
|
||||
public function palette(Request $request, string $id): Response
|
||||
public function palette(Request $request, string $id, string $scope = ''): Response
|
||||
{
|
||||
$palette = DesignLibrary::find((int) $id, 'palette');
|
||||
if (!$palette) {
|
||||
@@ -181,11 +197,19 @@ final class DesignController extends AdminController
|
||||
foreach ($palette['payload'] as $variable => $value) {
|
||||
$declarations[] = '--' . $variable . ':' . $value;
|
||||
}
|
||||
$variables = implode(';', $declarations);
|
||||
if ($scope === 'region') {
|
||||
$region = ':is([data-site-area], main)[data-region-palette="' . $palette['id'] . '"]';
|
||||
$css = "$region {" . $variables . ';color:var(--ink);background-color:var(--white)}'
|
||||
. " $region .site-footer {--paper:inherit;--ink:inherit;--muted:inherit;background-color:var(--paper)}";
|
||||
} else {
|
||||
$css = ':root, #main-content.page-theme {' . $variables . '}'
|
||||
. ' #main-content:not(.page-theme) .hero-home {background:var(--paper)}';
|
||||
}
|
||||
|
||||
return new Response(200, [
|
||||
'Content-Type' => 'text/css; charset=utf-8', 'Cache-Control' => 'public, max-age=60',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
], ':root, #main-content.page-theme {' . implode(';', $declarations) . '} .page-theme .hero, .hero-home {background:var(--paper)}'
|
||||
. ' #main-content .button-primary, #main-content .button-primary:hover {color:var(--button-ink);background:var(--accent)}');
|
||||
], $css);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ final class SiteStatus implements MiddlewareInterface
|
||||
// Media and styles must remain available for the maintenance page and the admin canvas.
|
||||
if (in_array($request->method(), ['GET', 'HEAD'], true)
|
||||
&& ($path === SiteIcon::PATH
|
||||
|| preg_match('~^/(?:assets/uploads/[a-f0-9]{32}\.[a-z0-9]+|palette/[0-9]+\.css|canvas-style\.css|favicon\.ico)$~D', $path))) {
|
||||
|| preg_match('~^/(?:assets/uploads/[a-f0-9]{32}\.[a-z0-9]+|palette/[0-9]+(?:/region)?\.css|canvas-style\.css|favicon\.ico)$~D', $path))) {
|
||||
$asset = $handler($request);
|
||||
if ($asset->getStatusCode() !== 404) {
|
||||
return $asset;
|
||||
|
||||
@@ -13,14 +13,31 @@ $e = View::escape(...);
|
||||
<p><a href="/admin">在网站页面中管理页头和页脚</a></p>
|
||||
<section class="admin-panel" id="palettes">
|
||||
<div class="admin-heading compact"><h2>配色方案</h2><a class="button button-outline" href="/admin/design/palette/new"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>新建配色方案</a></div>
|
||||
<?php if (!$items): ?><p class="field-note">暂无自定义配色。</p><?php endif ?>
|
||||
<?php if ($deleted): ?><p class="feedback success" data-save-confirmation role="status">配色方案已删除。</p><?php endif ?>
|
||||
<?php if (!$items): ?><p class="field-note">暂无自定义配色,站点使用系统配色。</p><?php endif ?>
|
||||
<ul class="admin-list">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<li><div class="palette-name"><strong><?= $e($item['name']) ?></strong>
|
||||
<?php if ($item['id'] === $defaultPaletteId): ?><span class="dashboard-page-state">站点默认</span><?php endif ?>
|
||||
<?= View::fragment('palette-swatches', ['colors' => $item['colors']]) ?>
|
||||
</div>
|
||||
<a class="button button-outline" href="/admin/design/palette/<?= $e($item['id']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑</a>
|
||||
<?php
|
||||
$isDefault = $item['id'] === $defaultPaletteId;
|
||||
$deleteMessage = '确定删除「' . $item['name'] . '」?使用该方案的页面将恢复到各自的默认配色。';
|
||||
if ($isDefault) {
|
||||
$deleteMessage .= '站点默认配色将恢复为系统配色。';
|
||||
}
|
||||
?>
|
||||
<li>
|
||||
<div class="palette-name">
|
||||
<strong><?= $e($item['name']) ?></strong>
|
||||
<?php if ($isDefault): ?><span class="dashboard-page-state">站点默认</span><?php endif ?>
|
||||
<?= View::fragment('palette-swatches', ['colors' => $item['colors']]) ?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="/admin/design/palette/<?= $e($item['id']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑</a>
|
||||
<form method="post" action="/admin/design/palette/<?= $e($item['id']) ?>/delete">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
||||
<button class="button button-outline destructive-action" type="submit" data-confirm="<?= $e($deleteMessage) ?>"><?= View::fragment('studio-icon', ['icon' => 'delete']) ?>删除</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
+14
-7
@@ -2,6 +2,7 @@
|
||||
use App\Content\Buttons;
|
||||
use App\Content\CanvasStyle;
|
||||
use App\Content\Database;
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\SystemPage;
|
||||
@@ -15,18 +16,24 @@ $pageTypes = LayoutPage::TYPES + SystemPage::TYPES;
|
||||
$layoutSlugs = array_column($designs, 'slug', 'id');
|
||||
$published = $page['status'] === 'published';
|
||||
$publicPage = !$page['layout_kind'] && in_array($page['page_type'], ['page', 'home'], true);
|
||||
$defaultPalette = empty($page['theme']) ? (array_column($palettes, null, 'id')[$defaultPaletteId] ?? null) : null;
|
||||
$usesSitePalette = empty($page['theme']);
|
||||
$defaultPalette = $usesSitePalette && $defaultPaletteId !== null
|
||||
? (array_column($palettes, null, 'id')[$defaultPaletteId] ?? null) : null;
|
||||
$fallbackName = $layout && $usesSitePalette ? '跟随所在页面'
|
||||
: ($usesSitePalette ? '跟随站点默认 · ' . ($defaultPalette['name'] ?? '系统配色') : '模板原有配色');
|
||||
$paletteOptions = [[
|
||||
'id' => '', 'name' => $defaultPalette ? '跟随站点默认 · ' . $defaultPalette['name'] : '模板原有配色',
|
||||
'colors' => $defaultPalette['colors'] ?? [], 'version' => $defaultPalette['version'] ?? 0, 'cssId' => $defaultPalette['id'] ?? null,
|
||||
'id' => '', 'name' => $fallbackName,
|
||||
'colors' => $layout ? [] : ($defaultPalette['colors'] ?? ($usesSitePalette ? DesignLibrary::defaults('palette') : [])),
|
||||
'version' => $defaultPalette['version'] ?? 0, 'cssId' => $defaultPalette['id'] ?? null,
|
||||
]];
|
||||
foreach ($palettes as $palette) {
|
||||
if ($palette['id'] === $defaultPaletteId) {
|
||||
if ($defaultPalette && $page['palette_id'] !== $defaultPaletteId) {
|
||||
if (!$layout && $defaultPalette && $page['palette_id'] !== $defaultPaletteId) {
|
||||
continue;
|
||||
}
|
||||
$palette['name'] .= $defaultPalette ? '(固定使用)' : '(当前站点默认)';
|
||||
}
|
||||
$palette['region'] = (bool) $layout;
|
||||
$paletteOptions[] = $palette;
|
||||
}
|
||||
$previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
@@ -296,10 +303,10 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<?= View::fragment('admin-palette-picker', [
|
||||
'id' => 'page-palette', 'label' => '配色方案', 'options' => $paletteOptions, 'selected' => $page['palette_id'],
|
||||
]) ?>
|
||||
<?php endif ?>
|
||||
<?= View::fragment('admin-palette-picker', [
|
||||
'id' => 'page-palette', 'label' => '配色方案', 'options' => $paletteOptions, 'selected' => $page['palette_id'],
|
||||
]) ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
<?php if (($layout['kind'] ?? '') === 'header'): ?>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
@@ -8,7 +9,8 @@ $e = View::escape(...);
|
||||
<select id="<?= $e($id) ?>" name="palette_id">
|
||||
<?php foreach ($options as $option): ?>
|
||||
<?php $cssId = $option['cssId'] ?? $option['id']; ?>
|
||||
<option value="<?= $e($option['id']) ?>" data-palette-css="<?= $cssId ? '/palette/' . $e($cssId) . '.css?v=' . $e($option['version']) : '' ?>"<?= (string) $selected === (string) $option['id'] ? ' selected' : '' ?>><?= $e($option['name']) ?></option>
|
||||
<?php $region = $option['region'] ?? false; ?>
|
||||
<option value="<?= $e($option['id']) ?>" data-palette-css="<?= $cssId ? $e(DesignLibrary::paletteUrl($cssId, $option['version'], $region)) : '' ?>"<?= $region ? ' data-palette-region' : '' ?><?= (string) $selected === (string) $option['id'] ? ' selected' : '' ?>><?= $e($option['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<details class="palette-picker" hidden>
|
||||
|
||||
+5
-4
@@ -13,6 +13,7 @@ if (str_starts_with($imageUrl, '/')) {
|
||||
}
|
||||
$theme = $page['theme'] ?? '';
|
||||
$palette = DesignLibrary::find((int) ($page['palette_id'] ?? ($theme === '' ? $site['palette_id'] ?? 0 : 0)), 'palette');
|
||||
$regionPalette = $palette && !empty($page['layout_kind']) && $page['palette_id'] !== null;
|
||||
$showHeader = $page['visibility']['header'] ?? true;
|
||||
$showFooter = $page['visibility']['footer'] ?? true;
|
||||
$canvasStyles = $content . ($headerMarkup ?? '') . ($footerMarkup ?? '');
|
||||
@@ -50,7 +51,7 @@ $favicon = $site['favicon'] ?? '';
|
||||
<?php if (!empty($canvas) || str_contains($canvasStyles, 'studio-style-') || str_contains($canvasStyles, 'studio-media-')): ?><link rel="stylesheet" href="<?= $e(CanvasStyle::stylesheetUrl()) ?>"><?php endif ?>
|
||||
<?php if (!empty($canvas) || $canvasColors !== ''): ?><style nonce="<?= $e($styleNonce) ?>" data-canvas-colors><?= $canvasColors ?></style><?php endif ?>
|
||||
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
|
||||
<?php if ($palette): ?><link rel="stylesheet" data-page-palette href="/palette/<?= $e($palette['id']) ?>.css?v=<?= $e($palette['version']) ?>"><?php endif ?>
|
||||
<?php if ($palette): ?><link rel="stylesheet" data-page-palette href="<?= $e(DesignLibrary::paletteUrl($palette['id'], $palette['version'], $regionPalette)) ?>"><?php endif ?>
|
||||
<script src="<?= $e(Assets::JQUERY) ?>" defer></script>
|
||||
<script src="/assets/site.js" defer></script>
|
||||
<?= $headMarkup ?>
|
||||
@@ -58,12 +59,12 @@ $favicon = $site['favicon'] ?? '';
|
||||
<body>
|
||||
<a class="skip-link" href="#main-content">跳到内容</a>
|
||||
<?php if (empty($page['layout_kind']) && ($showHeader || !empty($canvas))): ?>
|
||||
<?php if (isset($headerMarkup)): ?><div role="banner" data-site-area="header"<?= $showHeader ? '' : ' hidden' ?>><?= $headerMarkup ?></div>
|
||||
<?php if (isset($headerMarkup)): ?><?= $headerMarkup ?>
|
||||
<?php else: ?><?= View::fragment('header', compact('header', 'site', 'showHeader', 'visitor', 'member', 'path')) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
|
||||
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?><?= $regionPalette ? ' data-region-palette="' . $e($palette['id']) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
|
||||
<?php if (empty($page['layout_kind']) && ($showFooter || !empty($canvas))): ?>
|
||||
<?php if (isset($footerMarkup)): ?><div id="contact" role="contentinfo" data-site-area="footer"<?= $showFooter ? '' : ' hidden' ?>><?= $footerMarkup ?></div>
|
||||
<?php if (isset($footerMarkup)): ?><?= $footerMarkup ?>
|
||||
<?php else: ?><?= View::fragment('footer', compact('footer', 'site', 'showFooter')) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$header = $kind === 'header';
|
||||
?>
|
||||
<div role="<?= $header ? 'banner' : 'contentinfo' ?>" data-site-area="<?= $e($kind) ?>"<?= $header ? '' : ' id="contact"' ?><?= $visible ? '' : ' hidden' ?>
|
||||
<?= $theme === '' ? '' : 'class="page-theme theme-' . $e($theme) . '"' ?><?= $palette ? ' data-region-palette="' . $e($palette['id']) . '"' : '' ?>>
|
||||
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
|
||||
<?php if ($palette): ?><link rel="stylesheet" href="<?= $e(DesignLibrary::paletteUrl($palette['id'], $palette['version'], true)) ?>"><?php endif ?>
|
||||
<?= $content ?>
|
||||
</div>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use App\Content\Database;
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\McpSettings;
|
||||
use App\Content\View;
|
||||
|
||||
@@ -15,7 +16,8 @@ $e = View::escape(...);
|
||||
<label>静态资源 CDN<input name="cdn" value="<?= $e($cdn) ?>" placeholder="https://cdn.example.com"><small>填写后,公开页面的 /assets/ 文件从该地址加载。</small></label>
|
||||
<div>
|
||||
<?= View::fragment('admin-palette-picker', [
|
||||
'id' => 'site-palette', 'label' => '站点默认配色', 'options' => $palettes, 'selected' => $paletteId,
|
||||
'id' => 'site-palette', 'label' => '站点默认配色', 'selected' => $paletteId,
|
||||
'options' => [['id' => '', 'name' => '系统配色', 'colors' => DesignLibrary::defaults('palette')], ...$palettes],
|
||||
]) ?>
|
||||
<a class="back-link" href="/admin/design#palettes">管理配色方案</a>
|
||||
</div>
|
||||
|
||||
@@ -56,9 +56,11 @@ Route::add(['GET', 'POST'], '/admin/settings', [DesignController::class, 'site']
|
||||
Route::add(['GET', 'POST'], '/admin/backup', [BackupController::class, 'index']);
|
||||
Route::get('/admin/backup/download', [BackupController::class, 'export']);
|
||||
Route::get('/admin/design', [DesignController::class, 'index']);
|
||||
Route::post('/admin/design/palette/{id:[0-9]+}/delete', [DesignController::class, 'deletePalette']);
|
||||
Route::get('/admin/design/{kind:header|footer|palette}/{id:[0-9]+}/preview', [DesignController::class, 'previewDesign']);
|
||||
Route::add(['GET', 'POST'], '/admin/design/{kind:header|footer|palette}/{key:new|[0-9]+}', [DesignController::class, 'edit']);
|
||||
Route::get('/palette/{id:[0-9]+}.css', [DesignController::class, 'palette']);
|
||||
Route::get('/palette/{id:[0-9]+}/{scope:region}.css', [DesignController::class, 'palette']);
|
||||
Route::add(['GET', 'POST'], '/admin/media', [StudioController::class, 'media']);
|
||||
Route::get('/admin/media/options', [StudioController::class, 'mediaOptions']);
|
||||
Route::post('/admin/media/{name:[a-f0-9]{32}\.[a-z0-9]+}', [StudioController::class, 'mediaMeta']);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
--line: #cbd7e5;
|
||||
--accent: #184ed3;
|
||||
--accent-deep: #153a9b;
|
||||
--accent-light: #e8efff;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-cobalt .hero {
|
||||
background: radial-gradient(ellipse at 77% 28%, #c9dafa 0, transparent 45%),
|
||||
@@ -47,6 +49,7 @@
|
||||
--accent: #9c3818;
|
||||
--accent-deep: #78290f;
|
||||
--accent-light: #ffe7d5;
|
||||
--button-ink: #231911;
|
||||
}
|
||||
.theme-studio .hero {
|
||||
background: radial-gradient(circle, #9d8269 1px, transparent 1px) 0 0 / 24px 24px, var(--paper);
|
||||
@@ -68,8 +71,8 @@
|
||||
}
|
||||
.theme-studio .app-frame img { border-radius: 0; object-fit: cover; }
|
||||
.theme-studio .button { border-radius: .15rem; }
|
||||
.theme-studio .button-primary { color: #231911; background: #f3a578; border-color: #713a24; }
|
||||
.theme-studio .button-primary:hover { background: #f8ba96; }
|
||||
.theme-studio .button-primary { background: color-mix(in srgb, var(--accent) 12%, #ffb485); border-color: var(--accent-deep); }
|
||||
.theme-studio .button-primary:hover { background: color-mix(in srgb, var(--accent) 12%, #ffd0ab); }
|
||||
.theme-studio .button-outline { background: var(--white); border-color: #827261; }
|
||||
.template-portfolio { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.4rem, 5vw, 4rem); }
|
||||
.template-portfolio img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border: 1px solid var(--line); border-radius: 0; background: var(--paper); }
|
||||
@@ -84,8 +87,9 @@
|
||||
--accent: #bdc7ff;
|
||||
--accent-deep: #dbe1ff;
|
||||
--accent-light: #343d5e;
|
||||
--button-ink: #151a30;
|
||||
}
|
||||
.theme-dusk .hero { background: radial-gradient(ellipse at 77% 48%, #454255 0, #222639 46%, #191d2b 78%); }
|
||||
.theme-dusk .hero { background: radial-gradient(ellipse at 77% 48%, #454255 0, var(--paper) 46%, var(--white) 78%); }
|
||||
.theme-dusk .app-frame {
|
||||
border: 1px solid #8b869c;
|
||||
background: #514d6370;
|
||||
@@ -93,7 +97,6 @@
|
||||
box-shadow: 0 21px 65px -20px #090a18ab;
|
||||
}
|
||||
.theme-dusk .app-frame img { object-fit: cover; }
|
||||
.theme-dusk .button-primary, .theme-dusk .button-primary:hover { color: #151a30; }
|
||||
.theme-dusk .button-outline { color: var(--ink); border-color: #8c96b0; }
|
||||
.theme-dusk .button-outline:hover { color: var(--accent-deep); background: var(--paper); }
|
||||
.theme-dusk .crumb-divider { color: var(--muted); }
|
||||
@@ -124,15 +127,15 @@
|
||||
--accent: #bfe971;
|
||||
--accent-deep: #d7ffa0;
|
||||
--accent-light: #2e4233;
|
||||
--button-ink: #172318;
|
||||
}
|
||||
.theme-vantage .hero {
|
||||
background: radial-gradient(ellipse at 82% 35%, #243b39, transparent 65%),
|
||||
radial-gradient(circle, #4b6959 1px, transparent 1.4px) 0 0 / 18px 18px, var(--white);
|
||||
}
|
||||
.theme-vantage .hero-copy { background: #121b20; padding-block: 1rem; }
|
||||
.theme-vantage .hero-copy { background: var(--white); padding-block: 1rem; }
|
||||
.theme-vantage .app-frame { border: 1px solid #618076; border-radius: .2rem; background: #263738; box-shadow: 8px 8px 0 #172e26; }
|
||||
.theme-vantage .app-frame img, .theme-vantage .button { border-radius: .2rem; }
|
||||
.theme-vantage .button-primary, .theme-vantage .button-primary:hover { color: #172318; }
|
||||
.theme-vantage .button-outline { border-color: #7d9b8e; color: var(--ink); }
|
||||
.theme-vantage .button-outline:hover { background: var(--paper); }
|
||||
|
||||
@@ -145,8 +148,9 @@
|
||||
--accent: #633ab1;
|
||||
--accent-deep: #4d268e;
|
||||
--accent-light: #ebdfff;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-ribbon .hero { background: radial-gradient(ellipse at 88% 24%, #d9c5f3, transparent 60%), #f5eff9; }
|
||||
.theme-ribbon .hero { background: radial-gradient(ellipse at 88% 24%, #d9c5f3, transparent 60%), var(--paper); }
|
||||
.theme-ribbon .app-frame { border-color: #b9a1db; border-radius: clamp(1.4rem, 4vw, 3rem); background: #fffafc; box-shadow: 0 22px 65px -31px #68489b83; }
|
||||
.theme-ribbon .app-frame img { border-radius: 1rem; object-fit: cover; }
|
||||
.theme-ribbon .button { border-radius: 2rem; }
|
||||
@@ -162,8 +166,9 @@
|
||||
--accent: #325335;
|
||||
--accent-deep: #233a27;
|
||||
--accent-light: #e3ecd9;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-furrow .hero { background: linear-gradient(115deg, #f7f0dd, #eee2c5); }
|
||||
.theme-furrow .hero { background: linear-gradient(115deg, color-mix(in srgb, var(--paper), var(--white)), var(--paper)); }
|
||||
.theme-furrow .hero-copy { border-inline-start: .3rem solid #b67e28; padding-inline-start: clamp(1rem, 2.6vw, 2.2rem); }
|
||||
.theme-furrow :is(h1, h2) { font-family: 'Noto Serif CJK SC', 'Songti SC', Georgia, serif; }
|
||||
.theme-furrow .app-frame { border: 1px solid #9f946f; border-radius: .3rem; background: #fff8e7; box-shadow: 9px 9px 0 #c6ae7d56; }
|
||||
@@ -183,6 +188,7 @@
|
||||
--accent: #944022;
|
||||
--accent-deep: #692714;
|
||||
--accent-light: #f2dfc5;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-gather .hero {
|
||||
background: radial-gradient(circle at 88% 75%, #f6bd53 0 18%, transparent 18.15%),
|
||||
@@ -199,6 +205,7 @@
|
||||
--accent: #235d48;
|
||||
--accent-deep: #163d2d;
|
||||
--accent-light: #d9eadf;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-market .hero {
|
||||
background: linear-gradient(125deg, var(--paper) 0 59%, #d7e8dd 59% 76%, #c6ded0 76%);
|
||||
@@ -216,6 +223,7 @@
|
||||
--accent: #783849;
|
||||
--accent-deep: #542136;
|
||||
--accent-light: #f1dde4;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-dispatch .hero { background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), #d8cbd0 calc(25% - 1px) 25%), var(--paper); }
|
||||
.theme-dispatch .hero-copy { padding: 1.5rem; background: var(--paper); border-block: 1px solid var(--line); }
|
||||
@@ -236,6 +244,7 @@
|
||||
--accent: #984631;
|
||||
--accent-deep: #72321f;
|
||||
--accent-light: #f3dcd0;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-atrium .hero { background: radial-gradient(ellipse at 78% 28%, #fff9eb, transparent 52%), var(--paper); }
|
||||
.theme-atrium :is(h1, h2, h3) { font-family: 'Noto Serif CJK SC', 'Songti SC', Georgia, serif; font-weight: 580; }
|
||||
@@ -252,6 +261,7 @@
|
||||
--accent: #176471;
|
||||
--accent-deep: #154752;
|
||||
--accent-light: #f4e5b5;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-harbor .hero { background: radial-gradient(ellipse at 87% 90%, #eed88d 0 16%, transparent 16.2%), var(--paper); }
|
||||
.theme-harbor .app-frame { padding: .4rem; border-color: #719891; border-radius: 1.5rem; background: var(--white); }
|
||||
@@ -267,6 +277,7 @@
|
||||
--accent: #554381;
|
||||
--accent-deep: #3d2d60;
|
||||
--accent-light: #e9e1f6;
|
||||
--button-ink: #ffffff;
|
||||
}
|
||||
.theme-index .hero { background: repeating-linear-gradient(0deg, transparent 0 31px, #dfd9ec 31px 32px), var(--paper); }
|
||||
.theme-index .hero-copy { padding: 1rem; border-inline-start: 3px solid var(--accent); background: var(--paper); }
|
||||
|
||||
@@ -297,7 +297,7 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
||||
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
|
||||
.empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; }
|
||||
|
||||
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #e4ecfc; border-top: 1px solid var(--line); }
|
||||
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: var(--accent-light); border-top: 1px solid var(--line); }
|
||||
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem clamp(2rem, 7vw, 7rem); }
|
||||
.footer-company { display: flex; flex-direction: column; align-items: flex-start; }
|
||||
.footer-logo img { width: clamp(8.125rem, 13vw, 10rem); height: auto; }
|
||||
|
||||
@@ -1375,7 +1375,9 @@ jQuery(function ($) {
|
||||
});
|
||||
pageInput('palette_id').on('change.canvas', function () {
|
||||
$doc.find('[data-page-palette]').remove();
|
||||
const href = this.selectedOptions[0]?.dataset.paletteCss;
|
||||
const option = this.selectedOptions[0];
|
||||
const href = option?.dataset.paletteCss;
|
||||
$doc.find('#main-content').attr('data-region-palette', option?.hasAttribute('data-palette-region') ? option.value : null);
|
||||
if (href) {
|
||||
$('<link>', {rel: 'stylesheet', href, 'data-page-palette': ''})
|
||||
.one('load', syncFormatControls).appendTo($doc.find('head'));
|
||||
|
||||
Reference in New Issue
Block a user