Author SHA1 Message Date
ChatGPT abccb8c004 Restore the original Laysense footer 2026-11-21 23:49:21 +08:00
DeepSeek 2ef38bd716 Merge pull request #8: 修复 /network 指向空白文章的死链,统一目录兜底规则
目录卡片:有网址用网址,无网址且有内容才回退文章页,否则不渲染链接。21 项断言 + 三套端到端回归通过。
2026-11-21 23:26:34 +08:00
8 changed files with 88 additions and 33 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ php bin/admin.php reset admin@example.com
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。「查看全部动态」和翻页只列出该区块所选的分类。
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
+29 -3
View File
@@ -16,14 +16,40 @@ final class SiteDesign
];
public const DEFAULT_FOOTER = [
'logo' => '/assets/wordmark.webp', 'alt' => '来笙 Laysense',
'logo' => '/assets/original/footer-wordmark.webp', 'alt' => '来笙 Laysense',
'name' => '上海来笙信息科技有限公司',
'address' => '中国(上海)自由贸易试验区世博村路231号2单元3层328室',
'email' => 'public@laysense.cn',
'products_title' => '产品与服务',
'products' => [['/pagepan', 'PAGEPAN 小飞页'], ['/highspeaker', 'HighSpeaker DNS'], ['/sc', '软著代理服务'], ['/shnu-sc', 'SHNU 学生软著服务']],
'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']],
'company_title' => '公司',
'company' => [['/#about', '关于来笙'], ['/articles', '来笙动态'], ['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
'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']],
'copyright' => '© Shanghai Laysense Information Technology Co. Ltd. 2024',
'terms' => '本网站中产品价格仅作展示,不作为订立合同、邀约或要约邀请的有效因素。',
'registration' => '沪ICP备2024051698号-1',
];
public static function footer(array $site): array
{
$saved = $site['footer'] ?? null;
if ($saved === null) {
return self::DEFAULT_FOOTER;
}
// Older configurations store the entire footer navigation in two columns.
if (!array_key_exists('resources', $saved)) {
$saved += ['resources' => [], 'resources_title' => ''];
if (!empty($saved['copyright'])) {
$saved['copyright'] .= ' 2024–' . date('Y');
}
}
return $saved + self::DEFAULT_FOOTER;
}
public static function parseLinks(string $value): array
{
$links = [];
+10 -4
View File
@@ -98,15 +98,16 @@ final class StudioController extends AdminController
$site = (new Repository())->site();
$defaults = match ($part) {
'header' => SiteDesign::DEFAULT_HEADER,
'footer' => SiteDesign::DEFAULT_FOOTER + array_intersect_key($site, array_flip(['name', 'address', 'email', 'copyright', 'registration', 'terms'])),
'footer' => SiteDesign::DEFAULT_FOOTER,
'cdn' => ['origin' => ''],
};
$config = ($site[$part] ?? []) + $defaults;
$config = $part === 'footer' ? SiteDesign::footer($site) : ($site[$part] ?? []) + $defaults;
$version = $site['revisions'][$part] ?? 0;
$error = '';
if ($request->method() === 'POST') {
try {
$config = $this->settingsInput($request, $part, $defaults);
$config = $part === 'footer' && $request->post('operation') === 'restore-footer'
? $defaults : $this->settingsInput($request, $part, $defaults, $config);
SiteDesign::saveSettings($part, $config, $this->version($request));
return $this->success($request, '/admin/settings/' . $part . '?saved=1');
@@ -177,13 +178,18 @@ final class StudioController extends AdminController
return $this->success($request, '/admin/media');
}
private function settingsInput(Request $request, string $part, array $defaults): array
private function settingsInput(Request $request, string $part, array $defaults, array $current): array
{
if ($part === 'cdn') {
return ['origin' => Assets::cdn($this->input($request, 'origin'))];
}
$result = [];
$hasResources = $request->post('resources') !== null;
foreach ($defaults as $key => $default) {
if ($part === 'footer' && !$hasResources && in_array($key, ['resources', 'resources_title'], true)) {
$result[$key] = $current[$key];
continue;
}
$input = $this->input($request, $key);
if (is_array($default)) {
$result[$key] = SiteDesign::parseLinks($input);
+25 -15
View File
@@ -8,7 +8,7 @@ $e = View::escape(...);
<div class="footer-grid">
<div class="footer-company" itemscope itemtype="https://schema.org/Organization">
<?php if ($footer['logo'] !== ''): ?>
<a href="/" itemprop="url" aria-label="来笙 Laysense 首页">
<a class="footer-logo" href="/" itemprop="url" aria-label="来笙 Laysense 首页">
<img src="<?= $e($footer['logo']) ?>" alt="<?= $e($footer['alt']) ?>" width="130" height="33" itemprop="logo" loading="lazy">
</a>
<?php endif ?>
@@ -17,31 +17,41 @@ $e = View::escape(...);
<?php if ($footer['email']): ?>
<a itemprop="email" href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a>
<?php endif ?>
<p class="footer-payment-label">支持的付款方式</p>
<div class="payment-methods" aria-label="支持的付款方式">
<img src="/assets/original/payment-taobao.png" alt="淘宝" width="26" height="26" loading="lazy">
<img src="/assets/original/payment-alipay.png" alt="支付宝" width="26" height="26" loading="lazy">
<img src="/assets/original/payment-wechat.png" alt="微信支付" width="26" height="26" loading="lazy">
</div>
</div>
<?php foreach (['products', 'company'] as $group): ?>
<?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?>
<div>
<?php if ($footer[$group . '_title'] !== ''): ?><p class="footer-label"><?= $e($footer[$group . '_title']) ?></p><?php endif ?>
<?php foreach ($footer[$group] as [$url, $label]): ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a><?php endforeach ?>
</div>
<?php endforeach ?>
<nav class="footer-links" aria-label="页脚导航">
<?php foreach (['products', 'company', 'resources'] as $group): ?>
<?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?>
<div>
<?php if ($footer[$group . '_title'] !== ''): ?><h2 class="footer-label"><?= $e($footer[$group . '_title']) ?></h2><?php endif ?>
<?php if ($footer[$group]): ?>
<ul>
<?php foreach ($footer[$group] as [$url, $label]): ?><li><a href="<?= $e($url) ?>"><?= $e($label) ?></a></li><?php endforeach ?>
</ul>
<?php endif ?>
</div>
<?php endforeach ?>
</nav>
</div>
<div class="footer-meta">
<?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?> 2024–<?= $e(date('Y')) ?></p><?php endif ?>
<?php if ($footer['phones']): ?>
<p>全球号码
<?php foreach ($footer['phones'] as $index => [$url, $label]): ?>
<?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
<?php endforeach ?>
<?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?></p><?php endif ?>
<?php if ($footer['email'] || $footer['phones']): ?>
<p>
<?php if ($footer['email']): ?><a href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a><?php endif ?>
<?php if ($footer['phones']): ?>全球号码:
<?php foreach ($footer['phones'] as $index => [$url, $label]): ?>
<?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
<?php endforeach ?>
<?php endif ?>
</p>
<?php endif ?>
<?php if ($footer['registration']): ?><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a><?php endif ?>
<?php if ($footer['terms']): ?><p class="footer-terms"><?= $e($footer['terms']) ?></p><?php endif ?>
<?php if ($footer['registration']): ?><p><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a></p><?php endif ?>
</div>
</div>
</footer>
+1 -1
View File
@@ -13,7 +13,7 @@ if (str_starts_with($imageUrl, '/')) {
$kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software';
$siteKind = $kind === 'service' ? 'other' : 'software';
$header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
$footer = ($site['footer'] ?? []) + SiteDesign::DEFAULT_FOOTER + $site;
$footer = SiteDesign::footer($site);
$nav = $header['links'];
$contact = $header['button'];
?>
+9 -1
View File
@@ -36,7 +36,7 @@ $e = View::escape(...);
<small>每行填写「显示号码 | tel:号码」。</small>
</label>
<div class="form-grid">
<?php foreach (['products' => '第一列', 'company' => '第二列'] as $key => $text): ?>
<?php foreach (['products' => '第一列', 'company' => '第二列', 'resources' => '第三列'] as $key => $text): ?>
<div class="admin-form">
<label><?= $text ?>标题<input name="<?= $key ?>_title" value="<?= $e($config[$key . '_title']) ?>"></label>
<label><?= $text ?>链接<textarea name="<?= $key ?>" rows="6"><?= $e(SiteDesign::linkText($config[$key])) ?></textarea>
@@ -50,3 +50,11 @@ $e = View::escape(...);
<?php endif ?>
<div class="form-submit"><button class="button button-primary" type="submit">保存设置</button></div>
</form>
<?php if ($part === 'footer'): ?>
<form method="post" action="/admin/settings/footer">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="version" value="<?= $e($revision) ?>">
<input type="hidden" name="operation" value="restore-footer">
<button class="button button-outline" type="submit" data-confirm="用原站的页脚内容覆盖当前页脚设置?">恢复原站页脚</button>
</form>
<?php endif ?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+13 -8
View File
@@ -301,18 +301,22 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; }
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #edf2fa; border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, .75fr)); gap: 1.5rem 3rem; }
.footer-grid > div { display: flex; flex-direction: column; align-items: flex-start; }
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #e4ecfc; border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem clamp(2rem, 7vw, 7rem); }
.footer-company { display: flex; flex-direction: column; align-items: flex-start; }
.footer-logo img { width: clamp(8.125rem, 13vw, 10rem); height: auto; }
.footer-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 1rem; }
.footer-links ul { padding: 0; margin: 0; list-style: none; }
.footer-grid a, .footer-meta a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.footer-grid a:hover, .footer-meta a:hover { color: var(--accent); text-decoration: underline; }
.footer-grid a { min-height: 44px; display: inline-flex; align-items: center; }
.footer-grid a { min-height: 40px; display: inline-flex; align-items: center; }
.footer-company p, .footer-label { color: var(--ink); font-weight: 640; margin: .2rem 0 .35rem; }
.footer-label { font-size: 1.05rem; line-height: 1.35; }
.footer-company p { margin-top: .6rem; }
.footer-company .footer-payment-label { margin: .25rem 0 0; color: var(--muted); font-size: .87rem; font-weight: 500; }
.footer-company address { color: var(--muted); max-width: 26rem; font-size: .95rem; }
.footer-meta { display: flex; flex-wrap: wrap; gap: .6rem 1.8rem; padding-top: 1.2rem; margin-top: 1.25rem; border-top: 1px solid var(--line); font-size: .875rem; }
.footer-meta { display: grid; gap: .35rem; padding-top: 1.2rem; margin-top: 1.6rem; border-top: 1px solid var(--line); font-size: .875rem; }
.footer-meta p { margin: 0; }
.footer-terms { flex-basis: 100%; }
@media (max-width: 62rem) {
.masthead-inner { gap: .85rem; }
@@ -358,8 +362,9 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.article-category { grid-column: 1; grid-row: 1; }
.article-row-title { grid-column: 1 / -1; grid-row: 2; }
.article-row time { grid-column: 2; grid-row: 1; }
.footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.footer-company { grid-column: 1 / -1; }
.footer-grid { grid-template-columns: 1fr; }
.footer-company { align-items: center; text-align: center; }
.footer-links, .footer-meta { text-align: center; }
}
@media (max-width: 23rem) {
.hero-actions .button { width: 100%; }