From 2e1e43a3ce94a2eb225a5ae09a90b2dffa60a04b Mon Sep 17 00:00:00 2001 From: ChatGPT Date: Wed, 25 Nov 2026 17:43:57 +0800 Subject: [PATCH] Refine admin action buttons and add a system about page --- app/Controller/AdminController.php | 24 +++++++++++++++++++++++- app/view/admin-about.php | 14 ++++++++++++++ app/view/admin-article-list.php | 2 +- app/view/admin-article.php | 8 ++++---- app/view/admin-articles.php | 4 ++-- app/view/admin-dashboard.php | 18 +++++++++++------- app/view/admin-design-edit.php | 6 ++++-- app/view/admin-design.php | 12 +++++++++--- app/view/admin-layout.php | 16 +++++++++------- app/view/admin-page.php | 20 ++++++++++---------- app/view/admin-section.php | 4 ++-- app/view/admin-view-link.php | 12 ++++++++++++ app/view/studio-icon.php | 17 +++++++++++++++++ app/view/studio-media.php | 5 ++++- app/view/studio-new-page.php | 4 ++-- app/view/studio-page-templates.php | 5 +++-- app/view/studio-settings.php | 2 +- config/route.php | 1 + public/assets/admin.css | 29 +++++++++++++++++++++++------ 19 files changed, 152 insertions(+), 51 deletions(-) create mode 100644 app/view/admin-about.php create mode 100644 app/view/admin-view-link.php diff --git a/app/Controller/AdminController.php b/app/Controller/AdminController.php index 6e98212..8adda75 100644 --- a/app/Controller/AdminController.php +++ b/app/Controller/AdminController.php @@ -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 diff --git a/app/view/admin-about.php b/app/view/admin-about.php new file mode 100644 index 0000000..4b0a1f8 --- /dev/null +++ b/app/view/admin-about.php @@ -0,0 +1,14 @@ + +

+
+

版本与运行环境

+
+ $laysiteVersion] + $systemInfo as $name => $value): ?> +
+ +
+
diff --git a/app/view/admin-article-list.php b/app/view/admin-article-list.php index ea53853..2e9a139 100644 --- a/app/view/admin-article-list.php +++ b/app/view/admin-article-list.php @@ -10,7 +10,7 @@ $e = View::escape(...);
· ·
- 编辑文章 + 'edit']) ?>编辑文章 diff --git a/app/view/admin-article.php b/app/view/admin-article.php index 1d00a00..2cc5adc 100644 --- a/app/view/admin-article.php +++ b/app/view/admin-article.php @@ -8,7 +8,7 @@ $e = View::escape(...);

- 查看公开页面 + '/articles/' . $article['slug'], 'icon' => 'external']) ?>
@@ -23,7 +23,7 @@ $e = View::escape(...);
- +
@@ -48,7 +48,7 @@ $e = View::escape(...); - +
@@ -58,7 +58,7 @@ $e = View::escape(...);

删除后,文章及其目录卡片会从网站移除,且无法恢复。

- + diff --git a/app/view/admin-articles.php b/app/view/admin-articles.php index f314cd7..5fdf5e3 100644 --- a/app/view/admin-articles.php +++ b/app/view/admin-articles.php @@ -8,8 +8,8 @@ $filters = $category ? 'category=' . rawurlencode($category) . '&' : '';

文章与动态

文章已删除。

diff --git a/app/view/admin-dashboard.php b/app/view/admin-dashboard.php index 5fed558..790faac 100644 --- a/app/view/admin-dashboard.php +++ b/app/view/admin-dashboard.php @@ -17,9 +17,9 @@ foreach (['header', 'footer'] as $kind) {

网站后台

- 新建页面 - - 写文章 + 'add']) ?>新建页面 + + 'edit']) ?>写文章
@@ -58,8 +58,12 @@ foreach (['header', 'footer'] as $kind) {
- 编辑页面 - + 'edit']) ?>编辑页面 + $public ? $path : '/admin/pages/' . $page['slug'] . '/preview', + 'icon' => $public ? 'external' : 'preview', + 'label' => ($public ? '查看公开页面' : '预览页面') . ' · ' . $page['name'], + ]) ?>
@@ -74,8 +78,8 @@ foreach (['header', 'footer'] as $kind) {

站点编辑

diff --git a/app/view/admin-design-edit.php b/app/view/admin-design-edit.php index 623dc26..bd555e0 100644 --- a/app/view/admin-design-edit.php +++ b/app/view/admin-design-edit.php @@ -17,7 +17,9 @@ $fieldError = static function (string $name) use ($errorId, $field, $error, $e): 返回站点设计

配色方案

- 预览已保存的配置 + + '/admin/design/palette/' . $key . '/preview', 'icon' => 'preview', 'label' => '预览已保存的配置']) ?> +
$field === '' ? $error : '', 'saved' => $saved]) ?>
@@ -29,5 +31,5 @@ $fieldError = static function (string $name) use ($errorId, $field, $error, $e): -
+
diff --git a/app/view/admin-design.php b/app/view/admin-design.php index e0d66d0..3853b45 100644 --- a/app/view/admin-design.php +++ b/app/view/admin-design.php @@ -3,15 +3,21 @@ use App\Content\View; $e = View::escape(...); ?> -

