fix: 修复预览 loading 与媒体代理
This commit is contained in:
1 parent
18ddf125be
commit
0574a85632
4 files changed
+37
-3
No files matched your search
@@ -82,6 +82,19 @@ export default defineConfig({
|
|||||||
h5: {
|
h5: {
|
||||||
publicPath: process.env.PREVIEW_PUBLIC_PATH || "/",
|
publicPath: process.env.PREVIEW_PUBLIC_PATH || "/",
|
||||||
router: { mode: "hash" },
|
router: { mode: "hash" },
|
||||||
devServer: { host: "0.0.0.0", port: Number(process.env.PREVIEW_PORT || 3002) },
|
devServer: {
|
||||||
|
host: "0.0.0.0",
|
||||||
|
port: Number(process.env.PREVIEW_PORT || 3002),
|
||||||
|
proxy: {
|
||||||
|
"/media": {
|
||||||
|
target:
|
||||||
|
process.env.MEDIA_API_TARGET ||
|
||||||
|
(process.env.API_BASE_URL?.startsWith("http")
|
||||||
|
? new URL(process.env.API_BASE_URL).origin
|
||||||
|
: "http://localhost:3001"),
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -43,7 +43,7 @@ export function WorkspaceProvider({ children }: PropsWithChildren) {
|
|||||||
.catch((error: unknown) =>
|
.catch((error: unknown) =>
|
||||||
setError(error instanceof Error ? error.message : "加载失败,请重试"),
|
setError(error instanceof Error ? error.message : "加载失败,请重试"),
|
||||||
)
|
)
|
||||||
.finally(() => setLoading(!editorPreview));
|
.finally(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(reload, [reload]);
|
useEffect(reload, [reload]);
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -83,14 +83,31 @@ test("加载失败提供重试", async ({ page }) => {
|
|||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
await expect(page.getByText("测试服务暂不可用")).toBeVisible();
|
await expect(page.getByText("测试服务暂不可用")).toBeVisible();
|
||||||
await expect(page.getByText("重试")).toBeVisible();
|
await expect(page.getByText("重试")).toBeVisible();
|
||||||
|
await page.unroute("**/public/workspace**");
|
||||||
|
const response = page.waitForResponse((response) => response.url().includes("/public/workspace"));
|
||||||
|
await page.getByText("重试", { exact: true }).click();
|
||||||
|
expect((await response).ok()).toBe(true);
|
||||||
|
await expect(page.locator(".runtime-state")).toHaveCount(0);
|
||||||
|
await expect(page.locator("[data-editor-target]").first()).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("林境模板使用真实品牌数据与独立路由", async ({ page }) => {
|
test("林境模板使用真实品牌数据与独立路由", async ({ page }) => {
|
||||||
const errors: string[] = [];
|
const errors: string[] = [];
|
||||||
page.on("pageerror", (error) => errors.push(error.message));
|
page.on("pageerror", (error) => errors.push(error.message));
|
||||||
await page.goto("http://localhost:3003/");
|
await page.goto("http://localhost:3003/#/pages/home/index");
|
||||||
await expect(page.locator(".founder-name")).toContainText("林");
|
await expect(page.locator(".founder-name")).toContainText("林");
|
||||||
await expect(page.locator(".stat-value")).toHaveCount(4);
|
await expect(page.locator(".stat-value")).toHaveCount(4);
|
||||||
|
await expect
|
||||||
|
.poll(() =>
|
||||||
|
page
|
||||||
|
.locator(".editorial-home img")
|
||||||
|
.evaluateAll(
|
||||||
|
(images) =>
|
||||||
|
images.length > 0 &&
|
||||||
|
images.every((image) => (image as HTMLImageElement).naturalWidth > 0),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toBe(true);
|
||||||
await page.getByText("主理人与我", { exact: true }).click();
|
await page.getByText("主理人与我", { exact: true }).click();
|
||||||
await expect(page.locator(".editorial-profile .founder")).toBeVisible();
|
await expect(page.locator(".editorial-profile .founder")).toBeVisible();
|
||||||
await expect(page.locator(".trust-card").first()).toBeVisible();
|
await expect(page.locator(".trust-card").first()).toBeVisible();
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ CI 可执行 pnpm test:template-doctor 和诊断命令。新模板自动扫描
|
|||||||
|
|
||||||
## 保存与预览补充
|
## 保存与预览补充
|
||||||
|
|
||||||
|
独立 H5 预览须覆盖真实公开数据加载、失败提示及重试恢复;请求成功或失败后都必须退出 loading,不能仅以 tabbar 出现判定页面可用。编辑器预览继续等待 workspaceDraft,不得因公开请求结束而提前显示失败。
|
||||||
|
|
||||||
|
H5 开发预览的 `/media` 请求须代理至 API 媒体服务,默认 `http://localhost:3001`,可通过 `MEDIA_API_TARGET` 覆盖,或从绝对地址 `API_BASE_URL` 推导 origin。图片回归检查实际加载尺寸,不能只检查图片节点存在;生产环境仍由部署网关提供 `/media` 路由。
|
||||||
|
|
||||||
保存请求仅包含允许修改的字段及新配置。禁止在新 config 后展开带旧 config 的完整品牌对象,禁止内容编辑携带 visualTemplateKey 触发模板切换权限。共享表单保存须保留跨区域修改。
|
保存请求仅包含允许修改的字段及新配置。禁止在新 config 后展开带旧 config 的完整品牌对象,禁止内容编辑携带 visualTemplateKey 触发模板切换权限。共享表单保存须保留跨区域修改。
|
||||||
|
|
||||||
Admin 预览读取当前品牌的草稿 Runtime,公开接口读取已发布快照。两者共用投影逻辑;保存后预览、重新加载预览、发布后公开读取必须分别测试。不得用 mock 返回最新数据掩盖真实预览接口仍读旧发布快照。
|
Admin 预览读取当前品牌的草稿 Runtime,公开接口读取已发布快照。两者共用投影逻辑;保存后预览、重新加载预览、发布后公开读取必须分别测试。不得用 mock 返回最新数据掩盖真实预览接口仍读旧发布快照。
|
||||||
|
|||||||
Reference in new issue
Block a user