109 lines
3.6 KiB
HTML
109 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
|
|
|
<!-- iOS 图标和应用配置 -->
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<meta name="apple-mobile-web-app-title" content="My PWA">
|
|
|
|
<!-- iOS 专用图标 -->
|
|
<link rel="apple-touch-icon" sizes="76x76" href="icons/76x76.png">
|
|
<link rel="apple-touch-icon" sizes="120x120" href="icons/120x120.png">
|
|
<link rel="apple-touch-icon" sizes="152x152" href="icons/152x152.png">
|
|
<link rel="apple-touch-icon" sizes="167x167" href="icons/167x167.png">
|
|
<link rel="apple-touch-icon" sizes="180x180" href="icons/180x180.png">
|
|
|
|
<!-- 通用图标配置 -->
|
|
<link rel="icon" type="image/png" sizes="40x40" href="icons/40x40.png">
|
|
<link rel="icon" type="image/png" sizes="20x20" href="icons/20x20.png">
|
|
<link rel="manifest" href="manifest.json">
|
|
<link rel="mask-icon" href="icons/safari-pinned-tab.svg" color="#2196f3">
|
|
<meta name="msapplication-TileColor" content="#2196f3">
|
|
<meta name="theme-color" content="#2196f3">
|
|
|
|
<title>My PWA with Custom Icons</title>
|
|
|
|
<style>
|
|
/* 保持之前的样式不变 */
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html, body {
|
|
height: 100%;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
}
|
|
|
|
body {
|
|
padding-top: constant(safe-area-inset-top);
|
|
padding-top: env(safe-area-inset-top);
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
background: linear-gradient(135deg, #2196f3 0%, #0d47a1 100%);
|
|
color: white;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
text-align: center;
|
|
}
|
|
|
|
.container {
|
|
max-width: 600px;
|
|
padding: 2rem;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.icon-preview {
|
|
width: 120px;
|
|
height: 120px;
|
|
margin: 2rem auto;
|
|
border-radius: 24px; /* 模拟iOS图标圆角 */
|
|
overflow: hidden;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.icon-preview img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Custom PWA Icons</h1>
|
|
<p>Your app will now have proper icons when added to home screen</p>
|
|
|
|
<div class="icon-preview">
|
|
<img src="icons/icon-180x180.png" alt="App Icon Preview">
|
|
</div>
|
|
|
|
<p>Make sure to use all required icon sizes for best results across devices</p>
|
|
</div>
|
|
|
|
<script>
|
|
if ('serviceWorker' in navigator) {
|
|
window.addEventListener('load', () => {
|
|
navigator.serviceWorker.register('sw.js')
|
|
.then(registration => {
|
|
console.log('ServiceWorker registered successfully');
|
|
})
|
|
.catch(err => {
|
|
console.log('ServiceWorker registration failed:', err);
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|