站点设计

+
+

站点设计

+ +

在网站页面中管理页头和页脚

-

配色方案

新建配色方案
+

暂无自定义配色。

diff --git a/app/view/admin-layout.php b/app/view/admin-layout.php index 892be0b..3497d48 100644 --- a/app/view/admin-layout.php +++ b/app/view/admin-layout.php @@ -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) { >站点设计
- 访问网站 + '/', 'icon' => 'globe']) ?>
- 返回网站 + '/', 'icon' => 'globe', 'label' => '返回网站']) ?>
-
LaySite ver
+
LaySite ver

从媒体库选择

diff --git a/app/view/admin-page.php b/app/view/admin-page.php index 9daf60c..86df61f 100644 --- a/app/view/admin-page.php +++ b/app/view/admin-page.php @@ -20,18 +20,18 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;

- 页面设置 + 'settings']) ?>页面设置 '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?> > + href="" target="_blank" rel="noopener"> $kind]) ?> - - 站点设置 - 公开页面 + + 'settings']) ?>站点设置 + $path, 'icon' => 'external']) ?> - 打开预览 + $previewUrl, 'icon' => 'preview', 'label' => '预览页面']) ?>
@@ -48,8 +48,8 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;

页面画布

- - + +
- +
@@ -228,7 +228,7 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null; -
+
diff --git a/app/view/admin-section.php b/app/view/admin-section.php index 1bac8dd..73ade75 100644 --- a/app/view/admin-section.php +++ b/app/view/admin-section.php @@ -9,7 +9,7 @@ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR); 返回页面编辑

· #

- 预览区块 + '/admin/pages/' . $slug . '/preview#' . $key, 'icon' => 'preview', 'label' => '预览区块']) ?>
@@ -29,5 +29,5 @@ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR); 'html', 'body' => $section['body']]) ?> -
+
diff --git a/app/view/admin-view-link.php b/app/view/admin-view-link.php new file mode 100644 index 0000000..1a12e47 --- /dev/null +++ b/app/view/admin-view-link.php @@ -0,0 +1,12 @@ + '查看公开页面', + 'preview' => '打开预览', + 'globe' => '访问网站', +}; +$hint = $e($label . '(在新标签页打开)'); +?> + diff --git a/app/view/studio-icon.php b/app/view/studio-icon.php index d7e2bdd..cab00b6 100644 --- a/app/view/studio-icon.php +++ b/app/view/studio-icon.php @@ -9,6 +9,23 @@ $paths = [ 'edit' => '', 'copy' => '', 'delete' => '', + 'external' => '', + 'preview' => '', + 'globe' => '', + 'account' => '', + 'chevron' => '', + 'key' => '', + 'logout' => '', + 'info' => '', + 'add' => '', + 'templates' => '', + 'header' => '', + 'footer' => '', + 'media' => '', + 'save' => '', + 'desktop' => '', + 'phone' => '', + 'archive' => '', ]; ?> diff --git a/app/view/studio-media.php b/app/view/studio-media.php index 3d0a78c..b3c9af7 100644 --- a/app/view/studio-media.php +++ b/app/view/studio-media.php @@ -32,7 +32,10 @@ $e = View::escape(...);

KB · -
打开
+
+ $file['url'], 'icon' => 'external', 'label' => '打开媒体文件']) ?> + +
管理文件
diff --git a/app/view/studio-new-page.php b/app/view/studio-new-page.php index fdf1ff2..bee4324 100644 --- a/app/view/studio-new-page.php +++ b/app/view/studio-new-page.php @@ -6,7 +6,7 @@ $e = View::escape(...); 返回页面

新建页面

- +
$error, 'saved' => false]) ?> @@ -20,6 +20,6 @@ $e = View::escape(...); -
+
diff --git a/app/view/studio-page-templates.php b/app/view/studio-page-templates.php index 8c99adf..1ed3085 100644 --- a/app/view/studio-page-templates.php +++ b/app/view/studio-page-templates.php @@ -43,7 +43,8 @@ $previewRoot = '/assets/page-templates/';
@@ -52,7 +53,7 @@ $previewRoot = '/assets/page-templates/';
-
+
diff --git a/app/view/studio-settings.php b/app/view/studio-settings.php index df61494..8ecc06e 100644 --- a/app/view/studio-settings.php +++ b/app/view/studio-settings.php @@ -27,5 +27,5 @@ $e = View::escape(...);

开启后,访客会看到维护页。后台仍可登录和编辑。

