优化画布工具条,支持动态模块操作和首页导航编辑 #12
@@ -35,7 +35,7 @@ php bin/admin.php reset admin@example.com
|
|||||||
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。
|
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。
|
||||||
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
||||||
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
||||||
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。编辑页底部可永久删除文章,重复安装也会保留删除结果。已发布文章改网址标识后,旧标识会自动跳转。
|
||||||
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
||||||
|
|
||||||
## 生产运行
|
## 生产运行
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ use Throwable;
|
|||||||
|
|
||||||
final class Database
|
final class Database
|
||||||
{
|
{
|
||||||
|
// Avoid reusing a deleted ID that may still be open in an editing form.
|
||||||
|
public const NEXT_ARTICLE_ID = 'MAX(COALESCE((SELECT MAX(id) FROM articles), 0),
|
||||||
|
COALESCE((SELECT MAX(article_id) FROM article_deletions), 0)) + 1';
|
||||||
|
|
||||||
private static ?PDO $connection = null;
|
private static ?PDO $connection = null;
|
||||||
|
|
||||||
public static function connect(): PDO
|
public static function connect(): PDO
|
||||||
@@ -94,8 +98,10 @@ final class Database
|
|||||||
$category->execute([$slug, $name]);
|
$category->execute([$slug, $name]);
|
||||||
}
|
}
|
||||||
$article = $pdo->prepare("INSERT OR IGNORE INTO articles
|
$article = $pdo->prepare("INSERT OR IGNORE INTO articles
|
||||||
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
|
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
|
||||||
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)");
|
SELECT " . self::NEXT_ARTICLE_ID . ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM article_deletions WHERE slug = ?)");
|
||||||
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
||||||
foreach ($seed['articles'] as $item) {
|
foreach ($seed['articles'] as $item) {
|
||||||
$format = $item['body_format'] ?? 'markdown';
|
$format = $item['body_format'] ?? 'markdown';
|
||||||
@@ -104,7 +110,7 @@ final class Database
|
|||||||
$item['slug'], $item['title'], $item['summary'] ?? '',
|
$item['slug'], $item['title'], $item['summary'] ?? '',
|
||||||
$format === 'html' ? Html::sanitize($item['body']) : $item['body'], $format,
|
$format === 'html' ? Html::sanitize($item['body']) : $item['body'], $format,
|
||||||
self::json($item['card'] ?? []), self::json($item['tags'] ?? []),
|
self::json($item['card'] ?? []), self::json($item['tags'] ?? []),
|
||||||
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'],
|
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'], $item['slug'],
|
||||||
]);
|
]);
|
||||||
if ($article->rowCount() === 1) {
|
if ($article->rowCount() === 1) {
|
||||||
$id = $pdo->lastInsertId();
|
$id = $pdo->lastInsertId();
|
||||||
|
|||||||
@@ -264,8 +264,8 @@ final class Repository
|
|||||||
];
|
];
|
||||||
if ($id === null) {
|
if ($id === null) {
|
||||||
$query = $pdo->prepare('INSERT INTO articles
|
$query = $pdo->prepare('INSERT INTO articles
|
||||||
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
|
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
VALUES (' . Database::NEXT_ARTICLE_ID . ', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
$query->execute($values);
|
$query->execute($values);
|
||||||
$id = (int) $pdo->lastInsertId();
|
$id = (int) $pdo->lastInsertId();
|
||||||
} else {
|
} else {
|
||||||
@@ -289,6 +289,22 @@ final class Repository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteArticle(int $id, int $version): void
|
||||||
|
{
|
||||||
|
Database::write(function (PDO $pdo) use ($id, $version): void {
|
||||||
|
// Keep the original seed slug even if the article has been renamed.
|
||||||
|
$deletions = $pdo->prepare('INSERT INTO article_deletions (slug, article_id)
|
||||||
|
SELECT slug, id FROM articles WHERE id = :id
|
||||||
|
UNION ALL SELECT slug, article_id FROM article_redirects WHERE article_id = :id
|
||||||
|
ON CONFLICT (slug) DO UPDATE SET article_id = excluded.article_id');
|
||||||
|
$deletions->execute(['id' => $id]);
|
||||||
|
|
||||||
|
$delete = $pdo->prepare('DELETE FROM articles WHERE id = ? AND version = ?');
|
||||||
|
$delete->execute([$id, $version]);
|
||||||
|
self::checkVersion($delete->rowCount());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function sitemapArticles(): iterable
|
public function sitemapArticles(): iterable
|
||||||
{
|
{
|
||||||
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
|
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ class AdminController
|
|||||||
return $this->render($request, 'admin-articles', [
|
return $this->render($request, 'admin-articles', [
|
||||||
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page,
|
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page,
|
||||||
'hasNext' => count($articles) > 30, 'categories' => $categories, 'category' => $category,
|
'hasNext' => count($articles) > 30, 'categories' => $categories, 'category' => $category,
|
||||||
|
'deleted' => $request->get('deleted') === '1',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +222,21 @@ class AdminController
|
|||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteArticle(Request $request, string $id): Response
|
||||||
|
{
|
||||||
|
if ($failure = $this->guard($request)) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
(new Repository())->deleteArticle((int) $id, $this->version($request));
|
||||||
|
} catch (RuntimeException $exception) {
|
||||||
|
return $this->error($request, $this->validationMessage($exception), $exception instanceof \PDOException ? 500 : 409);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($request, '/admin/articles?deleted=1');
|
||||||
|
}
|
||||||
|
|
||||||
public function page(Request $request, string $slug): Response
|
public function page(Request $request, string $slug): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
|
|||||||
@@ -51,3 +51,14 @@ $e = View::escape(...);
|
|||||||
<button class="button button-primary" type="submit">保存文章</button>
|
<button class="button button-primary" type="submit">保存文章</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<?php if ($articleId !== null): ?>
|
||||||
|
<details class="admin-panel admin-options">
|
||||||
|
<summary>删除文章</summary>
|
||||||
|
<form method="post" action="/admin/articles/<?= $e($articleId) ?>/delete">
|
||||||
|
<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>
|
||||||
|
</form>
|
||||||
|
</details>
|
||||||
|
<?php endif ?>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ $filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
|
|||||||
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
|
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<?php if ($deleted): ?><p class="feedback success" role="status">文章已删除。</p><?php endif ?>
|
||||||
<nav class="filter-nav" aria-label="筛选文章">
|
<nav class="filter-nav" aria-label="筛选文章">
|
||||||
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
<?php foreach ($categories as $key => $name): ?>
|
<?php foreach ($categories as $key => $name): ?>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ Route::add(['GET', 'POST'], '/admin/article-categories', [AdminController::class
|
|||||||
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
||||||
|
Route::post('/admin/articles/{id:[0-9]+}/delete', [AdminController::class, 'deleteArticle']);
|
||||||
Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPage']);
|
Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPage']);
|
||||||
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
||||||
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
.feedback { padding: .8rem 1rem; border-radius: .5rem; }
|
.feedback { padding: .8rem 1rem; border-radius: .5rem; }
|
||||||
.feedback.error { background: #feebeb; color: #9c252a; }
|
.feedback.error { background: #feebeb; color: #9c252a; }
|
||||||
.feedback.success { background: #e5f6ed; color: #126044; }
|
.feedback.success { background: #e5f6ed; color: #126044; }
|
||||||
|
.button-danger { color: #9c252a; background: transparent; border-color: #e6b6b9; }
|
||||||
|
.button-danger:hover { color: #9c252a; background: #feebeb; }
|
||||||
.editor { display: grid; gap: .45rem; }
|
.editor { display: grid; gap: .45rem; }
|
||||||
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
|
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
|
||||||
.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
|
.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
|
||||||
|
|||||||
@@ -152,15 +152,14 @@ address { font-style: normal; }
|
|||||||
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
|
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
|
||||||
.crumb-divider { color: #74859d; }
|
.crumb-divider { color: #74859d; }
|
||||||
.hero-directory {
|
.hero-directory {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: minmax(0, .9fr) repeat(4, minmax(0, 1fr));
|
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: .85rem .85rem 0 0;
|
border-radius: .85rem .85rem 0 0;
|
||||||
background: #ffffffb8;
|
background: #ffffffb8;
|
||||||
min-height: 7rem;
|
min-height: 7rem;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
.hero-directory > * { display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); }
|
.hero-directory > * { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); overflow-wrap: anywhere; }
|
||||||
.hero-directory a { color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); transition: background-color 160ms ease, color 160ms ease; }
|
.hero-directory a { color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); transition: background-color 160ms ease, color 160ms ease; }
|
||||||
.hero-directory a:hover { color: var(--accent); background: #fff; }
|
.hero-directory a:hover { color: var(--accent); background: #fff; }
|
||||||
.hero-directory a span { font-size: 1.12rem; font-weight: 670; }
|
.hero-directory a span { font-size: 1.12rem; font-weight: 670; }
|
||||||
@@ -350,10 +349,11 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.hero-lead { margin-bottom: 1.3rem; }
|
.hero-lead { margin-bottom: 1.3rem; }
|
||||||
.hero-illustration { border-radius: 1.15rem; }
|
.hero-illustration { border-radius: 1.15rem; }
|
||||||
.hero-illustration img { border-radius: .8rem; }
|
.hero-illustration img { border-radius: .8rem; }
|
||||||
.hero-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .2rem; }
|
.hero-directory { flex-wrap: wrap; margin-top: .2rem; }
|
||||||
.hero-directory > .overline { grid-column: 1 / -1; }
|
.hero-directory > * { flex-basis: 50%; }
|
||||||
|
.hero-directory > .directory-label { flex-basis: 100%; border-top: 0; }
|
||||||
.hero-directory a { border-top: 1px solid var(--line); min-height: 4rem; padding-inline: .8rem; }
|
.hero-directory a { border-top: 1px solid var(--line); min-height: 4rem; padding-inline: .8rem; }
|
||||||
.hero-directory a:nth-child(even) { border-inline-start: 0; }
|
.hero-directory > a:nth-child(odd of :not(.directory-label)) { border-inline-start: 0; }
|
||||||
.section-nav-inner { column-gap: 1.1rem; }
|
.section-nav-inner { column-gap: 1.1rem; }
|
||||||
.section-nav a { font-size: .875rem; }
|
.section-nav a { font-size: .875rem; }
|
||||||
.project, .project:nth-child(even) { grid-template-columns: 1fr; gap: 1rem; }
|
.project, .project:nth-child(even) { grid-template-columns: 1fr; gap: 1rem; }
|
||||||
@@ -473,7 +473,6 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
}
|
}
|
||||||
@media (max-width: 44rem) {
|
@media (max-width: 44rem) {
|
||||||
.catalog-grid, .copyright-service #materials .feature-grid { grid-template-columns: 1fr; }
|
.catalog-grid, .copyright-service #materials .feature-grid { grid-template-columns: 1fr; }
|
||||||
.hero-directory > .directory-label { grid-column: 1 / -1; border-top: 0; }
|
|
||||||
.copyright-service #go > .wrap { padding: 1.55rem; min-height: 0; }
|
.copyright-service #go > .wrap { padding: 1.55rem; min-height: 0; }
|
||||||
.copyright-service #go .contact-panel { display: flex; gap: 1rem; }
|
.copyright-service #go .contact-panel { display: flex; gap: 1rem; }
|
||||||
.copyright-service #go .contact-panel img { position: static; transform: none; width: 7rem; }
|
.copyright-service #go .contact-panel img { position: static; transform: none; width: 7rem; }
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ CREATE TABLE IF NOT EXISTS article_redirects (
|
|||||||
slug TEXT PRIMARY KEY,
|
slug TEXT PRIMARY KEY,
|
||||||
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE
|
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS article_deletions (
|
||||||
|
slug TEXT PRIMARY KEY,
|
||||||
|
article_id INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX IF NOT EXISTS article_deletions_id ON article_deletions (article_id);
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
email TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
email TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||||
|
|||||||
@@ -380,6 +380,24 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
await sourcePage.goto('/network');
|
await sourcePage.goto('/network');
|
||||||
assert.equal(await sourcePage.locator('.network-group').count(), 2);
|
assert.equal(await sourcePage.locator('.network-group').count(), 2);
|
||||||
await sourcePage.close();
|
await sourcePage.close();
|
||||||
|
|
||||||
|
await page.goto(articleAdmin);
|
||||||
|
const deletePath = articleAdmin + '/delete';
|
||||||
|
const deleteForm = page.locator('form[action="' + deletePath + '"]');
|
||||||
|
const version = await deleteForm.locator('[name=version]').inputValue();
|
||||||
|
const csrf = await deleteForm.locator('[name=csrf]').inputValue();
|
||||||
|
const headers = {'X-Requested-With': 'XMLHttpRequest'};
|
||||||
|
assert.equal((await context.request.post(deletePath, {form: {version}, headers})).status(), 403);
|
||||||
|
assert.equal((await context.request.post(deletePath, {form: {csrf, version: String(Number(version) + 1)}, headers})).status(), 409);
|
||||||
|
assert.equal((await context.request.get(publishedPath)).status(), 200);
|
||||||
|
await page.getByText('删除文章', {exact: true}).click();
|
||||||
|
await deleteForm.getByRole('button', {name: '永久删除'}).click();
|
||||||
|
await page.waitForURL('**/admin/articles?deleted=1');
|
||||||
|
await page.getByText('文章已删除。', {exact: true}).waitFor();
|
||||||
|
assert.equal(await page.locator('a[href="' + articleAdmin + '"]').count(), 0);
|
||||||
|
assert.equal((await context.request.get(articleAdmin)).status(), 404);
|
||||||
|
assert.equal((await context.request.get(publishedPath)).status(), 404);
|
||||||
|
assert(!(await (await context.request.get('/sitemap.xml')).text()).includes(publishedPath + '</loc>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function verifyEditableLandingPages(admin, publicPage, category, articlePath, slug) {
|
async function verifyEditableLandingPages(admin, publicPage, category, articlePath, slug) {
|
||||||
@@ -494,8 +512,10 @@ async function verifyHomeModules(context, page) {
|
|||||||
await page.goto('/admin/pages/home');
|
await page.goto('/admin/pages/home');
|
||||||
const frame = page.frameLocator('iframe[title="可编辑页面画布"]');
|
const frame = page.frameLocator('iframe[title="可编辑页面画布"]');
|
||||||
const tools = page.getByRole('group', {name: '所选元素'});
|
const tools = page.getByRole('group', {name: '所选元素'});
|
||||||
const card = frame.locator('#hero-directory .hero-directory a').nth(1);
|
const directory = frame.locator('#hero-directory .hero-directory');
|
||||||
assert.equal(await frame.locator('#hero-directory .hero-directory a').count(), 5);
|
const cards = directory.locator(':scope > a');
|
||||||
|
const card = cards.nth(1);
|
||||||
|
assert.equal(await cards.count(), 5);
|
||||||
await card.click();
|
await card.click();
|
||||||
const edit = tools.getByRole('button', {name: '属性'});
|
const edit = tools.getByRole('button', {name: '属性'});
|
||||||
assert.equal((await edit.textContent()).trim(), '');
|
assert.equal((await edit.textContent()).trim(), '');
|
||||||
@@ -506,6 +526,10 @@ async function verifyHomeModules(context, page) {
|
|||||||
await props.locator('[name=url]').fill('/pagepan#download');
|
await props.locator('[name=url]').fill('/pagepan#download');
|
||||||
await props.getByRole('button', {name: '应用'}).click();
|
await props.getByRole('button', {name: '应用'}).click();
|
||||||
assert.equal(await card.locator('small').textContent(), '编辑过的导航说明');
|
assert.equal(await card.locator('small').textContent(), '编辑过的导航说明');
|
||||||
|
await cards.last().click();
|
||||||
|
await tools.getByRole('button', {name: '删除'}).click();
|
||||||
|
assert.equal(await cards.count(), 4);
|
||||||
|
await verifyDirectoryWidth(directory);
|
||||||
|
|
||||||
await frame.locator('#network h2').click();
|
await frame.locator('#network h2').click();
|
||||||
const moduleSettings = tools.getByRole('button', {name: '模块设置'});
|
const moduleSettings = tools.getByRole('button', {name: '模块设置'});
|
||||||
@@ -536,6 +560,11 @@ async function verifyHomeModules(context, page) {
|
|||||||
assert.equal(await module.getByRole('link', {name: '查看全部'}).getAttribute('href'), '/articles/feed/home/' + id);
|
assert.equal(await module.getByRole('link', {name: '查看全部'}).getAttribute('href'), '/articles/feed/home/' + id);
|
||||||
assert.equal(await publicPage.locator('#hero-directory a').nth(1).getAttribute('href'), '/pagepan#download');
|
assert.equal(await publicPage.locator('#hero-directory a').nth(1).getAttribute('href'), '/pagepan#download');
|
||||||
assert.equal(await publicPage.locator('#hero-directory a').nth(1).locator('small').textContent(), '编辑过的导航说明');
|
assert.equal(await publicPage.locator('#hero-directory a').nth(1).locator('small').textContent(), '编辑过的导航说明');
|
||||||
|
const publicDirectory = publicPage.locator('#hero-directory .hero-directory');
|
||||||
|
assert.equal(await publicDirectory.locator(':scope > a').count(), 4);
|
||||||
|
await verifyDirectoryWidth(publicDirectory);
|
||||||
|
await publicPage.setViewportSize({width: 390, height: 844});
|
||||||
|
await verifyDirectoryWidth(publicDirectory);
|
||||||
assert.equal(await publicPage.locator('#network #supported-projects').count(), 1);
|
assert.equal(await publicPage.locator('#network #supported-projects').count(), 1);
|
||||||
|
|
||||||
await page.bringToFront();
|
await page.bringToFront();
|
||||||
@@ -552,11 +581,19 @@ async function verifyHomeModules(context, page) {
|
|||||||
await publicPage.close();
|
await publicPage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function verifyDirectoryWidth(directory) {
|
||||||
|
assert(await directory.evaluate((node) => {
|
||||||
|
const rightEdge = node.getBoundingClientRect().right - node.clientLeft;
|
||||||
|
const lastLink = node.lastElementChild.getBoundingClientRect();
|
||||||
|
return Math.abs(rightEdge - lastLink.right) < 1;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
||||||
try {
|
try {
|
||||||
await run(browser);
|
await run(browser);
|
||||||
console.log('Passed Chromium dashboard, template library, dynamic module tools, homepage links, and scoped archives.');
|
console.log('Passed Chromium dashboard, template library, dynamic modules, homepage link reflow, scoped archives, and article deletion.');
|
||||||
} finally {
|
} finally {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user