优化画布工具条,支持动态模块操作和首页导航编辑 #12

Merged
enoch merged 3 commits from ChatGPT/laysense.cn:studio-dynamic-component-tools into main 2026-11-22 02:12:19 +08:00
31 changed files with 273 additions and 104 deletions
Showing only changes of commit 02e8685bc2 - Show all commits
+4 -3
View File
@@ -28,10 +28,11 @@ php bin/admin.php reset admin@example.com
## 后台编辑
- **网站后台**可按名称、地址或发布状态查找页面,从列表打开画布、公开页或草稿预览。
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。已有五个内置页面的首屏图文和正文区块都可复用,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。可在功能分类中复用产品图文、特性组、服务报价等内置模板,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表和项目与伙伴卡片共用分类设置。「查看全部动态」和翻页只列出该区块所选的分类。
- **普通页面**包括 `/services`、`/articles` 和 `/contact`。产品目录和分类文章模块的设置可在画布编辑。动态页默认显示公告、新闻和产品动态。
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
@@ -71,7 +72,7 @@ location = /admin/media {
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。首页五联导航和伙伴动态模块会作为可管理区块导入一次。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。安装会补齐 `/services`、`/articles` 和 `/contact` 的页面记录,并一次性导入首页五联导航和伙伴动态模块。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
### CDN
+23 -5
View File
@@ -10,6 +10,8 @@ final class BlockTemplates
public const NETWORK_FEED = '{"categories":["supported-projects","partners"],"mode":"network","limit":30}';
public const CATALOG_FEED = '{"categories":["services"],"mode":"catalog","limit":30}';
public const PRODUCT_LINKS = '<div class="hero-directory"><a class="overline directory-label" href="/services">产品与服务</a><a href="/pagepan"><span>PAGEPAN</span><small>可视化建站</small></a><a href="/highspeaker"><span>HighSpeaker DNS</span><small>开源智能解析</small></a><a href="/sc"><span>软著代理</span><small>登记申请与材料服务</small></a><a href="/shnu-sc"><span>SHNU 学生</span><small>软著申请方案</small></a></div>';
public const ELEMENT_GROUPS = [
@@ -72,7 +74,7 @@ final class BlockTemplates
'two-actions' => ['双按钮横幅', '<div class="studio-banner studio-banner-two"><div><h3>选择下一步</h3><p>介绍访客可以立即做什么。</p></div><div class="actions"><a class="button button-primary" href="/services">查看服务</a><a class="button button-outline" href="/#contact">联系我们</a></div></div>'],
]],
'layout' => ['图文与布局', [
'image' => ['图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
'image' => ['产品图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
'grid' => ['双栏网格', '<div class="studio-two-column"><article class="content-card"><h3>第一栏</h3><p>填写主要内容。</p></article><article class="content-card"><h3>第二栏</h3><p>补充相关信息。</p></article></div>'],
]],
'media' => ['媒体', [
@@ -94,6 +96,7 @@ final class BlockTemplates
'pricing' => ['双方案报价', '<div class="card-grid price-grid studio-pricing"><article class="content-card price-card"><h3>基础方案</h3><p class="price-value">填写价格</p><p>填写方案包含的服务。</p><a class="button button-outline" href="/#contact">咨询基础方案</a></article><article class="content-card price-card"><h3>进阶方案</h3><p class="price-value">填写价格</p><p>填写扩展服务或权益。</p><a class="button button-primary" href="/#contact">咨询进阶方案</a></article></div>'],
]],
'actions' => ['导航与引导', [
'service-catalog' => ['产品与服务目录', '', '', self::CATALOG_FEED],
'product-links' => ['产品与服务五联导航', self::PRODUCT_LINKS],
'navigation' => ['快速导航', '<ul class="studio-quick-nav"><li><a href="/services">产品与服务</a></li><li><a href="/articles">动态与文章</a></li><li><a href="/#contact">联系来笙</a></li></ul>'],
'cta' => ['行动按钮', '<p>说明下一步。</p><p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
@@ -111,7 +114,17 @@ final class BlockTemplates
$groups = self::GROUPS;
$seed = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR);
$sectionGroups = [
'product' => 'layout', 'about' => 'content', 'blog' => 'content',
'features' => 'features', 'support' => 'features', 'why' => 'features', 'stories' => 'features',
'pricing' => 'details', 'comparison' => 'details', 'materials' => 'details', 'fees' => 'details',
'faq' => 'details', 'terms' => 'details',
'get' => 'actions', 'options' => 'actions', 'go' => 'actions', 'benefits' => 'layout',
];
foreach ($seed['pages'] as $page) {
if (!in_array($page['slug'], ['home', 'highspeaker', 'sc', 'shnu-sc'], true)) {
continue;
}
$links = '';
foreach ($page['actions'] as [$url, $label]) {
$links .= '<a class="button button-outline" href="' . View::escape($url) . '">' . View::escape($label) . '</a>';
@@ -119,15 +132,20 @@ final class BlockTemplates
$hero = '<div class="studio-cover"><img src="' . View::escape($page['image']) . '" alt="' . View::escape($page['alt']) . '" loading="lazy">'
. '<div><h3>' . View::escape(trim($page['heading'] . ' ' . $page['accent'])) . '</h3><p>' . View::escape($page['lead'])
. '</p><div class="actions">' . $links . '</div></div></div>';
$items = ['existing-' . $page['slug'] . '-hero' => ['首屏图文', $hero]];
$prefix = 'existing-' . $page['slug'] . '-';
$groups['cover'][1][$prefix . 'hero'] = ['产品图文 · ' . $page['name'], $hero];
foreach ($page['sections'] as $section) {
$items['existing-' . $page['slug'] . '-' . $section['key']] = [
$section['title'], Html::sanitize($section['body']), $section['lead'],
$group = $sectionGroups[$section['key']] ?? null;
if ($group === null) {
continue;
}
$groups[$group][1][$prefix . $section['key']] = [
$section['key'] === 'features' ? '特性组' : $section['title'],
Html::sanitize($section['body']), $section['lead'],
isset($section['feed']) ? Database::json($section['feed']) : null,
$section['style'],
];
}
$groups['existing-' . $page['slug']] = ['现有页面 · ' . $page['name'], $items];
}
return $groups;
+2 -2
View File
@@ -12,7 +12,7 @@ final class SiteDesign
public const DEFAULT_HEADER = [
'logo' => '/assets/wordmark.webp', 'alt' => 'Laysense 来笙',
'links' => [['/', '首页'], ['/services', '产品与服务'], ['/articles', '动态'], ['/#about', '关于来笙']],
'button' => ['#contact', '联系来笙'],
'button' => ['/contact', '联系来笙'],
];
public const DEFAULT_FOOTER = [
@@ -23,7 +23,7 @@ final class SiteDesign
'products_title' => '产品与服务',
'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']],
'company_title' => '公司',
'company' => [['/#about', '关于来笙'], ['#contact', '联系来笙']],
'company' => [['/#about', '关于来笙'], ['/contact', '联系来笙']],
'resources_title' => '资源',
'resources' => [['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']],
+1 -1
View File
@@ -581,7 +581,7 @@ class AdminController
{
$categories = $this->selectedCategories($selected);
$limit = filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]);
if (!in_array($mode, ['merged', 'tabs', 'network'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
if (!in_array($mode, ['merged', 'tabs', 'network', 'catalog'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
throw new RuntimeException('请选择文章分类,并将展示数量设为 1 至 30。');
}
+17 -19
View File
@@ -24,6 +24,16 @@ final class SiteController
if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
return $this->missing($request);
}
if ($slug === 'articles' && $request->get('page') !== null) {
foreach ($page['sections'] as $section) {
$feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
if (in_array($feed['mode'] ?? null, ['merged', 'tabs'], true)) {
return $this->feedArchive($request, $slug, $section['key']);
}
}
return $this->missing($request);
}
return $this->renderPage($repo, $page);
}
@@ -38,6 +48,7 @@ final class SiteController
}
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
$network = $feed['mode'] === 'network';
$catalog = $feed['mode'] === 'catalog';
$grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1);
$archivePath = '/articles/feed/' . $slug . '/' . $section['key'];
if ($network && count($feed['categories']) === 2 && !array_diff($feed['categories'], ['supported-projects', 'partners'])) {
@@ -46,11 +57,13 @@ final class SiteController
$section['archivePath'] = $page['status'] === 'published' ? $archivePath : null;
$section['articleFeed'] = [];
$section['networkFeed'] = $network;
$section['catalogFeed'] = $catalog;
$section['feedLimit'] = $feed['limit'];
foreach ($grouped ? $feed['categories'] : [''] as $category) {
$selected = $category === '' ? $feed['categories'] : [$category];
$section['articleFeed'][] = [
'categories' => $selected, 'label' => $categories[$category] ?? '',
'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network),
'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network || $catalog),
];
}
}
@@ -68,18 +81,6 @@ final class SiteController
]);
}
public function services(Request $request): Response
{
$repo = new Repository();
return View::render('services', [
'site' => $repo->site(), 'path' => '/services',
'title' => '产品与服务 · 来笙 Laysense',
'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。',
'products' => $repo->articles('services', limit: -1, directoryOrder: true),
]);
}
public function network(Request $request): Response
{
$repo = new Repository();
@@ -157,6 +158,7 @@ final class SiteController
'archivePath' => $category === null ? $allPath : $categoryLinks[$category], 'allPath' => $allPath,
'categoryLinks' => $categoryLinks, 'categories' => $categories, 'category' => $category, 'tag' => null,
'categoryScope' => $category === null ? array_keys($categories) : [$category],
'catalog' => $feed['mode'] === 'catalog',
'backPath' => $returnPath, 'backLabel' => '返回原页面', 'noindex' => true,
]);
}
@@ -168,7 +170,7 @@ final class SiteController
return $this->missing($request);
}
$page = (int) $number;
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20);
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20, directoryOrder: $view['catalog'] ?? false);
if ($page > 1 && $articles === []) {
return $this->missing($request);
}
@@ -240,11 +242,7 @@ final class SiteController
$repo = new Repository();
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
$pages = $repo->pages(publishedOnly: true);
$pages[] = ['slug' => 'services', 'updated_at' => null];
$pages[] = ['slug' => 'network', 'updated_at' => null];
if ($repo->articles(limit: 1)) {
$pages[] = ['slug' => 'articles', 'updated_at' => null];
}
foreach ($pages as $page) {
$xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']);
}
@@ -269,7 +267,7 @@ final class SiteController
$normal = rtrim($path, '/');
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
if ($known || in_array($normal, ['/services', '/network'], true) || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) {
if ($known || $normal === '/network' || preg_match('~^/articles(?:/[a-z0-9-]+){1,2}$~D', $normal)) {
$query = $request->queryString();
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
+1 -1
View File
@@ -27,7 +27,7 @@ final class StudioController extends AdminController
$data['name'] = $this->input($request, 'name');
$data['slug'] = $this->input($request, 'slug');
try {
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'network', 'news', 'main', 'favicon'], true)
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'home', 'network', 'news', 'main', 'favicon'], true)
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
throw new RuntimeException('请填写页面名称及可用的网址标识。');
}
+5 -5
View File
@@ -48,11 +48,11 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
</section>
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
<h2 id="quick-title">站点编辑</h2>
<ul>
<li><a href="/admin/settings/header">编辑页头</a></li>
<li><a href="/admin/settings/footer">编辑页脚</a></li>
<li><a href="/admin/settings/cdn">静态资源 CDN</a></li>
<li><a href="/admin/media">打开媒体库</a></li>
<ul class="dashboard-setting-buttons">
<li><a class="button button-outline" href="/admin/settings/header">编辑页头</a></li>
<li><a class="button button-outline" href="/admin/settings/footer">编辑页脚</a></li>
<li><a class="button button-outline" href="/admin/settings/cdn">静态资源 CDN</a></li>
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
</ul>
</section>
</div>
+5 -1
View File
@@ -16,7 +16,11 @@ $e = View::escape(...);
<a href="<?= $e($categoryLinks[$key]) ?>" <?= $category === (string) $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
<?php endforeach ?>
</nav>
<?= View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
<?php if (!empty($catalog)): ?>
<?= View::fragment('service-cards', ['products' => $articles]) ?>
<?php else: ?>
<?= View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
<?php endif ?>
<?php if ($pageNumber > 1 || $hasNext): ?>
<nav class="pagination" aria-label="动态分页">
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="<?= $e(View::archivePage($archivePath, $pageNumber - 1)) ?>" rel="prev">上一页</a><?php endif ?>
+6
View File
@@ -24,6 +24,7 @@ if ($dynamic && $body === '<p><a class="back-link" href="/articles">查看全部
$body = '';
}
$network = $section['networkFeed'] ?? false;
$catalog = $section['catalogFeed'] ?? false;
?>
<section class="section section-<?= $e($section['style']) ?><?= $network ? ' network' : '' ?>" id="<?= $e($section['key']) ?>" aria-labelledby="heading-<?= $e($section['key']) ?>" <?= $moment ? 'data-moment="iris-opens"' : '' ?><?= $studio ?>>
<div class="wrap">
@@ -40,6 +41,11 @@ $network = $section['networkFeed'] ?? false;
</div>
<?php endforeach ?>
<?php if ($section['archivePath'] !== null): ?><p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p><?php endif ?>
<?php elseif ($catalog): ?>
<?= View::fragment('service-cards', ['products' => $section['articleFeed'][0]['articles']]) ?>
<?php if ($section['archivePath'] !== null && count($section['articleFeed'][0]['articles']) >= $section['feedLimit']): ?>
<p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p>
<?php endif ?>
<?php elseif (!empty($section['articleFeed'])): ?>
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key'], 'archivePath' => $section['archivePath']]) ?>
<?php endif ?>
+38
View File
@@ -0,0 +1,38 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?>
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
<div class="catalog-grid">
<?php foreach ($products as $product): ?>
<?php
$card = $product['card'];
$body = Html::articleBody($product);
$target = DirectoryCard::links($product, $body)['primary'];
$extra = $card['extra_url'] ?? '';
?>
<article class="catalog-card">
<?php if (!empty($card['image'])): ?>
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
<?php endif ?>
<div class="catalog-content">
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<h3><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h3>
<?php if ($product['summary']): ?>
<p><?= $e($product['summary']) ?></p>
<?php else: ?>
<div class="rich"><?= $body ?></div>
<?php endif ?>
<?php if ($target !== '' || $extra !== ''): ?>
<div class="actions">
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
</div>
<?php endif ?>
</div>
</article>
<?php endforeach ?>
</div>
-50
View File
@@ -1,50 +0,0 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?>
<section class="section catalog-hero">
<div class="wrap">
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
<h1>产品与服务</h1>
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
</div>
</section>
<section class="section catalog-listing" aria-label="产品与服务目录">
<div class="wrap">
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
<div class="catalog-grid">
<?php foreach ($products as $product): ?>
<?php
$card = $product['card'];
$body = Html::articleBody($product);
['primary' => $target, 'detail' => $detail] = DirectoryCard::links($product, $body);
$extra = $card['extra_url'] ?? '';
?>
<article class="catalog-card">
<?php if (!empty($card['image'])): ?>
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
<?php endif ?>
<div class="catalog-content">
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
<?php if ($product['summary']): ?>
<p><?= $e($product['summary']) ?></p>
<?php else: ?>
<div class="rich"><?= $body ?></div>
<?php endif ?>
<?php if ($target !== '' || $extra !== ''): ?>
<div class="actions">
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
<?php if ($detail !== '' && $detail !== $extra): ?><a class="catalog-detail" href="<?= $e($detail) ?>">查看详情</a><?php endif ?>
</div>
<?php endif ?>
</div>
</article>
<?php endforeach ?>
</div>
</div>
</section>
+1 -1
View File
@@ -2,7 +2,7 @@
use App\Content\View;
$e = View::escape(...);
$modes = ($allowOff ? ['off' => '不展示'] : []) + ['merged' => '合并列表', 'tabs' => '分类标签页', 'network' => '项目与伙伴卡片'];
$modes = ($allowOff ? ['off' => '不展示'] : []) + ['merged' => '合并列表', 'tabs' => '分类标签页', 'network' => '项目与伙伴卡片', 'catalog' => '产品与服务卡片'];
?>
<div class="form-grid">
<label>展示方式<select name="feed_mode">
-2
View File
@@ -10,10 +10,8 @@ use Webman\Route;
Route::disableDefaultRoute();
Route::get('/', [SiteController::class, 'home']);
Route::get('/services', [SiteController::class, 'services']);
Route::get('/network', [SiteController::class, 'network']);
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
Route::get('/articles', [SiteController::class, 'archive']);
Route::get('/articles/category/{category:[a-z0-9-]+}', [SiteController::class, 'archive']);
Route::get('/articles/tag/{tag:[^/]+}', [SiteController::class, 'tagged']);
Route::get('/articles/feed/{slug:[a-z0-9-]+}/{key:[a-z0-9-]+}', [SiteController::class, 'feedArchive']);
+2 -1
View File
@@ -285,7 +285,8 @@
.dashboard-secondary .admin-list li { gap: .35rem .65rem; }
.dashboard-secondary .admin-list .button { min-height: 2.15rem; padding: .25rem .5rem; font-size: .82rem; }
.dashboard-settings h2 { margin-bottom: .55rem; }
.dashboard-settings ul { display: flex; flex-wrap: wrap; gap: .45rem 1.15rem; list-style: none; padding: 0; margin: 0; }
.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; }
@media (max-width: 51rem) {
.dashboard-grid { grid-template-columns: 1fr; gap: 0; }
+3 -2
View File
@@ -384,13 +384,12 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.catalog-hero { background: var(--paper); padding-block: clamp(3rem, 6vw, 6rem); }
.catalog-hero h1 { margin-bottom: .85rem; }
.catalog-hero p { margin: 0; font-size: 1.15rem; }
.catalog-listing { padding-block: clamp(3rem, 6vw, 6rem); }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2rem); }
.catalog-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.catalog-image { aspect-ratio: 16 / 8; padding: clamp(.8rem, 3vw, 1.8rem); background: var(--paper); display: grid; place-items: center; }
.catalog-image img { max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.catalog-content { padding: clamp(1.25rem, 3vw, 2rem); flex: 1; display: flex; flex-direction: column; }
.catalog-content h2 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
.catalog-content h3 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
.catalog-content .overline { margin-bottom: .4rem; }
.catalog-content .actions { margin-top: auto; padding-top: 1rem; }
@@ -736,3 +735,5 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.studio-empty { text-align: center; border: 1px dashed var(--line); border-radius: .6rem; padding: clamp(1.25rem, 4vw, 2.7rem); }
.studio-success-note { border-inline-start-color: #257b50; background: #e7f6ed; }
.rich .hero-directory { border-bottom: 1px solid var(--line); border-radius: .85rem; }
.hero:is(.hero-services, .hero-articles, .hero-contact) .hero-text-only { min-height: auto; }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

+87
View File
@@ -428,6 +428,93 @@
"style": "plain"
}
]
},
{
"slug": "services",
"name": "产品与服务",
"title": "产品与服务 · 来笙 Laysense",
"heading": "产品与服务",
"accent": "",
"description": "自托管建站、开源智能 DNS 与软件著作权代理服务。",
"lead": "自托管建站、开源智能 DNS 与软件著作权代理服务。",
"image": "",
"alt": "",
"actions": [],
"quicklinks": [],
"sections": [
{
"key": "catalog",
"title": "服务目录",
"lead": "",
"body": "",
"style": "plain",
"feed": {
"categories": [
"services"
],
"mode": "catalog",
"limit": 30
}
}
]
},
{
"slug": "articles",
"name": "来笙动态",
"title": "来笙动态 · 来笙 Laysense",
"heading": "来笙动态",
"accent": "",
"description": "查看来笙的公告、新闻和产品动态。",
"lead": "查看来笙的公告、新闻和产品动态。",
"image": "",
"alt": "",
"actions": [],
"quicklinks": [],
"sections": [
{
"key": "updates",
"title": "公告、新闻与产品动态",
"lead": "",
"body": "",
"style": "plain",
"feed": {
"categories": [
"announcement",
"news",
"product"
],
"mode": "tabs",
"limit": 8
}
}
]
},
{
"slug": "contact",
"name": "联系来笙",
"title": "联系来笙 · 来笙 Laysense",
"heading": "联系来笙",
"accent": "",
"description": "联系上海来笙信息科技有限公司,咨询产品、技术支持或合作。",
"lead": "联系上海来笙信息科技有限公司,咨询产品、技术支持或合作。",
"image": "",
"alt": "",
"actions": [
[
"mailto:public@laysense.cn",
"发送邮件"
]
],
"quicklinks": [],
"sections": [
{
"key": "contact-information",
"title": "联系方式",
"lead": "",
"body": "<div class=\"studio-contact\"><div><h3>上海来笙信息科技有限公司</h3><p>上海自贸试验区世博村路231号2单元3层328室</p></div><dl class=\"studio-definitions\"><dt>电子邮件</dt><dd><a href=\"mailto:public@laysense.cn\">public@laysense.cn</a></dd><dt>全球号码</dt><dd><a href=\"tel:+16699004532\">+1 (669) 900 4532</a> / <a href=\"tel:+85257012856\">+852 5701 2856</a></dd></dl></div>",
"style": "plain"
}
]
}
],
"articles": [
+9 -4
View File
@@ -9,6 +9,7 @@ use App\Content\View;
$primary = 'https://example.com/product?a=1&b=2';
$cases = [
'configured-with-detail' => [['card' => ['url' => $primary], 'body' => '<p>有正文</p>'], $primary, true],
'configured-with-extra' => [['card' => ['url' => '/sc', 'extra_url' => '/pagepan#download', 'extra_label' => '下载'], 'summary' => '简介'], '/sc', true],
'configured-only' => [['card' => ['url' => '/pagepan']], '/pagepan', false],
'summary-only' => [['summary' => '仅摘要'], '/articles/summary-only', false],
'editor-placeholder' => [['body' => '<p><br></p><p>&nbsp;&#8203;</p>'], '', false],
@@ -36,16 +37,20 @@ function equal(mixed $actual, mixed $expected, string $message): void
}
}
$services = parseFragment(View::fragment('services', ['products' => $items]));
$services = parseFragment(View::fragment('service-cards', ['products' => $items]));
$network = parseFragment(View::fragment('network-groups', [
'network' => ['partners' => ['name' => '合作伙伴', 'articles' => $items]], 'standalone' => true,
]));
foreach ($cases as $slug => [, $target, $detail]) {
$card = "//article[h2='$slug' or div/h2='$slug']";
$card = "//article[div/h3='$slug']";
equal($services->evaluate("count($card)"), 1.0, "$slug 服务卡片存在");
equal($services->evaluate("string($card/div/h2/a/@href)"), $target, "$slug 服务标题目标");
equal($services->evaluate("string($card/div/h3/a/@href)"), $target, "$slug 服务标题目标");
equal($services->evaluate("string($card/div/div/a[contains(@class, 'button-primary')]/@href)"), $target, "$slug 服务按钮目标");
equal($services->evaluate("boolean($card/div/div/a[@class='catalog-detail'][@href='/articles/$slug'])"), $detail, "$slug 服务独立详情");
equal($services->evaluate("boolean($card/div/div/a[@href='/articles/$slug'][not(contains(@class, 'button-primary'))])"), false, "$slug 不追加详情");
if ($slug === 'configured-with-extra') {
equal($services->evaluate("string($card/div/div/a[@href='/pagepan#download'])"), '下载', "$slug 保留附加链接");
equal($services->evaluate("count($card/div/div/a)"), 2.0, "$slug 只有主、附加链接");
}
$item = "//li[*[1]/span='$slug']";
equal($network->evaluate("count($item)"), 1.0, "$slug 伙伴卡片存在");
+69 -7
View File
@@ -35,6 +35,10 @@ async function run(browser) {
await post('/admin/new-page', {slug, name: '画布测试页'});
await page.goto('/admin');
const dashboard = page.locator('[data-page-list]');
const settingsLinks = page.getByRole('region', {name: '站点编辑'}).locator('.dashboard-setting-buttons .button');
assert.deepEqual(await settingsLinks.evaluateAll((links) => links.map((link) => link.getAttribute('href'))), [
'/admin/settings/header', '/admin/settings/footer', '/admin/settings/cdn', '/admin/media',
]);
await dashboard.locator('[data-page-search]').fill(slug);
assert.equal(await dashboard.locator('[data-page-item]:visible').count(), 1);
const draft = dashboard.locator('[data-page-item]:visible');
@@ -166,9 +170,12 @@ async function run(browser) {
const elementTab = gallery.getByRole('tab', {name: '元素'});
const backToModules = () => modules.getByRole('button', {name: '返回分类'}).click();
const openModule = (key) => modules.locator('[data-library-category="' + key + '"]').click();
assert.equal(await modules.locator('[data-library-category]:visible').count(), 12);
assert.equal(await modules.locator('[data-library-category]:visible').count(), 7);
assert.equal(await modules.locator('[data-template-card]:visible').count(), 0);
assert.equal(await modules.locator('[data-template-card]').count(), 65);
assert.equal(await modules.locator('[data-template-card]').count(), 59);
assert.equal(await modules.locator('[data-canvas-template^=existing-pagepan]').count(), 0);
assert.equal(await modules.locator('[data-canvas-template=existing-highspeaker-registration]').count(), 0);
assert.equal(await modules.locator('[data-canvas-template=existing-highspeaker-features]').getAttribute('data-template-title'), '特性组');
assert.equal(await modules.getByText('按锚点新建区块').count(), 1);
assert.equal(await gallery.locator('[data-library-panel=layers]').getByText(/首屏与目录|按锚点新建区块/).count(), 0);
assert.equal(await page.locator('#studio-page-settings').getByText('首屏与目录').count(), 1);
@@ -197,7 +204,7 @@ async function run(browser) {
});
assert.equal(brokenPreviews, 0);
await openModule('cover');
assert.equal(await modules.locator('[data-template-card]:visible').count(), 3);
assert.equal(await modules.locator('[data-template-card]:visible').count(), 7);
const cover = gallery.locator('[data-template-preview=cover]');
await cover.hover();
const peek = gallery.locator('[data-template-peek]');
@@ -224,8 +231,6 @@ async function run(browser) {
await openModule('details');
await modules.locator('[data-canvas-template=pricing]').click();
await frame.locator('.studio-pricing').waitFor();
await backToModules();
await openModule('existing-sc');
await modules.locator('[data-canvas-template=existing-sc-materials]').click();
await frame.locator('section[id^=block-]').filter({hasText: '申请软著需要哪些材料'}).waitFor();
await modules.locator('[data-canvas-template=existing-sc-pricing]').click();
@@ -371,13 +376,70 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
await noJS.close();
assert((await context.request.get('/articles/category/' + category)).ok());
await verifyScopedArchive(context, page, sourcePage, post, slug, feedId, category, publishedPath);
await sourcePage.goto('/services');
await sourcePage.locator('.catalog-card').first().waitFor();
await verifyEditableLandingPages(page, sourcePage, category, publishedPath, slug);
await sourcePage.goto('/network');
assert.equal(await sourcePage.locator('.network-group').count(), 2);
await sourcePage.close();
}
async function verifyEditableLandingPages(admin, publicPage, category, articlePath, slug) {
await publicPage.goto('/articles');
const defaultLinks = publicPage.locator('#updates .article-list a');
assert.equal(await defaultLinks.filter({hasText: 'LayFi'}).count(), 0);
assert.equal(await defaultLinks.filter({hasText: 'PAGEPAN 小飞页'}).count(), 0);
await admin.goto('/admin/pages/articles');
const frame = admin.frameLocator('iframe[title="可编辑页面画布"]');
await frame.locator('#updates h2').click();
const tools = admin.getByRole('group', {name: '所选元素'});
await tools.getByRole('button', {name: '模块设置'}).click();
const settings = admin.locator('[data-module-dialog]');
for (const option of await settings.locator('[name="feed_categories[]"]').all()) await option.uncheck();
await settings.locator('[name="feed_categories[]"][value="' + category + '"]').check();
await settings.locator('[name=feed_limit]').fill('30');
await settings.getByRole('button', {name: '应用'}).click();
await admin.getByRole('button', {name: '保存页面', exact: true}).first().click();
await admin.locator('[data-save-confirmation]').waitFor();
await publicPage.reload();
assert.equal(await publicPage.locator('#updates a[href="' + articlePath + '"]').count(), 1);
assert.equal(await publicPage.locator('#updates a[href="/articles/' + slug + '-excluded"]').count(), 0);
const allUpdates = publicPage.locator('#updates').getByRole('link', {name: '查看全部动态'});
assert.equal(await allUpdates.getAttribute('href'), '/articles/feed/articles/updates');
await allUpdates.click();
await publicPage.waitForURL('**/articles/feed/articles/updates');
const archiveLinks = publicPage.locator('.article-list a');
const excludedPath = '/articles/' + slug + '-excluded';
assert.equal(await archiveLinks.filter({hasText: '分类分页样例 20'}).count(), 1);
assert.equal(await publicPage.locator('.article-list a[href="' + excludedPath + '"]').count(), 0);
await publicPage.getByRole('link', {name: '下一页'}).click();
await publicPage.waitForURL('**/articles/feed/articles/updates?page=2');
assert.equal(await publicPage.locator('.article-list a[href="' + articlePath + '"]').count(), 1);
assert.equal(await publicPage.locator('.article-list a[href="' + excludedPath + '"]').count(), 0);
assert.equal((await publicPage.request.get('/articles/feed/articles/updates?category=announcement')).status(), 404);
await admin.goto('/admin/pages/services');
await frame.locator('#catalog h2').click();
await tools.getByRole('button', {name: '模块设置'}).click();
assert.equal(await settings.locator('[name=feed_mode]').inputValue(), 'catalog');
assert(await settings.locator('[name="feed_categories[]"][value=services]').isChecked());
await settings.locator('[name=module_title]').fill('产品目录验证');
await settings.getByRole('button', {name: '应用'}).click();
await admin.getByRole('button', {name: '保存页面', exact: true}).first().click();
await admin.locator('[data-save-confirmation]').waitFor();
await publicPage.goto('/services');
await publicPage.getByRole('heading', {name: '产品目录验证'}).waitFor();
const cards = publicPage.locator('#catalog .catalog-card');
assert(await cards.count() > 0);
assert.equal(await cards.getByRole('link', {name: '查看详情', exact: true}).count(), 0);
assert.equal(await cards.locator('a[href="/pagepan#download"]').count(), 1);
await admin.goto('/admin/pages/contact');
await frame.locator('#contact-information a[href="mailto:public@laysense.cn"]').waitFor();
await publicPage.goto('/contact');
await publicPage.getByRole('heading', {name: '联系来笙', exact: true}).waitFor();
assert.equal(await publicPage.locator('#contact-information a[href="mailto:public@laysense.cn"]').count(), 1);
}
async function verifyScopedArchive(context, admin, page, post, slug, feedId, category, articlePath) {
const scope = '/articles/feed/' + slug + '/' + feedId;
const scopedResponse = (query = '') => context.request.get(scope + query);