perf: optimize app startup and background lifecycles

This commit is contained in:
inman committed 2026-08-19 00:56:15 +08:00
1 parent 31332f6d76
commit 927e13349b
121 files changed
+4359 -1400

No files matched your search

+7 -48
View File
@@ -84,66 +84,25 @@ test.describe('Makelore module navigation without setup flow', () => {
expect(resizedMetrics[0]!.imageWidth).toBeLessThan(resizedMetrics[0]!.width / 2);
expect(resizedMetrics[0]!.imageHeight).toBeGreaterThan(resizedMetrics[0]!.height * 0.75);
await page.mouse.move(20, 20);
const restingTransforms = await moduleCards.first().evaluate((element) => {
const surface = element.querySelector<HTMLElement>('.module-option-card-surface');
const image = element.querySelector<HTMLElement>('.module-option-card-image');
const imageMedia = element.querySelector<HTMLElement>('.module-option-card-image-media');
const content = element.querySelector<HTMLElement>('.module-option-card-content');
const title = element.querySelector<HTMLElement>('.module-option-card-title');
return {
surfaceShadow: surface ? getComputedStyle(surface).boxShadow : 'none',
image: image ? getComputedStyle(image).transform : 'none',
imageMedia: imageMedia ? getComputedStyle(imageMedia).transform : 'none',
content: content ? getComputedStyle(content).transform : 'none',
title: title ? getComputedStyle(title).transform : 'none',
};
});
await moduleCards.first().hover();
await moduleCards.first().focus();
await expect.poll(async () => await moduleCards.first().evaluate((element, rest) => {
await expect.poll(async () => await moduleCards.first().evaluate((element) => {
const surface = element.querySelector<HTMLElement>('.module-option-card-surface');
const image = element.querySelector<HTMLElement>('.module-option-card-image');
const imageMedia = element.querySelector<HTMLElement>('.module-option-card-image-media');
const content = element.querySelector<HTMLElement>('.module-option-card-content');
const title = element.querySelector<HTMLElement>('.module-option-card-title');
const description = element.querySelector<HTMLElement>('.module-option-card-description');
const getTranslateZ = (transform: string) => {
if (!transform.startsWith('matrix3d(')) return 0;
const values = transform.slice(9, -1).split(',').map(Number);
return values[14] ?? 0;
};
const titleTransform = title ? getComputedStyle(title).transform : 'none';
const descriptionTransform = description ? getComputedStyle(description).transform : 'none';
return Boolean(surface)
&& Boolean(image)
&& Boolean(imageMedia)
&& Boolean(content)
&& Boolean(title)
&& Boolean(description)
&& getComputedStyle(surface).transform !== 'none'
&& getComputedStyle(surface).boxShadow !== rest.surfaceShadow
&& getComputedStyle(surface).borderTopColor === 'rgb(255, 255, 255)'
&& getComputedStyle(image).transform !== 'none'
&& getComputedStyle(imageMedia).transform !== 'none'
&& getComputedStyle(content).transform !== 'none'
&& titleTransform !== 'none'
&& descriptionTransform !== 'none'
&& getTranslateZ(titleTransform) > getTranslateZ(descriptionTransform) + 20;
}, restingTransforms)).toBe(true);
await expect.poll(async () => await moduleCards.first().evaluate((element, rest) => {
const image = element.querySelector<HTMLElement>('.module-option-card-image');
const imageMedia = element.querySelector<HTMLElement>('.module-option-card-image-media');
const content = element.querySelector<HTMLElement>('.module-option-card-content');
const title = element.querySelector<HTMLElement>('.module-option-card-title');
return Boolean(image && imageMedia && content && title)
&& getComputedStyle(image!).transform !== rest.image
&& getComputedStyle(imageMedia!).transform !== rest.imageMedia
&& getComputedStyle(content!).transform !== rest.content
&& getComputedStyle(title!).transform !== rest.title;
}, restingTransforms)).toBe(true);
&& getComputedStyle(surface).transform === 'none'
&& getComputedStyle(image).transform === 'none'
&& getComputedStyle(imageMedia).transform === 'none'
&& getComputedStyle(content).transform === 'none'
&& getComputedStyle(title).transform === 'none';
})).toBe(true);
} finally {
await closeElectronApp(app);
}