覆盖CSS3核心特性、Flex/Grid布局、CSS动画、响应式设计、 Tailwind CSS最佳实践、CSS新特性(容器查询、层叠层、:has选择器、 滚动驱动动画、现代色彩系统等) 功能: - 渐进式学习页面(learn.html) - 闪卡复习模式(flashcard.html) - 知识点索引与搜索(roots.html) - 知识点详情(root-detail.html) - 学习进度追踪(progress.html) - PWA离线支持 - SEO优化
36 lines
781 B
JavaScript
36 lines
781 B
JavaScript
// Service Worker - 提供基本的离线缓存
|
|
const CACHE_NAME = 'modern-css-v1';
|
|
const ASSETS = [
|
|
'./',
|
|
'./index.html',
|
|
'./learn.html',
|
|
'./flashcard.html',
|
|
'./roots.html',
|
|
'./root-detail.html',
|
|
'./progress.html',
|
|
'./css/minimal.css',
|
|
'./js/wordData.js',
|
|
'./js/siteConfig.js',
|
|
'./js/storage.js'
|
|
];
|
|
|
|
self.addEventListener('install', (e) => {
|
|
e.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', (e) => {
|
|
e.respondWith(
|
|
caches.match(e.request).then((res) => res || fetch(e.request))
|
|
);
|
|
});
|
|
|
|
self.addEventListener('activate', (e) => {
|
|
e.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
)
|
|
);
|
|
});
|