Skip to content

Commit b7ca00d

Browse files
committed
Optimize: Refine PWA install component configuration for Document Editor
1 parent cf24304 commit b7ca00d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,21 @@ const initPwaInstall = () => {
9393
const pwaInstall = document.createElement('pwa-install');
9494
pwaInstall.id = 'pwa-install';
9595

96+
// Optimization: Only use attributes that enhance the specific project experience
97+
// Use local storage to avoid showing the prompt too often
98+
pwaInstall.setAttribute('use-local-storage', '');
99+
100+
// Professional branding
101+
pwaInstall.setAttribute('name', 'Document Editor');
102+
pwaInstall.setAttribute('description', 'A privacy-focused, local web-based document editor.');
103+
pwaInstall.setAttribute('install-description', 'Install the App for a better offline experience and quick access.');
104+
96105
// Use the browser's native resolution from the existing link tags
97-
// This is the most elegant and "Single Source of Truth" way
98106
const manifest = document.querySelector<HTMLLinkElement>('link[rel="manifest"]');
99107
const icon = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
100-
console.log(manifest?.href, icon?.href);
108+
101109
if (manifest?.href) pwaInstall.setAttribute('manifest-url', manifest.href);
102-
if (icon?.href) pwaInstall.setAttribute('icon-url', icon.href);
110+
if (icon?.href) pwaInstall.setAttribute('icon', icon.href);
103111

104112
document.body.appendChild(pwaInstall);
105113
};

0 commit comments

Comments
 (0)