- + diff --git a/config/route.php b/config/route.php index 5e449dc..8dc72c8 100644 --- a/config/route.php +++ b/config/route.php @@ -32,6 +32,7 @@ Route::get('/canvas-style.css', [SiteController::class, 'canvasStyle']); Route::add(['GET', 'POST'], '/admin/login', [AdminController::class, 'login']); Route::post('/admin/logout', [AdminController::class, 'logout']); Route::add(['GET', 'POST'], '/admin/password', [AdminController::class, 'password']); +Route::get('/admin/about', [AdminController::class, 'about']); Route::get('/admin', [AdminController::class, 'dashboard']); Route::add(['GET', 'POST'], '/admin/article-categories', [AdminController::class, 'articleCategories']); Route::get('/admin/articles', [AdminController::class, 'articles']); diff --git a/public/assets/admin.css b/public/assets/admin.css index d02bcb3..b97af6a 100644 --- a/public/assets/admin.css +++ b/public/assets/admin.css @@ -7,6 +7,11 @@ .admin-main { padding-block: clamp(1.65rem, 4vw, 3.25rem); } .admin-version { margin-block-start: auto; padding-block: 1rem; border-block-start: 1px solid var(--line); color: var(--muted); font-size: .875rem; } .settings-stack { display: grid; gap: .9rem; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .65rem; min-inline-size: 0; } +.admin-system-info { max-inline-size: 44rem; } +.admin-system-info dl { margin: 0; } +.admin-system-info dl > div { display: grid; grid-template-columns: minmax(7.5rem, 1fr) 2fr; gap: .65rem 1rem; padding-block: .85rem; border-block-start: 1px solid var(--line); } +.admin-system-info dt { color: var(--muted); } +.admin-system-info dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; } .admin-main h1 { font-size: clamp(2rem, 4vw, 3.1rem); margin: 0; } .admin-main h2 { font-size: 1.38rem; margin-bottom: 1rem; } .admin-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; margin: 0 0 1.2rem; } @@ -283,22 +288,29 @@ .admin-primary a { padding: .28rem .65rem; border-radius: .48rem; color: var(--muted); } .admin-primary a[aria-current="page"] { background: var(--accent-light); color: var(--accent-deep); } -.admin-utility { display: flex; gap: .8rem; align-items: center; font-size: .88rem; } -.admin-utility > a { padding-block: .55rem; white-space: nowrap; } +.admin-utility { display: flex; gap: .55rem; align-items: center; font-size: .88rem; } +.admin-body .button:has(> svg) { gap: .4rem; } +.admin-body :where(.button, .admin-account summary, .admin-account a, .admin-account button) > svg { + inline-size: 1.05rem; block-size: 1.05rem; flex: none; pointer-events: none; +} .admin-account { position: relative; z-index: 5; } .admin-account summary { - min-height: 2.45rem; padding: .43rem .6rem; border: 1px solid var(--line); + display: flex; align-items: center; gap: .38rem; min-height: 2.75rem; padding: .43rem .6rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--ink); cursor: pointer; } +.admin-account summary::-webkit-details-marker { display: none; } +.admin-account[open] summary > svg:last-child { transform: rotate(180deg); } .admin-account-menu { - position: absolute; inset: calc(100% + .4rem) 0 auto auto; min-width: 8rem; padding: .3rem; + position: absolute; inset: calc(100% + .4rem) 0 auto auto; min-width: 9rem; padding: .3rem; border: 1px solid var(--line); border-radius: .5rem; background: white; box-shadow: 0 .55rem 1.5rem #1d315026; } .admin-account-menu a, .admin-account-menu button { - display: block; width: 100%; padding: .52rem .65rem; border: 0; border-radius: .3rem; background: white; + display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 2.75rem; padding: .52rem .65rem; + border: 0; border-radius: .3rem; background: white; color: var(--ink); text-align: left; text-decoration: none; font: inherit; cursor: pointer; } -.admin-account-menu :is(a, button):hover { background: var(--paper); color: var(--accent-deep); } +.admin-account-menu :is(a:hover, button:hover, a[aria-current="page"]) { background: var(--paper); color: var(--accent-deep); } +.admin-account-divider { margin: .25rem .3rem; border: 0; border-block-start: 1px solid var(--line); } .dashboard-heading { margin-bottom: 1.55rem; } .dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 1.05rem; } .dashboard-grid .admin-panel { padding: clamp(.95rem, 2.3vw, 1.55rem); } @@ -317,6 +329,11 @@ .dashboard-settings h2 { margin-bottom: .55rem; } .dashboard-setting-buttons { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: 0; margin: 0; } .dashboard-setting-buttons .button { min-height: 2.45rem; padding: .3rem .6rem; font-size: .85rem; } +.button.admin-view-link { inline-size: 2.75rem; min-block-size: 2.75rem; padding: 0; flex: none; } +.button.admin-view-link > svg { inline-size: 1.15rem; block-size: 1.15rem; } +.button.admin-view-link-external { background: var(--accent-light); color: var(--accent-deep); border-color: var(--accent-light); } +.button.admin-view-link-preview { color: var(--muted); } +.button.admin-view-link:hover { background: var(--white); color: var(--accent-deep); border-color: var(--accent); } @media (max-width: 51rem) { .dashboard-grid { grid-template-columns: 1fr; gap: 0; } -- 2.52.0