Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abccb8c004 | ||
|
|
2ef38bd716 | ||
|
|
62c10b09bc | ||
|
|
935bc7f071 | ||
|
|
1a025353b2 |
@@ -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 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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);
|
||||
|
||||
+18
-8
@@ -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): ?>
|
||||
<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'] !== ''): ?><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 ?>
|
||||
<?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 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
@@ -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'];
|
||||
?>
|
||||
|
||||
@@ -17,15 +17,21 @@ $e = View::escape(...);
|
||||
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
|
||||
<ul class="network-list">
|
||||
<?php foreach ($group['articles'] as $item): ?>
|
||||
<?php $card = $item['card']; $articlePath = '/articles/' . $item['slug']; ?>
|
||||
<?php
|
||||
// 优先跳卡片配置的网址;没有网址时,只有文章本身有内容才回退到文章页,否则不渲染链接。
|
||||
$card = $item['card'];
|
||||
$articlePath = '/articles/' . $item['slug'];
|
||||
$hasDetail = $item['body'] !== '' || $item['summary'] !== '';
|
||||
$target = ($card['url'] ?? '') ?: ($hasDetail ? $articlePath : '');
|
||||
?>
|
||||
<li>
|
||||
<a href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>">
|
||||
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
|
||||
<?php if (!empty($card['image'])): ?>
|
||||
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
||||
<?php endif ?>
|
||||
<span><?= $e($item['title']) ?></span>
|
||||
</a>
|
||||
<?php if ($standalone && !empty($card['url']) && ($item['body'] !== '' || $item['summary'] !== '')): ?>
|
||||
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
|
||||
<?php if ($standalone && !empty($card['url']) && $hasDetail): ?>
|
||||
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
|
||||
@@ -17,9 +17,10 @@ $e = View::escape(...);
|
||||
<div class="catalog-grid">
|
||||
<?php foreach ($products as $product): ?>
|
||||
<?php
|
||||
// 目录卡片指向卡片自己配置的网址,文章页只在未设置网址时兜底。
|
||||
// 目录卡片指向卡片自己配置的网址;没有网址时,只有文章本身有内容才回退到文章页。
|
||||
$card = $product['card'];
|
||||
$target = ($card['url'] ?? '') ?: '/articles/' . $product['slug'];
|
||||
$hasDetail = $product['body'] !== '' || $product['summary'] !== '';
|
||||
$target = ($card['url'] ?? '') ?: ($hasDetail ? '/articles/' . $product['slug'] : '');
|
||||
?>
|
||||
<article class="catalog-card">
|
||||
<?php if (!empty($card['image'])): ?>
|
||||
@@ -27,16 +28,18 @@ $e = View::escape(...);
|
||||
<?php endif ?>
|
||||
<div class="catalog-content">
|
||||
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
||||
<h2><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a></h2>
|
||||
<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"><?= Html::articleBody($product) ?></div>
|
||||
<?php endif ?>
|
||||
<?php if ($target !== '' || !empty($card['extra_url'])): ?>
|
||||
<div class="actions">
|
||||
<a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a>
|
||||
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
|
||||
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
|
||||
@@ -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
@@ -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%; }
|
||||
|
||||
Reference in New Issue
Block a user