feat: 添加PWA支持,支持离线访问和添加到主屏幕

This commit is contained in:
System Administrator
2026-03-28 00:47:13 +07:00
parent d437580500
commit 8ffadc8604
5 changed files with 172 additions and 2 deletions
+23 -2
View File
@@ -1,9 +1,16 @@
<!doctype html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#1890ff" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="apple-mobile-web-app-title" content="轻远ERP" />
<meta name="description" content="轻远电力老挝分公司财务管理系统" />
<link rel="manifest" href="/manifest.json" />
<link rel="apple-touch-icon" href="/logo.png" />
<title>轻远电力老挝ERP - Qingyuan Power Laos</title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
@@ -12,5 +19,19 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
// 注册 Service Worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('SW registered:', registration);
})
.catch((error) => {
console.log('SW registration failed:', error);
});
});
}
</script>
</body>
</html>