feat(route-detail): 实现路线详情独立管理全链路功能
添加`DetailRecord`数据库模型、迁移脚本及完整的CRUD管理接口,将路线详情从玩法路线表解耦,实现独立存储。 在Admin UI的路线编辑器中集成详情配置面板,支持编辑详情文案、图片等展示内容。 完善MiniAPP路线详情页,新增导航函数、API调用及数据归一化逻辑,并添加对应单元测试。 更新所有相关文档,明确领域边界、联调流程及接口契约规范。 调整首页和玩法页的点击跳转逻辑,优先跳转路线详情页而非原需求页。 新增数值格式化工具函数优化内容展示效果。
This commit is contained in:
1 parent
7ba92f3c5d
commit
c143b67275
32 files changed
+1343
-259
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
findWanfaRouteDetailFallback,
|
||||
normalizeDetailPresentation,
|
||||
} from "@/pages/detail/components/detailPresentation";
|
||||
|
||||
describe("wanfa route detail presentation", () => {
|
||||
it("normalizes a complete public response", () => {
|
||||
expect(
|
||||
normalizeDetailPresentation({
|
||||
key: "family-water",
|
||||
eyebrow: " 玩法推荐 ",
|
||||
duration: " 5天4晚 ",
|
||||
title: " 亲子玩水 ",
|
||||
subtitle: " 贵州路线 ",
|
||||
intro: " 沿着山地深入探索。 ",
|
||||
highlights: [" 核心景观串联 ", "", " 小团出行 "],
|
||||
included: [" 行程内用车 "],
|
||||
excluded: [" 往返大交通 "],
|
||||
notes: [" 请准备雨具。 "],
|
||||
gallery: [" https://example.test/cover.jpg "],
|
||||
}),
|
||||
).toEqual({
|
||||
key: "family-water",
|
||||
eyebrow: "玩法推荐",
|
||||
duration: "5天4晚",
|
||||
title: "亲子玩水",
|
||||
subtitle: "贵州路线",
|
||||
intro: "沿着山地深入探索。",
|
||||
highlights: ["核心景观串联", "小团出行"],
|
||||
included: ["行程内用车"],
|
||||
excluded: ["往返大交通"],
|
||||
notes: ["请准备雨具。"],
|
||||
gallery: ["https://example.test/cover.jpg"],
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the route fallback for invalid or incomplete API data", () => {
|
||||
const fallback = findWanfaRouteDetailFallback("family-water");
|
||||
|
||||
expect(fallback).not.toBeNull();
|
||||
expect(
|
||||
normalizeDetailPresentation(
|
||||
{ key: "family-water", title: "", gallery: [] },
|
||||
fallback,
|
||||
),
|
||||
).toEqual(fallback);
|
||||
});
|
||||
|
||||
it("returns no fallback for an unknown route", () => {
|
||||
expect(findWanfaRouteDetailFallback("missing-route")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { goWanfaRouteDetail } from "@/lib/navigation";
|
||||
|
||||
describe("wanfa route detail navigation", () => {
|
||||
const navigateTo = vi.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
navigateTo.mockReset();
|
||||
vi.stubGlobal("uni", { navigateTo });
|
||||
});
|
||||
|
||||
it("encodes the route id in the detail page URL", () => {
|
||||
goWanfaRouteDetail("family water");
|
||||
|
||||
expect(navigateTo).toHaveBeenCalledWith({
|
||||
url: "/pages/detail/index?routeId=family%20water",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user