已将业务时间生成入口统一为 Asia/Shanghai,不依赖服务器默认时区
This commit is contained in:
+13
-13
@@ -87,7 +87,7 @@
|
||||
### 2.2 时间和公共类型
|
||||
|
||||
```ts
|
||||
type UtcDateTime = string;
|
||||
type ShanghaiDateTime = string;
|
||||
|
||||
interface ApiResponse<T> {
|
||||
code: string;
|
||||
@@ -104,11 +104,11 @@ interface PageResponse<T> {
|
||||
}
|
||||
```
|
||||
|
||||
`createdAt`、`updatedAt`、`publishedAt`、`expiresAt`、`startedAt`、`finishedAt` 为 UTC 时间字符串,例如 `2026-10-20T02:30:00.123`,当前没有时区后缀。前端按 UTC 解析后再格式化为本地时间,不能直接当作北京时间。提交历史的 `authorDate` 沿用 Git 日期,可能自带 `Z` 或时区偏移。
|
||||
`createdAt`、`updatedAt`、`publishedAt`、`expiresAt`、`startedAt`、`finishedAt` 为上海时间(`Asia/Shanghai`,UTC+8)字符串,例如 `2026-10-20T10:30:00.123`,当前没有时区后缀。前端应补充 `+08:00` 后解析,再格式化为用户本地时间;不能继续补 `Z`,也不能依赖浏览器默认时区。前后端需同时切换时间约定,避免多显示 8 小时。提交历史的 `authorDate` 沿用 Git 日期,可能自带 `Z` 或时区偏移。
|
||||
|
||||
```ts
|
||||
function parseServerTime(value: string): Date {
|
||||
return new Date(/(?:Z|[+-]\d{2}:?\d{2})$/i.test(value) ? value : `${value}Z`);
|
||||
return new Date(/(?:Z|[+-]\d{2}:?\d{2})$/i.test(value) ? value : `${value}+08:00`);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -281,7 +281,7 @@ interface UserView {
|
||||
status: UserStatus;
|
||||
role: UserRole;
|
||||
projectCount: number; // 名下未删除项目数
|
||||
createdAt: UtcDateTime;
|
||||
createdAt: ShanghaiDateTime;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -349,7 +349,7 @@ interface ProjectView {
|
||||
repoStatus: RepoStatus;
|
||||
publishStatus: PublishStatus;
|
||||
publishedCommitSha: string | null;
|
||||
publishedAt: UtcDateTime | null;
|
||||
publishedAt: ShanghaiDateTime | null;
|
||||
sourceProjectCode: string | null;
|
||||
sourceCommitSha: string | null;
|
||||
likeCount: number;
|
||||
@@ -357,8 +357,8 @@ interface ProjectView {
|
||||
liked: boolean;
|
||||
sourceRepositoryUrl: string | null;
|
||||
sourceLicense: string | null;
|
||||
createdAt: UtcDateTime;
|
||||
updatedAt: UtcDateTime;
|
||||
createdAt: ShanghaiDateTime;
|
||||
updatedAt: ShanghaiDateTime;
|
||||
}
|
||||
|
||||
interface ManagedProjectView {
|
||||
@@ -711,7 +711,7 @@ interface CoverUploadSignature {
|
||||
uploadUrl: string;
|
||||
objectKey: string;
|
||||
coverUrl: string;
|
||||
expiresAt: UtcDateTime;
|
||||
expiresAt: ShanghaiDateTime;
|
||||
formFields: Record<string, string>;
|
||||
}
|
||||
```
|
||||
@@ -771,7 +771,7 @@ interface UrdfUploadSignature {
|
||||
batchCode: string;
|
||||
mainRelativePath: string;
|
||||
uploadUrl: string;
|
||||
expiresAt: UtcDateTime;
|
||||
expiresAt: ShanghaiDateTime;
|
||||
files: UrdfFileSignature[];
|
||||
}
|
||||
```
|
||||
@@ -849,7 +849,7 @@ interface ResourceFile { relativePath: string; sizeBytes: number }
|
||||
interface ResourceUploadSignature {
|
||||
batchCode: string;
|
||||
uploadUrl: string;
|
||||
expiresAt: UtcDateTime;
|
||||
expiresAt: ShanghaiDateTime;
|
||||
files: { relativePath: string; objectKey: string; formFields: Record<string, string> }[];
|
||||
}
|
||||
|
||||
@@ -1026,9 +1026,9 @@ interface TaskView {
|
||||
canRetry: boolean;
|
||||
retryMessage: string | null;
|
||||
warnings: string[];
|
||||
createdAt: UtcDateTime;
|
||||
startedAt: UtcDateTime | null;
|
||||
finishedAt: UtcDateTime | null;
|
||||
createdAt: ShanghaiDateTime;
|
||||
startedAt: ShanghaiDateTime | null;
|
||||
finishedAt: ShanghaiDateTime | null;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user