feat: 集成PWA基础配置,支持用户以类App形式打开项目

Note: 暂未实现缓存、离线等进阶PWA功能
This commit is contained in:
dingning
2025-10-30 17:45:38 +08:00
parent 43a80cf308
commit 1ca082bdf0
3 changed files with 40 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8"/>
<link rel="icon" type="image/svg+xml" href="/favicon.png"/>
<link rel="manifest" href="/manifest.json">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Type Words - 词文记 | 单词跟打 · 文章跟打</title>
<!-- 搜索引擎描述 -->
@@ -77,5 +78,16 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(error => {
console.log('ServiceWorker registration failed: ', error);
});
});
}
</script>
</body>
</html>