Launch LaySite visual editor and MCP workspace
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
use App\Content\Buttons;
|
||||
use App\Content\Database;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$slug = $page['slug'];
|
||||
$path = $slug === 'home' ? '/' : '/' . $slug;
|
||||
$previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
?>
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta"><code><?= $e($path) ?></code>
|
||||
<span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span></p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
||||
</div>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
<div class="studio-layout">
|
||||
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
|
||||
<h2 id="studio-library-title">页面编辑</h2>
|
||||
<?= View::fragment('studio-templates', [
|
||||
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
|
||||
'anchorForm' => View::fragment('studio-anchor-form', compact('slug', 'token')),
|
||||
]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
||||
<div class="admin-heading compact">
|
||||
<h2 id="studio-preview-title">页面画布</h2>
|
||||
<div class="preview-selector" aria-label="预览尺寸">
|
||||
<button type="button" class="button button-outline" data-preview-size="desktop" aria-pressed="true">桌面</button>
|
||||
<button type="button" class="button button-outline" data-preview-size="phone" aria-pressed="false">手机</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-toolbar studio-canvas-toolbar" data-canvas-toolbar hidden aria-label="正文工具">
|
||||
<div>
|
||||
<button type="button" data-canvas-command="heading">小标题</button>
|
||||
<button type="button" data-canvas-command="bold">粗体</button>
|
||||
<button type="button" data-canvas-command="list">列表</button>
|
||||
<button type="button" data-canvas-command="link">插入链接</button>
|
||||
<button type="button" data-canvas-command="media">插入媒体</button>
|
||||
</div>
|
||||
<button class="button button-primary" form="studio-page-settings" type="submit">保存页面</button>
|
||||
</div>
|
||||
<div class="studio-frame-window">
|
||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
||||
<div class="studio-element-tools" data-element-tools role="group" aria-label="所选元素" hidden>
|
||||
<div class="studio-element-align" data-element-align role="group" aria-label="对齐">
|
||||
<?php foreach (['left' => '居左', 'center' => '居中', 'right' => '居右'] as $value => $label): ?>
|
||||
<button type="button" data-align="<?= $value ?>" aria-pressed="false" aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', ['icon' => $value]) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php foreach (['module-settings' => ['settings', '模块设置'], 'properties' => ['edit', '属性'], 'copy' => ['copy', '复制'], 'delete' => ['delete', '删除']] as $action => [$icon, $label]): ?>
|
||||
<button type="button" data-element-<?= $action ?> aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', compact('icon')) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<button class="studio-media-handle" type="button" role="slider" aria-label="媒体宽度" aria-valuemin="10" aria-valuemax="100" aria-valuenow="100" data-media-handle hidden></button>
|
||||
<div class="studio-media-sizing" data-media-sizing hidden>
|
||||
<output data-media-size aria-hidden="true"></output>
|
||||
<button class="button button-outline" type="button" data-reset-media>原始尺寸</button>
|
||||
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="field-note studio-canvas-status" data-canvas-status role="status"></p>
|
||||
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
|
||||
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
|
||||
<form class="admin-form" method="dialog">
|
||||
<label data-property-row="label">文案<input name="label"></label>
|
||||
<label data-property-row="note">副标题<input name="note" maxlength="200"></label>
|
||||
<label data-property-row="url">地址<input name="url" maxlength="1000"></label>
|
||||
<label data-property-row="buttonStyle">按钮样式<select name="buttonStyle">
|
||||
<?php foreach (Buttons::STYLES as $style => $label): ?><option value="<?= $e($style) ?>"><?= $e($label) ?></option><?php endforeach ?>
|
||||
</select></label>
|
||||
<label data-property-row="newTab">打开方式<select name="newTab"><option value="0">当前标签页</option><option value="1">新标签页</option></select></label>
|
||||
<label data-property-row="alt">图片替代文本<input name="alt" maxlength="200"></label>
|
||||
<label data-property-row="quicklinks">目录链接<textarea name="quicklinks" rows="5" placeholder="概览 | #overview"></textarea><small>每行填写「文案 | 链接」。</small></label>
|
||||
<label data-property-row="value">当前值<input name="value" inputmode="numeric"></label>
|
||||
<label data-property-row="max">最大值<input name="max" inputmode="numeric"></label>
|
||||
<label data-property-row="poster">视频封面<input name="poster" maxlength="1000"></label>
|
||||
<p class="feedback error" role="alert" data-property-error hidden></p>
|
||||
<div class="actions">
|
||||
<button type="button" class="button button-outline" data-property-pick="url">从媒体库选择</button>
|
||||
<button type="button" class="button button-outline" data-property-pick="poster">选择视频封面</button>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit" class="button button-primary">应用</button>
|
||||
<button type="button" class="button button-outline" data-property-close>取消</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
<dialog class="media-picker canvas-module-settings" data-module-dialog aria-labelledby="module-settings-title">
|
||||
<div class="admin-heading compact"><h2 id="module-settings-title">模块设置</h2></div>
|
||||
<form class="admin-form" method="dialog">
|
||||
<label>模块标题<input name="module_title" maxlength="100" required></label>
|
||||
<label>模块简介<textarea name="module_lead" rows="2" maxlength="500"></textarea></label>
|
||||
<?= View::fragment('studio-feed-fields', ['categories' => $categories, 'feed' => [], 'allowOff' => false]) ?>
|
||||
<p class="feedback error" role="alert" data-module-error hidden></p>
|
||||
<div class="actions">
|
||||
<button class="button button-primary" type="submit">应用</button>
|
||||
<button class="button button-outline" data-module-close type="button">取消</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
</section>
|
||||
</div>
|
||||
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||
<h2>页面设置</h2>
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||
<input type="hidden" name="canvas_sections" value="">
|
||||
<input type="hidden" name="alignments" value="<?= $e(Database::json($page['alignments'])) ?>">
|
||||
<details class="studio-hero-settings">
|
||||
<summary>首屏与目录</summary>
|
||||
<div class="studio-hero-controls">
|
||||
<button class="button button-outline" type="button" disabled data-hero-control="image">首屏图片</button>
|
||||
<button class="button button-outline" type="button" disabled data-hero-control="add-action">添加首屏按钮</button>
|
||||
<button class="button button-outline" type="button" disabled data-hero-control="navigation">本页目录</button>
|
||||
</div>
|
||||
</details>
|
||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
||||
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
|
||||
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||
<fieldset class="admin-options form-grid">
|
||||
<legend>页面显示</legend>
|
||||
<?php foreach (['header' => '页头', 'hero' => '首屏', 'footer' => '页脚'] as $area => $label): ?>
|
||||
<?php $visible = $page['visibility'][$area] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="show_<?= $e($area) ?>">
|
||||
<option value="1" <?= $visible ? 'selected' : '' ?>>显示</option>
|
||||
<option value="0" <?= !$visible ? 'selected' : '' ?>>隐藏</option>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options form-grid"><legend>页头、页脚与配色</legend>
|
||||
<?php foreach (['header' => '页头方案', 'footer' => '页脚方案', 'palette' => '配色方案'] as $kind => $label): ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_id">
|
||||
<option value=""><?= $kind === 'palette' ? '页面原有配色' : '站点默认' ?></option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>" <?= ($page[$kind . '_id'] ?? null) === $item['id'] ? 'selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<a href="/admin/design" target="_blank" rel="noopener noreferrer">管理设计配置</a>
|
||||
</fieldset>
|
||||
<textarea name="hero_actions" hidden><?= $e(Database::json(Buttons::validate($page['actions']))) ?></textarea>
|
||||
<?php
|
||||
$contentFields = [
|
||||
'heading' => $page['heading'], 'accent' => $page['accent'], 'lead' => $page['lead'],
|
||||
'image' => $page['image'], 'alt' => $page['alt'], 'image_scale' => $page['image_scale'],
|
||||
'quicklinks' => SiteDesign::linkText($page['quicklinks']),
|
||||
];
|
||||
?>
|
||||
<?php foreach ($contentFields as $field => $value): ?>
|
||||
<?php if ($field === 'quicklinks'): ?>
|
||||
<textarea name="quicklinks" hidden><?= $e($value) ?></textarea>
|
||||
<?php else: ?>
|
||||
<input type="hidden" name="<?= $e($field) ?>" value="<?= $e($value) ?>">
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php if ($slug !== 'home'): ?>
|
||||
<label>发布状态<select name="status"><option value="draft" <?= $page['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||
<option value="published" <?= $page['status'] === 'published' ? 'selected' : '' ?>>已发布</option></select></label>
|
||||
<?php endif ?>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit">保存页面</button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?= View::fragment('studio-page-templates', compact('token')) ?>
|
||||
Reference in New Issue
Block a user