Prepare LaySite 1.4.4 editor templates and MCP settings
This commit is contained in:
+25
-14
@@ -12,6 +12,8 @@ $slug = $page['slug'];
|
||||
$path = $slug === 'home' ? '/' : '/' . $slug;
|
||||
$previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
$systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
$fontSizes = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144];
|
||||
$spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
?>
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
@@ -63,7 +65,16 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<button type="button" data-canvas-command="media">插入媒体</button>
|
||||
</div>
|
||||
<div class="canvas-format-tools" role="group" aria-label="文字格式">
|
||||
<label>字号 <input type="number" data-canvas-font-size min="8" max="144" step="1" placeholder="px" disabled></label>
|
||||
<div class="canvas-font-picker">
|
||||
<label for="canvas-font-size">字号</label>
|
||||
<div class="canvas-font-combo">
|
||||
<input id="canvas-font-size" type="number" data-canvas-font-size min="8" max="144" step="1" placeholder="px" disabled>
|
||||
<select data-font-preset aria-label="常用字号(px)" title="常用字号" disabled>
|
||||
<option value="" hidden>▾</option>
|
||||
<?php foreach ($fontSizes as $size): ?><option value="<?= $size ?>"><?= $size ?> px</option><?php endforeach ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<label>文字颜色 <input type="color" aria-label="文字颜色" data-canvas-color disabled></label>
|
||||
<button type="button" data-clear-color title="恢复默认文字颜色" aria-label="恢复默认文字颜色" disabled><?= View::fragment('studio-icon', ['icon' => 'refresh']) ?></button>
|
||||
<button type="button" data-canvas-format="weight" aria-label="加粗" title="加粗" aria-pressed="false" disabled><strong>B</strong></button>
|
||||
@@ -120,23 +131,23 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<div class="admin-heading compact"><h2 id="canvas-spacing-title">元素间距</h2></div>
|
||||
<form class="admin-form" method="dialog">
|
||||
<?php foreach (['p' => ['内边距', 0], 'm' => ['外边距', -128]] as $prefix => [$label, $min]): ?>
|
||||
<fieldset class="admin-options canvas-spacing-fields"><legend><?= $label ?>(px)</legend>
|
||||
<label class="canvas-spacing-preset">四边预设
|
||||
<select data-spacing-preset>
|
||||
<option value="">自定义</option>
|
||||
<option value="template">恢复默认</option>
|
||||
<option value="0">无间距 · 0 px</option>
|
||||
<option value="8">紧凑 · 8 px</option>
|
||||
<option value="16">常规 · 16 px</option>
|
||||
<option value="24">宽松 · 24 px</option>
|
||||
<option value="32">大间距 · 32 px</option>
|
||||
</select>
|
||||
</label>
|
||||
<fieldset class="admin-options canvas-spacing-fields"><legend id="spacing-<?= $prefix ?>-legend"><?= $label ?>(px)</legend>
|
||||
<div class="canvas-spacing-preset">
|
||||
<label id="spacing-preset-<?= $prefix ?>-label" for="spacing-preset-<?= $prefix ?>">四边预设</label>
|
||||
<input id="spacing-preset-<?= $prefix ?>" type="range" min="0" max="<?= count($spacingPresets) - 1 ?>" step="1"
|
||||
value="<?= array_search(16, $spacingPresets, true) ?>" data-spacing-preset="<?= $e(Database::json($spacingPresets)) ?>"
|
||||
list="spacing-preset-ticks" aria-labelledby="spacing-<?= $prefix ?>-legend spacing-preset-<?= $prefix ?>-label">
|
||||
<output for="spacing-preset-<?= $prefix ?>" data-spacing-readout aria-live="off">默认</output>
|
||||
<button class="button button-outline" type="button" data-spacing-reset>恢复默认</button>
|
||||
</div>
|
||||
<?php foreach (['t' => '上', 'r' => '右', 'b' => '下', 'l' => '左'] as $side => $direction): ?>
|
||||
<label><?= $direction ?><input name="<?= $prefix . $side ?>" type="number" min="<?= $min ?>" max="128" step="1" placeholder="默认"></label>
|
||||
<label><?= $direction ?><input data-spacing-side name="<?= $prefix . $side ?>" type="number" min="<?= $min ?>" max="128" step="1" placeholder="默认"></label>
|
||||
<?php endforeach ?>
|
||||
</fieldset>
|
||||
<?php endforeach ?>
|
||||
<datalist id="spacing-preset-ticks">
|
||||
<?php foreach (array_keys($spacingPresets) as $index): ?><option value="<?= $index ?>"></option><?php endforeach ?>
|
||||
</datalist>
|
||||
<div class="actions">
|
||||
<button type="submit" class="button button-primary">应用</button>
|
||||
<button type="button" class="button button-outline" data-spacing-close>取消</button>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use App\Content\McpSettings;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
@@ -29,3 +30,32 @@ $e = View::escape(...);
|
||||
</fieldset>
|
||||
<button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存设置</button>
|
||||
</form>
|
||||
<form id="mcp-settings" class="admin-form admin-panel" method="post" action="/admin/settings" aria-labelledby="mcp-settings-title">
|
||||
<header class="admin-heading compact"><h2 id="mcp-settings-title">MCP</h2></header>
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="settings_section" value="mcp">
|
||||
<input type="hidden" name="version" value="<?= $e($mcp['version']) ?>">
|
||||
<label><input type="checkbox" name="mcp_enabled" value="1"<?= $mcp['enabled'] ? ' checked' : '' ?>> 开放 MCP</label>
|
||||
<p class="field-note">允许持有密钥的 AI 客户端通过 Streamable HTTP 新建和编辑草稿。</p>
|
||||
<?php if ($mcp['enabled']): ?>
|
||||
<label>连接网址<input type="url" readonly value="<?= $e(View::absolute(McpSettings::PATH)) ?>"></label>
|
||||
<?php if ($mcp['token'] === null): ?>
|
||||
<p class="feedback error">当前密钥无法读取。生成新密钥后即可重新连接。</p>
|
||||
<?php else: ?>
|
||||
<details class="settings-stack">
|
||||
<summary>查看连接密钥</summary>
|
||||
<label>Bearer 密钥<input type="text" readonly spellcheck="false" autocomplete="off" value="<?= $e($mcp['token']) ?>"></label>
|
||||
<p class="field-note">在客户端设置 Authorization 请求头,格式为 Bearer 后加一个空格和密钥。</p>
|
||||
</details>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php if ($mcp['legacy']): ?>
|
||||
<p class="field-note">当前密钥来自环境变量 LAYSITE_MCP_TOKEN。保存后由后台管理。</p>
|
||||
<?php endif ?>
|
||||
<div class="actions">
|
||||
<button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存 MCP 设置</button>
|
||||
<?php if ($mcp['enabled']): ?>
|
||||
<button type="submit" class="button button-outline" name="rotate_mcp_token" value="1" data-confirm="生成新密钥后,原有的 MCP 连接需要更换密钥。继续吗?"><?= View::fragment('studio-icon', ['icon' => 'refresh']) ?>生成新密钥</button>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user