Skip to content

Commit 9ea4e2d

Browse files
committed
chore: release v1.16.1
1 parent 62e8d0f commit 9ea4e2d

10 files changed

Lines changed: 45 additions & 21 deletions

File tree

docs/changelog/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
55
---
66

7+
## v1.16.1 - 2026-07-26
8+
9+
### Fixed
10+
11+
- **详情页归档目录时区错位**:归档目录(`detailPathRule` 的年 / 年月 / 年月日 / 日期串规则)此前用裸 dayjs 按**操作系统本地时区**计算,而后台展示的发布时间走 `APP_TIME_ZONE``APP_TIME_ZONE``TZ``Asia/Shanghai` 兜底)。部署机时区与 `APP_TIME_ZONE` 不一致时(例如容器内 `TZ` 未设置、OS 为 UTC),跨年/跨月边界发布的内容会落进与后台显示不符的目录。现统一走 `APP_TIME_ZONE`,与 `formatDateTime()` 同源
12+
- **归档目录用例随时区漂移**`cms-urls.test.ts` 的日期夹具改用 `APP_TIME_ZONE` 正午构造,避开任意 runner 时区的日界,使断言与 CI/本地时区无关(该用例此前在 UTC runner 上暴露了上述真实缺陷)
13+
14+
---
15+
716
## v1.16.0 - 2026-07-26
817

918
[ChestnutCMS](https://github.com/liweiyi/ChestnutCMS) 为参照做了一轮完整的功能对标与架构瘦身:补齐 12 项经消费方核实的真实缺口,同时**移除发布通道**这一从 ChestnutCMS 直译、在响应式 React SSR 架构下已成负债的机制。

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenith-admin",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"workspaces": [
66
"packages/*"

packages/analytics-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenith/analytics-sdk",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"type": "module",
66
"sideEffects": false,

packages/electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenith/electron",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"description": "Zenith Admin Electron Client",
66
"author": "Zenith Admin",

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenith/server",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"type": "module",
66
"scripts": {

packages/server/src/services/cms/cms-urls.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { describe, expect, it } from 'vitest';
2-
import { formatDateTime } from '../../lib/datetime';
2+
import dayjs from 'dayjs';
3+
import timezone from 'dayjs/plugin/timezone';
4+
import utc from 'dayjs/plugin/utc';
5+
import { APP_TIME_ZONE, formatDateTime } from '../../lib/datetime';
36
import { contentArchiveDir, contentUrl } from './cms-urls';
47

5-
const AT = new Date(2026, 6, 5); // 2026-07-05(月/日单位数,用于验证补零差异)
8+
dayjs.extend(utc);
9+
dayjs.extend(timezone);
10+
11+
// 固定在 APP_TIME_ZONE 的正午构造,避开任何 runner 时区的日界,使字面断言与 TZ 无关
12+
// (用 new Date(2026, 6, 5) 会随 OS 时区漂移,CI 与本地结果不一致)
13+
const AT = dayjs.tz('2026-07-05 12:00:00', 'YYYY-MM-DD HH:mm:ss', APP_TIME_ZONE).toDate();
614

715
function content(overrides: Partial<Parameters<typeof contentUrl>[2]> = {}) {
816
return { id: 42, slug: null, publishedAt: AT, createdAt: AT, ...overrides };
@@ -36,8 +44,8 @@ describe('contentArchiveDir', () => {
3644
expect(contentArchiveDir('year', content({ publishedAt: null, createdAt: null }))).toBe('');
3745
});
3846

39-
it('取值口径与 formatDateTime 展示一致(同为 dayjs 本地时区)', () => {
40-
// 存的是 UTC 2023-12-31T16:00Z,在 UTC+8 下展示为 2024-01-01,归档目录须同为 2024
47+
it('取值口径与 formatDateTime 展示一致(同为 APP_TIME_ZONE,而非 OS 本地时区)', () => {
48+
// APP_TIME_ZONE 默认 Asia/Shanghai,部署机 TZ 未设置时裸 dayjs 会按 UTC 算,两者差一年
4149
const utcBoundary = new Date('2023-12-31T16:00:00.000Z');
4250
const displayedYear = Number(formatDateTime(utcBoundary).slice(0, 4));
4351
expect(contentArchiveDir('year', content({ publishedAt: utcBoundary }))).toBe(`${displayedYear}/`);
@@ -69,7 +77,7 @@ describe('contentUrl 与归档规则', () => {
6977
expect(contentUrl('', channel, c, 3)).toBe('/topic/2026/special_3.html');
7078
});
7179

72-
it('baseUrl 前缀参与拼接(预览 / 通道子树场景)', () => {
80+
it('baseUrl 前缀参与拼接(预览场景)', () => {
7381
expect(contentUrl('/__cms/main', channel, content())).toBe('/__cms/main/news/2026/42.html');
7482
});
7583

packages/server/src/services/cms/cms-urls.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
* 现有 `from './cms-render.service'` 的导入无需改动。
77
*/
88
import dayjs from 'dayjs';
9+
import timezone from 'dayjs/plugin/timezone';
10+
import utc from 'dayjs/plugin/utc';
911
import { cmsCustomPagePath } from '@zenith/shared';
1012
import type { CmsChannelDetailPathRule } from '@zenith/shared';
13+
import { APP_TIME_ZONE } from '../../lib/datetime';
14+
15+
dayjs.extend(utc);
16+
dayjs.extend(timezone);
1117

1218
/** 搭建页 URL / 静态产物路径:设了 path 用它,否则回落 p/{slug}/ */
1319
export { cmsCustomPagePath as customPagePath } from '@zenith/shared';
@@ -64,16 +70,17 @@ function pad2(n: number): string {
6470
/**
6571
* 归档目录片段(含结尾 `/`;不归档返回空串)。
6672
*
67-
* 日期取值口径与全站展示一致:走 dayjs 本地时区,和 `formatDateTime()` 呈现的发布时间同源,
68-
* 因此运营在后台看到「发布时间 2024-01-01」时,产物就落在 `2024/` 下,不会出现错位一天的困惑。
73+
* 日期取值口径必须与全站展示一致 —— 走 `APP_TIME_ZONE`(与 `formatDateTime()` 同源),
74+
* 而**不是** OS 本地时区:`APP_TIME_ZONE` 有 `Asia/Shanghai` 兜底,部署机时区不同时
75+
* 裸 dayjs 会和后台显示的发布时间差一年/一月,产出与运营预期不符的产物路径。
6976
* 未发布时回退创建时间;两者都缺失则退化为不归档,保证任何数据状态下都能算出稳定路径。
7077
*/
7178
export function contentArchiveDir(rule: CmsChannelDetailPathRule, content: CmsUrlContent): string {
7279
if (rule === 'none') return '';
7380
if (rule === 'idHash') return `${Math.abs(content.id) % 10}/`;
7481
const at = content.publishedAt ?? content.createdAt;
7582
if (!at) return '';
76-
const d = dayjs(at);
83+
const d = dayjs(at).tz(APP_TIME_ZONE);
7784
if (!d.isValid()) return '';
7885
const y = d.year();
7986
const m = d.month() + 1;

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenith/shared",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"type": "module",
66
"sideEffects": false,

packages/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenith/web",
3-
"version": "1.16.0",
3+
"version": "1.16.1",
44
"private": true,
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)