forked from laysense/laysite
Refine admin action buttons and add a system about page
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Content\Repository;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\View;
|
||||
use App\Http\Request;
|
||||
use Composer\InstalledVersions;
|
||||
use RuntimeException;
|
||||
use support\Response;
|
||||
|
||||
@@ -126,6 +127,24 @@ class AdminController
|
||||
]);
|
||||
}
|
||||
|
||||
public function about(Request $request): Response
|
||||
{
|
||||
if ($failure = $this->guard($request)) {
|
||||
return $failure;
|
||||
}
|
||||
|
||||
return $this->render($request, 'admin-about', [
|
||||
'title' => '关于系统',
|
||||
'systemInfo' => [
|
||||
'PHP' => PHP_VERSION,
|
||||
'Webman' => InstalledVersions::getPrettyVersion('workerman/webman-framework'),
|
||||
'Workerman' => InstalledVersions::getPrettyVersion('workerman/workerman'),
|
||||
'SQLite' => (string) Database::connect()->query('SELECT sqlite_version()')->fetchColumn(),
|
||||
'运行平台' => PHP_OS_FAMILY,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function articles(Request $request): Response
|
||||
{
|
||||
if ($failure = $this->guard($request)) {
|
||||
@@ -704,7 +723,10 @@ class AdminController
|
||||
], $status);
|
||||
}
|
||||
|
||||
return View::render($view, $data + ['token' => $token, 'user' => $this->user, 'adminPath' => $request->path()], $status, true);
|
||||
return View::render($view, $data + [
|
||||
'token' => $token, 'user' => $this->user, 'adminPath' => $request->path(),
|
||||
'laysiteVersion' => trim(file_get_contents(dirname(__DIR__, 2) . '/VERSION')),
|
||||
], $status, true);
|
||||
}
|
||||
|
||||
protected function error(Request $request, string $message, int $status): Response
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<header class="admin-heading"><h1><?= $e($title) ?></h1></header>
|
||||
<section class="admin-panel admin-system-info" aria-labelledby="system-info-title">
|
||||
<h2 id="system-info-title">版本与运行环境</h2>
|
||||
<dl>
|
||||
<?php foreach (['LaySite' => $laysiteVersion] + $systemInfo as $name => $value): ?>
|
||||
<div><dt><?= $e($name) ?></dt><dd><?= $e($value) ?></dd></div>
|
||||
<?php endforeach ?>
|
||||
</dl>
|
||||
</section>
|
||||
@@ -10,7 +10,7 @@ $e = View::escape(...);
|
||||
<div><strong><?= $e($item['title']) ?></strong>
|
||||
<small><?= $e(implode('、', $item['categories'])) ?> · <?= $item['status'] === 'published' ? '已发布' : '草稿' ?> · <?= $e(View::date($item['updated_at'])) ?></small>
|
||||
</div>
|
||||
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>">编辑文章</a>
|
||||
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑文章</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
@@ -8,7 +8,7 @@ $e = View::escape(...);
|
||||
<header class="admin-heading">
|
||||
<h1><?= $e($title) ?></h1>
|
||||
<?php if ($articleId && $article['status'] === 'published' && $article['slug'] !== ''): ?>
|
||||
<a class="button button-outline" href="/articles/<?= $e($article['slug']) ?>">查看公开页面</a>
|
||||
<?= View::fragment('admin-view-link', ['href' => '/articles/' . $article['slug'], 'icon' => 'external']) ?>
|
||||
<?php endif ?>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
@@ -23,7 +23,7 @@ $e = View::escape(...);
|
||||
<div class="article-editor" data-article-editor>
|
||||
<div class="article-editor-heading">
|
||||
<label for="article-source" data-article-editor-label>正文</label>
|
||||
<button type="button" class="button button-outline" data-insert-article-image hidden>从媒体库插入图片</button>
|
||||
<button type="button" class="button button-outline" data-insert-article-image hidden><?= View::fragment('studio-icon', ['icon' => 'media']) ?>从媒体库插入图片</button>
|
||||
</div>
|
||||
<input type="hidden" name="body_format" value="<?= $e($article['body_format']) ?>">
|
||||
<textarea id="article-source" name="body" rows="16" aria-label="文章正文"><?= $e($article['body']) ?></textarea>
|
||||
@@ -48,7 +48,7 @@ $e = View::escape(...);
|
||||
<option value="draft" <?= $article['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||
<option value="published" <?= $article['status'] === 'published' ? 'selected' : '' ?>>已发布</option>
|
||||
</select></label>
|
||||
<button class="button button-primary" type="submit">保存文章</button>
|
||||
<button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存文章</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php if ($articleId !== null): ?>
|
||||
@@ -58,7 +58,7 @@ $e = View::escape(...);
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
||||
<p class="field-note">删除后,文章及其目录卡片会从网站移除,且无法恢复。</p>
|
||||
<button class="button button-danger" type="submit">永久删除</button>
|
||||
<button class="button button-danger" type="submit"><?= View::fragment('studio-icon', ['icon' => 'delete']) ?>永久删除</button>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -8,8 +8,8 @@ $filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
|
||||
<header class="admin-heading">
|
||||
<h1>文章与动态</h1>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="/admin/article-categories">管理分类</a>
|
||||
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
|
||||
<a class="button button-outline" href="/admin/article-categories"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>管理分类</a>
|
||||
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>新建文章</a>
|
||||
</div>
|
||||
</header>
|
||||
<?php if ($deleted): ?><p class="feedback success" role="status">文章已删除。</p><?php endif ?>
|
||||
|
||||
@@ -17,9 +17,9 @@ foreach (['header', 'footer'] as $kind) {
|
||||
<header class="admin-heading dashboard-heading">
|
||||
<h1>网站后台</h1>
|
||||
<div class="actions">
|
||||
<a class="button button-primary" href="/admin/new-page">新建页面</a>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<a class="button button-outline" href="/admin/articles/new">写文章</a>
|
||||
<a class="button button-primary" href="/admin/new-page"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>新建页面</a>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden><?= View::fragment('studio-icon', ['icon' => 'templates']) ?>整页模板</button>
|
||||
<a class="button button-outline" href="/admin/articles/new"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>写文章</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="dashboard-grid">
|
||||
@@ -58,8 +58,12 @@ foreach (['header', 'footer'] as $kind) {
|
||||
</div>
|
||||
<span class="dashboard-page-state" data-published="<?= !$page['layout_kind'] && $published ? 'true' : 'false' ?>"><?= $kind ? $e($label) : ($published ? '已发布' : '草稿') ?><?= isset(SystemPage::TYPES[$type]) ? ($published ? ' · 已发布' : ' · 草稿') : '' ?></span>
|
||||
<div class="dashboard-page-actions">
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
||||
<a href="<?= $e($public ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $public ? '查看' : '预览' ?></a>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑页面</a>
|
||||
<?= View::fragment('admin-view-link', [
|
||||
'href' => $public ? $path : '/admin/pages/' . $page['slug'] . '/preview',
|
||||
'icon' => $public ? 'external' : 'preview',
|
||||
'label' => ($public ? '查看公开页面' : '预览页面') . ' · ' . $page['name'],
|
||||
]) ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
@@ -74,8 +78,8 @@ foreach (['header', 'footer'] as $kind) {
|
||||
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
|
||||
<h2 id="quick-title">站点编辑</h2>
|
||||
<ul class="dashboard-setting-buttons">
|
||||
<li><a class="button button-outline" href="/admin/settings">站点设置</a></li>
|
||||
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
|
||||
<li><a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a></li>
|
||||
<li><a class="button button-outline" href="/admin/media"><?= View::fragment('studio-icon', ['icon' => 'media']) ?>打开媒体库</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,9 @@ $fieldError = static function (string $name) use ($errorId, $field, $error, $e):
|
||||
<a class="back-link" href="/admin/design">返回站点设计</a>
|
||||
<header class="admin-heading">
|
||||
<h1>配色方案</h1>
|
||||
<?php if ($key !== 'new'): ?><a class="button button-outline" href="/admin/design/palette/<?= $e($key) ?>/preview" target="_blank" rel="noopener noreferrer">预览已保存的配置</a><?php endif ?>
|
||||
<?php if ($key !== 'new'): ?>
|
||||
<?= View::fragment('admin-view-link', ['href' => '/admin/design/palette/' . $key . '/preview', 'icon' => 'preview', 'label' => '预览已保存的配置']) ?>
|
||||
<?php endif ?>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', ['error' => $field === '' ? $error : '', 'saved' => $saved]) ?>
|
||||
<form class="admin-form admin-panel" method="post" action="/admin/design/palette/<?= $e($key) ?>">
|
||||
@@ -29,5 +31,5 @@ $fieldError = static function (string $name) use ($errorId, $field, $error, $e):
|
||||
<label><?= $e($label) ?><input type="<?= $field === $color ? 'text' : 'color' ?>" name="<?= $e($color) ?>" value="<?= $e($data[$color] ?? $fallback) ?>"<?= $describe($color) ?>><?php $fieldError($color); ?></label>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">保存配置</button></div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存配置</button></div>
|
||||
</form>
|
||||
|
||||
@@ -3,15 +3,21 @@ use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<header class="admin-heading"><h1>站点设计</h1><div class="actions"><a class="button button-outline" href="/admin/settings">站点设置</a><a class="button button-outline" href="/admin/backup">站点备份</a></div></header>
|
||||
<header class="admin-heading">
|
||||
<h1>站点设计</h1>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a>
|
||||
<a class="button button-outline" href="/admin/backup"><?= View::fragment('studio-icon', ['icon' => 'archive']) ?>站点备份</a>
|
||||
</div>
|
||||
</header>
|
||||
<p><a href="/admin">在网站页面中管理页头和页脚</a></p>
|
||||
<section class="admin-panel">
|
||||
<div class="admin-heading compact"><h2>配色方案</h2><a class="button button-outline" href="/admin/design/palette/new">新建配色方案</a></div>
|
||||
<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 ?>
|
||||
<ul class="admin-list">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<li><strong><?= $e($item['name']) ?></strong>
|
||||
<a class="button button-outline" href="/admin/design/palette/<?= $e($item['id']) ?>">编辑</a>
|
||||
<a class="button button-outline" href="/admin/design/palette/<?= $e($item['id']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
@@ -7,7 +7,7 @@ $active = match (true) {
|
||||
str_starts_with($adminPath, '/admin/article') => 'articles',
|
||||
str_starts_with($adminPath, '/admin/media') => 'media',
|
||||
str_starts_with($adminPath, '/admin/settings') || str_starts_with($adminPath, '/admin/design') || str_starts_with($adminPath, '/admin/backup') => 'settings',
|
||||
$adminPath === '/admin/password' => '',
|
||||
in_array($adminPath, ['/admin/password', '/admin/about'], true) => '',
|
||||
default => 'pages',
|
||||
};
|
||||
?>
|
||||
@@ -48,25 +48,27 @@ $active = match (true) {
|
||||
<a href="/admin/design"<?= $active === 'settings' ? ' aria-current="page"' : '' ?>>站点设计</a>
|
||||
</nav>
|
||||
<div class="admin-utility">
|
||||
<a href="/">访问网站</a>
|
||||
<?= View::fragment('admin-view-link', ['href' => '/', 'icon' => 'globe']) ?>
|
||||
<details class="admin-account">
|
||||
<summary>账户</summary>
|
||||
<summary><?= View::fragment('studio-icon', ['icon' => 'account']) ?>账户<?= View::fragment('studio-icon', ['icon' => 'chevron']) ?></summary>
|
||||
<div class="admin-account-menu">
|
||||
<a href="/admin/password">修改密码</a>
|
||||
<a href="/admin/password"<?= $adminPath === '/admin/password' ? ' aria-current="page"' : '' ?>><?= View::fragment('studio-icon', ['icon' => 'key']) ?>修改密码</a>
|
||||
<form method="post" action="/admin/logout">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<button type="submit">退出登录</button>
|
||||
<button type="submit"><?= View::fragment('studio-icon', ['icon' => 'logout']) ?>退出登录</button>
|
||||
</form>
|
||||
<hr class="admin-account-divider">
|
||||
<a href="/admin/about"<?= $adminPath === '/admin/about' ? ' aria-current="page"' : '' ?>><?= View::fragment('studio-icon', ['icon' => 'info']) ?>关于系统</a>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a class="back-link" href="/">返回网站</a>
|
||||
<?= View::fragment('admin-view-link', ['href' => '/', 'icon' => 'globe', 'label' => '返回网站']) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</header>
|
||||
<main class="admin-wrap admin-main<?= !empty($wideAdmin) ? ' admin-wide' : '' ?>" id="admin-content"><?= $content ?></main>
|
||||
<footer class="admin-wrap admin-version">LaySite ver <?= $e(trim(file_get_contents(dirname(__DIR__, 2) . '/VERSION'))) ?></footer>
|
||||
<footer class="admin-wrap admin-version">LaySite ver <?= $e($laysiteVersion) ?></footer>
|
||||
<?php if ($user): ?>
|
||||
<dialog class="media-picker" id="media-picker" aria-labelledby="picker-heading">
|
||||
<header class="admin-heading compact"><h2 id="picker-heading">从媒体库选择</h2><button class="button button-outline" type="button" data-close-picker>关闭</button></header>
|
||||
|
||||
+10
-10
@@ -20,18 +20,18 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<?php else: ?><?php if ($systemLabel): ?><span><?= $e($systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
</p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
|
||||
<a class="button button-outline" href="#studio-page-settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>页面设置</a>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?>
|
||||
<?php $defaultId = $layoutDefaults[$kind . '_id'] ?? ''; $id = $page[$kind . '_id'] ?? $defaultId; ?>
|
||||
<a class="button button-outline" data-page-layout-editor="<?= $e($kind) ?>" data-default-id="<?= $e($defaultId) ?>"
|
||||
href="<?= $id ? '/admin/pages/' . $e(LayoutPage::slug($kind, $id)) : '/admin/new-page?type=' . $e($kind) ?>" target="_blank" rel="noopener"<?= !($page['visibility'][$kind] ?? true) ? ' hidden' : '' ?>><?= $e($label) ?></a>
|
||||
href="<?= $id ? '/admin/pages/' . $e(LayoutPage::slug($kind, $id)) : '/admin/new-page?type=' . $e($kind) ?>" target="_blank" rel="noopener"<?= !($page['visibility'][$kind] ?? true) ? ' hidden' : '' ?>><?= View::fragment('studio-icon', ['icon' => $kind]) ?><?= $e($label) ?></a>
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($systemLabel): ?><a class="button button-outline" href="/admin/settings">站点设置</a>
|
||||
<?php elseif ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden><?= View::fragment('studio-icon', ['icon' => 'templates']) ?>整页模板</button>
|
||||
<?php if ($systemLabel): ?><a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a>
|
||||
<?php elseif ($page['status'] === 'published'): ?><?= View::fragment('admin-view-link', ['href' => $path, 'icon' => 'external']) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
||||
<?= View::fragment('admin-view-link', ['href' => $previewUrl, 'icon' => 'preview', 'label' => '预览页面']) ?>
|
||||
</div>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
@@ -48,8 +48,8 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<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>
|
||||
<button type="button" class="button button-outline" data-preview-size="desktop" aria-pressed="true"><?= View::fragment('studio-icon', ['icon' => 'desktop']) ?>桌面</button>
|
||||
<button type="button" class="button button-outline" data-preview-size="phone" aria-pressed="false"><?= View::fragment('studio-icon', ['icon' => 'phone']) ?>手机</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-toolbar studio-canvas-toolbar" data-canvas-toolbar hidden aria-label="正文工具">
|
||||
@@ -70,7 +70,7 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<button type="button" data-canvas-history="undo" title="撤销(Ctrl/⌘ Z)" disabled>撤销</button>
|
||||
<button type="button" data-canvas-history="redo" title="重做(Ctrl/⌘ Shift Z)" disabled>重做</button>
|
||||
</div>
|
||||
<button class="button button-primary" form="studio-page-settings" type="submit">保存页面</button>
|
||||
<button class="button button-primary" form="studio-page-settings" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button>
|
||||
</div>
|
||||
<div class="studio-frame-window">
|
||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
||||
@@ -228,7 +228,7 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
<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>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?php if (!$layout): ?><?= View::fragment('studio-page-templates', compact('token')) ?><?php endif ?>
|
||||
|
||||
@@ -9,7 +9,7 @@ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||
<a class="back-link" href="/admin/pages/<?= $e($slug) ?>">返回页面编辑</a>
|
||||
<header class="admin-heading">
|
||||
<div><h1><?= $e($title) ?></h1><p><?= $e($slug) ?> · #<?= $e($key) ?></p></div>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($slug) ?>/preview#<?= $e($key) ?>" target="_blank" rel="noopener">预览区块</a>
|
||||
<?= View::fragment('admin-view-link', ['href' => '/admin/pages/' . $slug . '/preview#' . $key, 'icon' => 'preview', 'label' => '预览区块']) ?>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
<form class="admin-form admin-panel" method="post" action="/admin/pages/<?= $e($slug) ?>/<?= $e($key) ?>">
|
||||
@@ -29,5 +29,5 @@ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||
</details>
|
||||
<?php endif ?>
|
||||
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存区块</button></div>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$label ??= match ($icon) {
|
||||
'external' => '查看公开页面',
|
||||
'preview' => '打开预览',
|
||||
'globe' => '访问网站',
|
||||
};
|
||||
$hint = $e($label . '(在新标签页打开)');
|
||||
?>
|
||||
<a class="button button-outline admin-view-link admin-view-link-<?= $e($icon) ?>" href="<?= $e($href) ?>" target="_blank" rel="noopener" aria-label="<?= $hint ?>" title="<?= $hint ?>"><?= View::fragment('studio-icon', compact('icon')) ?></a>
|
||||
@@ -9,6 +9,23 @@ $paths = [
|
||||
'edit' => '<path d="m14 5 5 5M5 19l4-.8L20 7.3 16.7 4 5.8 15z"/>',
|
||||
'copy' => '<rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 4H6a2 2 0 0 0-2 2v10"/>',
|
||||
'delete' => '<path d="M4 7h16M9 7V4h6v3m3 0-.8 13H6.8L6 7m4 4v5m4-5v5"/>',
|
||||
'external' => '<path d="M13 5h6v6m0-6-8 8m6 0v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5"/>',
|
||||
'preview' => '<path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z"/><circle cx="12" cy="12" r="2.5"/>',
|
||||
'globe' => '<circle cx="12" cy="12" r="9"/><ellipse cx="12" cy="12" rx="4" ry="9"/><path d="M3 12h18"/>',
|
||||
'account' => '<circle cx="12" cy="8" r="3.2"/><path d="M5 20v-2a7 7 0 0 1 14 0v2"/>',
|
||||
'chevron' => '<path d="m6 9 6 6 6-6"/>',
|
||||
'key' => '<circle cx="8" cy="9" r="4"/><path d="m11 12 8 8m-4-4 2-2m0 4 2-2"/>',
|
||||
'logout' => '<path d="M11 5H5v14h6m-2-7h12m-4-4 4 4-4 4"/>',
|
||||
'info' => '<circle cx="12" cy="12" r="9"/><path d="M12 11v5m0-8h.01"/>',
|
||||
'add' => '<path d="M12 5v14M5 12h14"/>',
|
||||
'templates' => '<rect x="3.5" y="4.5" width="17" height="15" rx="2"/><path d="M3.5 9.5h17m-11 0v10"/>',
|
||||
'header' => '<rect x="3.5" y="4.5" width="17" height="15" rx="2"/><path d="M3.5 9.5h17"/>',
|
||||
'footer' => '<rect x="3.5" y="4.5" width="17" height="15" rx="2"/><path d="M3.5 14.5h17"/>',
|
||||
'media' => '<rect x="3.5" y="4.5" width="17" height="15" rx="2"/><circle cx="9" cy="9.5" r="1.4"/><path d="m4 17 4-3 3 2 4-5 5 5"/>',
|
||||
'save' => '<path d="M5 4h12l3 3v13H4V4h1Zm3 0v6h8V4m-8 16v-6h8v6"/>',
|
||||
'desktop' => '<rect x="3" y="4.5" width="18" height="12" rx="2"/><path d="M12 16.5v4m-4 0h8"/>',
|
||||
'phone' => '<rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 17.5h2"/>',
|
||||
'archive' => '<rect x="4" y="4" width="16" height="4" rx="1"/><path d="M5 8v12h14V8m-9 4h4"/>',
|
||||
];
|
||||
?>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><?= $paths[$icon] ?></svg>
|
||||
|
||||
@@ -32,7 +32,10 @@ $e = View::escape(...);
|
||||
<?php endif ?>
|
||||
<h3><?= $e($file['label']) ?></h3>
|
||||
<small><?= $e((string) max(1, ceil($file['size'] / 1024))) ?> KB · <?= $file['name'] === '' ? '项目文件' : ($file['archived'] ? '已归档' : '上传文件') ?></small>
|
||||
<div class="actions"><a href="<?= $e($file['url']) ?>" target="_blank" rel="noopener">打开</a><button type="button" class="button button-outline" data-copy-asset="<?= $e($file['url']) ?>">复制路径</button></div>
|
||||
<div class="actions">
|
||||
<?= View::fragment('admin-view-link', ['href' => $file['url'], 'icon' => 'external', 'label' => '打开媒体文件']) ?>
|
||||
<button type="button" class="button button-outline" data-copy-asset="<?= $e($file['url']) ?>">复制路径</button>
|
||||
</div>
|
||||
<?php if ($file['name'] !== ''): ?>
|
||||
<details><summary>管理文件</summary>
|
||||
<form class="admin-form" method="post" action="/admin/media/<?= $e($file['name']) ?>">
|
||||
|
||||
@@ -6,7 +6,7 @@ $e = View::escape(...);
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
<h1>新建页面</h1>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden><?= View::fragment('studio-icon', ['icon' => 'templates']) ?>整页模板</button>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', ['error' => $error, 'saved' => false]) ?>
|
||||
<form class="admin-form admin-panel" method="post" action="/admin/new-page">
|
||||
@@ -20,6 +20,6 @@ $e = View::escape(...);
|
||||
<label data-new-page-slug<?= $type !== 'page' ? ' hidden' : '' ?>>网址标识<input name="slug" maxlength="70" value="<?= $e($slug) ?>" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="my-page"<?= $type === 'page' ? ' required' : ' disabled' ?>>
|
||||
<small>创建后为草稿。可在编辑画布中预览,并自行发布。</small>
|
||||
</label>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">创建页面</button></div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>创建页面</button></div>
|
||||
</form>
|
||||
<?= View::fragment('studio-page-templates', compact('token', 'openTemplates')) ?>
|
||||
|
||||
@@ -43,7 +43,8 @@ $previewRoot = '/assets/page-templates/';
|
||||
<div class="page-template-detail">
|
||||
<div>
|
||||
<div class="page-template-image"><img data-template-preview width="768" height="480" alt=""></div>
|
||||
<a class="button button-outline page-template-preview-link" data-template-live target="_blank" rel="noopener">打开完整页面预览</a>
|
||||
<a class="button button-outline admin-view-link admin-view-link-preview page-template-preview-link" data-template-live target="_blank" rel="noopener"
|
||||
aria-label="预览整页模板(在新标签页打开)" title="预览整页模板(在新标签页打开)"><?= View::fragment('studio-icon', ['icon' => 'preview']) ?></a>
|
||||
</div>
|
||||
<form class="admin-form" method="post" action="/admin/new-page">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
@@ -52,7 +53,7 @@ $previewRoot = '/assets/page-templates/';
|
||||
<label>页面名称<input name="name" maxlength="100" required></label>
|
||||
<label>网址标识<input name="slug" maxlength="70" pattern="[a-z0-9]+(-[a-z0-9]+)*" required></label>
|
||||
</div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">用此模板创建草稿</button></div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>用此模板创建草稿</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -27,5 +27,5 @@ $e = View::escape(...);
|
||||
<label><input type="checkbox" name="maintenance_enabled" value="1"<?= $maintenance ? ' checked' : '' ?>> 开启维护模式</label>
|
||||
<p class="field-note">开启后,访客会看到维护页。后台仍可登录和编辑。</p>
|
||||
</fieldset>
|
||||
<button type="submit" class="button button-primary">保存设置</button>
|
||||
<button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存设置</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user