fix(export): use default wallpaper for native background

This commit is contained in:
wiiiii123
2026-05-06 22:53:14 +07:00
parent ed103ed753
commit 978e913045
2 changed files with 26 additions and 3 deletions
@@ -53,6 +53,7 @@ function createExporter(overrides: Record<string, unknown> = {}) {
videoInfo: DecodedVideoInfo,
effectiveDurationSec: number,
) => string | null;
resolveNativeStaticLayoutBackground: () => Promise<unknown>;
};
}
@@ -190,6 +191,24 @@ describe("ModernVideoExporter native static-layout eligibility", () => {
).toBeNull();
});
it("uses the default wallpaper for native static-layout when the project has no wallpaper", async () => {
const exporter = createExporter({ wallpaper: "" });
const electronAPI = window.electronAPI as typeof window.electronAPI & {
getAssetBasePath: () => Promise<string>;
listAssetDirectory: () => Promise<{ success: true; files: string[] }>;
};
electronAPI.getAssetBasePath = vi.fn(async () => "file:///C:/Recordly/resources/");
electronAPI.listAssetDirectory = vi.fn(async () => ({
success: true,
files: ["tahoe-light.jpg"],
}));
await expect(exporter.resolveNativeStaticLayoutBackground()).resolves.toEqual({
backgroundColor: "#101010",
backgroundImagePath: "C:/Recordly/resources/wallpapers/tahoe-light.jpg",
});
});
it("allows non-tail trim timelines with native static-layout", () => {
const exporter = createExporter({
trimRegions: [{ id: "trim-1", startMs: 10_000, endMs: 12_000 }],
+7 -3
View File
@@ -40,7 +40,11 @@ import {
} from "@/components/video-editor/webcamOverlay";
import { extensionHost } from "@/lib/extensions";
import { getEffectiveVideoStreamDurationSeconds } from "@/lib/mediaTiming";
import { DEFAULT_WALLPAPER_RELATIVE_PATH, isVideoWallpaperSource } from "@/lib/wallpapers";
import {
DEFAULT_WALLPAPER_PATH,
DEFAULT_WALLPAPER_RELATIVE_PATH,
isVideoWallpaperSource,
} from "@/lib/wallpapers";
import { AudioProcessor, isAacAudioEncodingSupported } from "./audioEncoder";
import {
getDefaultLightningRenderBackend,
@@ -1261,7 +1265,8 @@ export class ModernVideoExporter {
}
private async resolveNativeStaticLayoutBackground(): Promise<NativeStaticLayoutBackground | null> {
const wallpaper = this.config.wallpaper?.trim() ?? "";
const configuredWallpaper = this.config.wallpaper?.trim() ?? "";
const wallpaper = configuredWallpaper || DEFAULT_WALLPAPER_PATH;
if (/^#?[0-9a-f]{6}$/i.test(wallpaper)) {
return {
backgroundColor: wallpaper.startsWith("#") ? wallpaper : `#${wallpaper}`,
@@ -1270,7 +1275,6 @@ export class ModernVideoExporter {
}
if (
!wallpaper ||
isVideoWallpaperSource(wallpaper) ||
wallpaper.startsWith("data:") ||
wallpaper.startsWith("blob:") ||