feat(W4): 站点path全链路-portalUrlOf/previewPortalUrl纯函数,站点列/向导地址预览/预览frame sitePath,store携带path,mock嵌套路由,T-W4-16..18 绿51/51
This commit is contained in:
@@ -21,7 +21,7 @@ vi.mock("@/utils/alova/alova-iview", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
import { articleApi, assetUrl } from "./cms";
|
||||
import { articleApi, assetUrl, themePreviewUrl } from "./cms";
|
||||
import { alovaInstance } from "@/utils/alova/alova-iview";
|
||||
|
||||
const JSON_HEADERS = { "Content-Type": "application/json;charset=UTF-8" };
|
||||
@@ -99,3 +99,13 @@ describe("assetUrl 站内资产路径补 serviceHost 前缀(线上主题截图
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("themePreviewUrl 参数语义(T-W4-17:W4 起 sitePath)", () => {
|
||||
it("query 携带 sitePath(嵌套路径 URL 编码)与 p_ 前缀参数", () => {
|
||||
const url = themePreviewUrl("sch-3/jdxy", "t-demo-red", { primary: "#b01a2e" });
|
||||
expect(url).toContain("sitePath=sch-3%2Fjdxy");
|
||||
expect(url).toContain("theme=t-demo-red");
|
||||
expect(url).toContain("p_primary=%23b01a2e");
|
||||
expect(url).not.toContain("siteCode=");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -214,9 +214,10 @@ class ThemeApi {
|
||||
}
|
||||
}
|
||||
|
||||
/** 主题预览 iframe URL(方案 §5.5:/api/theme/preview,CAS 会话同源,参数 p_ 前缀) */
|
||||
export function themePreviewUrl(siteCode: string, theme: string, themeParams: Record<string, string> = {}): string {
|
||||
const params = new URLSearchParams({ siteCode, theme, page: "home" });
|
||||
/** 主题预览 iframe URL(方案 §5.5:/api/theme/preview,CAS 会话同源,参数 p_ 前缀)。
|
||||
* W4:内容源站点参数 sitePath(嵌套路径语义,后端 siteSnapshotByPath 解析)。 */
|
||||
export function themePreviewUrl(sitePath: string, theme: string, themeParams: Record<string, string> = {}): string {
|
||||
const params = new URLSearchParams({ sitePath, theme, page: "home" });
|
||||
Object.keys(themeParams).forEach(k => params.set(`p_${k}`, themeParams[k]));
|
||||
return `${conf.isMock ? "" : conf.serviceHost}/api/theme/preview?${params.toString()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user