实现网站游戏评分与评价 (#561)
Project CI / AI game creator shell Rust crates (push) Successful in 1m43s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m7s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m55s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m23s
Project CI / Frontend tests (push) Successful in 3m3s
Project CI / Repository checks (push) Successful in 3m42s
Project CI / AI game creator shell web tests (push) Successful in 2m3s
Project CI / Backend tests (push) Successful in 6m19s
Project CI / Native shell tests (push) Successful in 8m7s

公开游戏详情页新增评分与评价:登录用户可提交并修改自己对每款游戏的唯一一条 1–10 分评价,评论可空且最多 4000 个 Unicode 码点;游客可分页浏览评价并查看平均分与评分人数。

- 新增私有评价表及共享 DTO/API,事务内校验游戏公开可见性、保证唯一性,并计算分页与全量评分统计;下架或封禁后关闭读写,重新公开及更新版本保留评价。
- 详情页支持编辑预填、取消、提交期间冻结输入、失败保留草稿,以及保存、翻页和账号/游戏切换时的旧响应隔离;复用现有认证与公共组件。
- 同步主规范、里程碑、实施计划、生成绑定、表目录和验收脚本。不扩展 AGC、外部 API、评论审核或评分缓存。

验证:
- 本轮审查复跑前端定向测试 40 项、评价领域测试 2 项,均通过。
- 网站 typecheck、Rust/TypeScript DTO 对齐、SpacetimeDB schema、文档索引、编码与 diff 检查通过。
- 实施文档另记录本地隔离数据库/API 49 项及桌面/移动视口浏览器 smoke 通过;本轮审查未重跑这些运行时验收,也未运行完整测试套件。

发布说明:新增 SpacetimeDB 表,部署时需同步 module 与 API。尚未部署 dev/production,待用户验收。

Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/561
Co-authored-by: Linghong <ink29535@proton.me>
Co-committed-by: Linghong <ink29535@proton.me>
This commit was merged in pull request #561.
This commit is contained in:
2026-10-01 19:19:58 +08:00
committed by 孔令弘
parent 44f415d057
commit b60aea4e71
81 changed files with 8594 additions and 60 deletions
@@ -5,12 +5,16 @@ import {
executeAdminRechargeRefund,
getAdminAgcTemplates,
getAdminFeatureGateConfig,
getAdminGameReview,
getAdminUserDetail,
importAdminAgcTemplates,
listAdminAgcTrackingEvents,
listAdminGameDistributionGames,
listAdminGameDistributionReviews,
listAdminGameReviewGames,
listAdminGameReviews,
listAdminRechargeOrders,
moderateAdminGameReview,
reconcileAdminUserConsumption,
resolveAdminRechargeRefundManualReview,
restoreAdminGameDistributionGame,
@@ -27,6 +31,52 @@ afterEach(() => {
vi.unstubAllGlobals();
});
test('用户评价查询编码筛选和目标,管理请求携带原创建时间及幂等key', async () => {
const fetchMock = vi
.fn()
.mockImplementation(
async () =>
new Response(JSON.stringify({ ok: true, data: {} }), { status: 200 }),
);
vi.stubGlobal('fetch', fetchMock);
await listAdminGameReviews('token', {
gameId: 'game+1',
userId: 'user/1',
keyword: '中文 广告',
status: 'hidden',
page: 2,
pageSize: 20,
});
expect(fetchMock.mock.calls[0]![0]).toBe(
'/admin/api/game-distribution/user-reviews?gameId=game%2B1&userId=user%2F1&keyword=%E4%B8%AD%E6%96%87+%E5%B9%BF%E5%91%8A&status=hidden&page=2&pageSize=20',
);
await listAdminGameReviewGames('token', { query: ' 中文 ', page: 1 });
expect(fetchMock.mock.calls[1]![0]).toBe(
'/admin/api/game-distribution/user-review-games?query=%E4%B8%AD%E6%96%87&page=1',
);
await getAdminGameReview('token', '6:game/1user');
expect(fetchMock.mock.calls[2]![0]).toBe(
'/admin/api/game-distribution/user-reviews/6%3Agame%2F1user',
);
const body = {
action: 'delete' as const,
expectedCreatedAt: '2026-10-01T00:00:00Z',
reason: '广告',
};
await moderateAdminGameReview('token', '6:game/1user', 'same-attempt', body);
expect(fetchMock).toHaveBeenLastCalledWith(
'/admin/api/game-distribution/user-reviews/6%3Agame%2F1user/moderation',
expect.objectContaining({
method: 'POST',
headers: expect.objectContaining({
Authorization: 'Bearer token',
'Idempotency-Key': 'same-attempt',
}),
body: JSON.stringify(body),
}),
);
});
test('客户端埋点查询传递筛选和游标并复用后台认证', async () => {
const payload = { entries: [], nextCursor: null };
const fetchMock = vi.fn().mockResolvedValue(
+62
View File
@@ -38,6 +38,13 @@ import type {
AdminGameDistributionReviewListResponse,
AdminGameDistributionReviewRequest,
AdminGameDistributionReviewResponse,
AdminGameReviewDetailResponse,
AdminGameReviewGamesQuery,
AdminGameReviewGamesResponse,
AdminGameReviewModerationRequest,
AdminGameReviewModerationResponse,
AdminGameReviewsQuery,
AdminGameReviewsResponse,
AdminImportAgcTemplatesResponse,
AdminLoginResponse,
AdminMeResponse,
@@ -1243,6 +1250,61 @@ export function listAdminGameDistributionReviews(token: string, limit = 48) {
);
}
function gameReviewQuery(
query: AdminGameReviewGamesQuery | AdminGameReviewsQuery,
) {
const params = new URLSearchParams();
for (const [key, value] of Object.entries(query)) {
if (value !== undefined && String(value).trim())
params.set(key, String(value).trim());
}
return params.toString();
}
export function listAdminGameReviewGames(
token: string,
query: AdminGameReviewGamesQuery = {},
) {
return request<AdminGameReviewGamesResponse>(
`/admin/api/game-distribution/user-review-games?${gameReviewQuery(query)}`,
{ token },
);
}
export function listAdminGameReviews(
token: string,
query: AdminGameReviewsQuery = {},
) {
return request<AdminGameReviewsResponse>(
`/admin/api/game-distribution/user-reviews?${gameReviewQuery(query)}`,
{ token },
);
}
export function getAdminGameReview(token: string, reviewId: string) {
return request<AdminGameReviewDetailResponse>(
`/admin/api/game-distribution/user-reviews/${encodeURIComponent(reviewId)}`,
{ token },
);
}
export function moderateAdminGameReview(
token: string,
reviewId: string,
idempotencyKey: string,
payload: AdminGameReviewModerationRequest,
) {
return request<AdminGameReviewModerationResponse>(
`/admin/api/game-distribution/user-reviews/${encodeURIComponent(reviewId)}/moderation`,
{
token,
method: 'POST',
headers: { 'Idempotency-Key': idempotencyKey },
body: payload,
},
);
}
export function listAdminGameDistributionGames(
token: string,
options: { limit?: number } = {},
+84
View File
@@ -1186,6 +1186,90 @@ export interface AdminGameDistributionRestoreResponse {
replayed: boolean;
}
/** 游戏用户评价管理,与发行版本审核分开。 */
export interface AdminGameReviewGamesQuery {
query?: string;
page?: number;
pageSize?: number;
}
export interface AdminGameReviewGame {
gameId: string;
title: string;
status: string;
}
export interface AdminGameReviewGamesResponse {
games: AdminGameReviewGame[];
page: number;
pageSize: number;
total: number;
totalPages: number;
}
export interface AdminGameReviewsQuery {
gameId?: string;
userId?: string;
keyword?: string;
status?: 'all' | 'visible' | 'hidden';
page?: number;
pageSize?: number;
}
export interface AdminGameReviewGameInfo {
title: string;
status: string;
}
export interface AdminGameReview {
id: string;
gameId: string;
game: AdminGameReviewGameInfo;
author: { id: string; name: string; avatarUrl?: string | null };
score: number;
comment: string;
isHidden: boolean;
createdAt: string;
updatedAt: string;
}
export interface AdminGameReviewOperation {
id: string;
reviewId: string;
gameId: string;
userId: string;
reviewCreatedAt: string;
action: string;
adminUserId: string;
reason: string | null;
createdAt: string;
}
export interface AdminGameReviewsResponse {
reviews: AdminGameReview[];
page: number;
pageSize: number;
total: number;
totalPages: number;
}
export interface AdminGameReviewDetailResponse {
review: AdminGameReview;
operations: AdminGameReviewOperation[];
}
export interface AdminGameReviewModerationRequest {
action: 'hide' | 'restore' | 'delete';
expectedCreatedAt: string;
reason?: string;
}
export interface AdminGameReviewModerationResponse {
review: AdminGameReview | null;
operation: AdminGameReviewOperation;
replayed: boolean;
}
export interface AdminAgcTemplatePayload {
id: string;
title: string;