forked from laysense/laysense.cn
Migrate Laysense to unmodified LaySite 1.5.2
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
use App\Content\Database;
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\McpSettings;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
@@ -11,6 +14,15 @@ $e = View::escape(...);
|
||||
<input type="hidden" name="version" value="<?= $e($version) ?>">
|
||||
<label>站点名称<input name="name" value="<?= $e($name) ?>" maxlength="100" required></label>
|
||||
<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' => '站点默认配色', 'selected' => $paletteId,
|
||||
'options' => [['id' => '', 'name' => '系统配色', 'colors' => DesignLibrary::defaults('palette')], ...$palettes],
|
||||
]) ?>
|
||||
<a class="back-link" href="/admin/design#palettes">管理配色方案</a>
|
||||
</div>
|
||||
<?= View::fragment('favicon-settings', compact('siteIcon')) ?>
|
||||
<?= View::fragment('head-settings', ['label' => '全站 Head', 'head' => $head]) ?>
|
||||
<fieldset class="settings-stack">
|
||||
<legend>系统页面</legend>
|
||||
<?php foreach (['maintenance' => ['maintenance_page', '维护页', '选择已发布的维护页'], 'not-found' => ['not_found_page', '404 页', '使用系统 404 页']] as $type => [$field, $label, $placeholder]): ?>
|
||||
@@ -29,3 +41,37 @@ $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['migrationRequired'] ? ' disabled' : '' ?>> 开放 MCP</label>
|
||||
<p class="field-note">允许持有密钥的 AI 客户端通过 Streamable HTTP 新建和编辑草稿。</p>
|
||||
<?php if ($mcp['migrationRequired']): ?>
|
||||
<p class="feedback error"><?= $e(Database::MIGRATION_REQUIRED) ?></p>
|
||||
<?php endif ?>
|
||||
<?php if ($mcp['enabled']): ?>
|
||||
<label>连接网址<input type="url" readonly value="<?= $e(View::absolute(McpSettings::PATH)) ?>"></label>
|
||||
<?php if ($mcp['keyError'] !== ''): ?>
|
||||
<p class="feedback error"><?= $e($mcp['keyError']) ?> 请检查数据库旁的 <code>.key</code> 文件及运行账户的权限。</p>
|
||||
<?php elseif ($mcp['token'] === null): ?>
|
||||
<p class="feedback error">当前密钥无法读取。可以生成新密钥并重新连接。</p>
|
||||
<?php else: ?>
|
||||
<details class="settings-stack">
|
||||
<summary>查看连接密钥</summary>
|
||||
<label>Bearer 密钥<input type="text" class="mcp-token" 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"<?= $mcp['migrationRequired'] ? ' disabled' : '' ?>><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存 MCP 设置</button>
|
||||
<?php if ($mcp['enabled'] && $mcp['keyError'] === ''): ?>
|
||||
<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