fix: 修复预览 loading 与媒体代理

This commit is contained in:
que01 committed 2026-10-12 15:31:25 +08:00
1 parent 18ddf125be
commit 0574a85632
4 files changed
+37 -3

No files matched your search

+14 -1
View File
@@ -82,6 +82,19 @@ export default defineConfig({
h5: {
publicPath: process.env.PREVIEW_PUBLIC_PATH || "/",
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,
},
},
},
},
});
+1 -1
View File
@@ -43,7 +43,7 @@ export function WorkspaceProvider({ children }: PropsWithChildren) {
.catch((error: unknown) =>
setError(error instanceof Error ? error.message : "加载失败,请重试"),
)
.finally(() => setLoading(!editorPreview));
.finally(() => setLoading(false));
}, []);
useEffect(reload, [reload]);
return (
+18 -1
View File
@@ -83,14 +83,31 @@ test("加载失败提供重试", async ({ page }) => {
await page.goto("/");
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 }) => {
const errors: string[] = [];
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(".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 expect(page.locator(".editorial-profile .founder")).toBeVisible();
await expect(page.locator(".trust-card").first()).toBeVisible();