From 6dea0e17526a8c67b51a54ea63770fcdda148575 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 11 May 2018 20:19:37 +0800 Subject: [PATCH] no cache --- docs/index.html | 9 ++++-- docs/serviceWorker.js | 75 ------------------------------------------- docs/start.md | 2 ++ 更新说明.txt | 5 +-- 4 files changed, 12 insertions(+), 79 deletions(-) delete mode 100644 docs/serviceWorker.js diff --git a/docs/index.html b/docs/index.html index f29c2402..cb5df153 100644 --- a/docs/index.html +++ b/docs/index.html @@ -44,8 +44,13 @@ mergeNavbar: true, formatUpdated: '{YYYY}-{MM}-{DD} {HH}:{mm}:{ss}', } - if (typeof navigator.serviceWorker !== 'undefined') { - navigator.serviceWorker.register('serviceWorker.js') + if (navigator.serviceWorker) { + navigator.serviceWorker.getRegistrations() + .then(function(registrations) { + for(let registration of registrations) { + registration.unregister(); + } + }); } diff --git a/docs/serviceWorker.js b/docs/serviceWorker.js deleted file mode 100644 index 34634e1e..00000000 --- a/docs/serviceWorker.js +++ /dev/null @@ -1,75 +0,0 @@ -const RUNTIME = 'docsify' -const HOSTNAME_WHITELIST = [ - self.location.hostname, - 'fonts.gstatic.com', - 'fonts.googleapis.com', - 'cdn.bootcss.com' -] - -// The Util Function to hack URLs of intercepted requests -const getFixedUrl = (req) => { - var now = Date.now() - var url = new URL(req.url) - - // 1. fixed http URL - // Just keep syncing with location.protocol - // fetch(httpURL) belongs to active mixed content. - // And fetch(httpRequest) is not supported yet. - url.protocol = self.location.protocol - - // 2. add query for caching-busting. - // Github Pages served with Cache-Control: max-age=600 - // max-age on mutable content is error-prone, with SW life of bugs can even extend. - // Until cache mode of Fetch API landed, we have to workaround cache-busting with query string. - // Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190 - if (url.hostname === self.location.hostname) { - url.search += (url.search ? '&' : '?') + 'cache-bust=' + now - } - return url.href -} - -/** - * @Lifecycle Activate - * New one activated when old isnt being used. - * - * waitUntil(): activating ====> activated - */ -self.addEventListener('activate', event => { - event.waitUntil(self.clients.claim()) -}) - -/** - * @Functional Fetch - * All network requests are being intercepted here. - * - * void respondWith(Promise r) - */ -self.addEventListener('fetch', event => { - // Skip some of cross-origin requests, like those for Google Analytics. - if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) { - // Stale-while-revalidate - // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale - // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1 - const cached = caches.match(event.request) - const fixedUrl = getFixedUrl(event.request) - const fetched = fetch(fixedUrl, { cache: 'no-store' }) - const fetchedCopy = fetched.then(resp => resp.clone()) - - // Call respondWith() with whatever we get first. - // If the fetch fails (e.g disconnected), wait for the cache. - // If there’s nothing in cache, wait for the fetch. - // If neither yields a response, return offline pages. - event.respondWith( - Promise.race([fetched.catch(_ => cached), cached]) -.then(resp => resp || fetched) -.catch(_ => { /* eat any errors */ }) -) - - // Update the cache with the version we fetched (only for ok status) - event.waitUntil( - Promise.all([fetchedCopy, caches.open(RUNTIME)]) - .then(([response, cache]) => response.ok && cache.put(event.request, response)) - .catch(_ => { /* eat any errors */ }) -) -} -}) \ No newline at end of file diff --git a/docs/start.md b/docs/start.md index 5027077e..160417f9 100644 --- a/docs/start.md +++ b/docs/start.md @@ -44,6 +44,8 @@ 如果提示“该素材未被定义”或有红色问号框,请参见[素材注册](#素材注册)。 +绘制地图时可以右键弹出菜单,移动图块和事件。 + ### 从RMXP导入已有的地图 如果我们想复刻一个现有的,已经被RMXP所制作的塔,也有很便捷的方式,那就是用到我们的“地图生成器”。 diff --git a/更新说明.txt b/更新说明.txt index fbdb7e9e..7fd97858 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,11 +1,12 @@ HTML5魔塔样板V2.2.1 +地图编辑器可以右键复制或移动图块 √ +事件:while循环处理 √ 衰弱减少攻防的比例 √ -while循环事件 √ 地图数据统计 最大存档个数提到main处理 √ 新建地图可以保留楼层属性 √ -自定义装备的教程(个性化 - 自定义装备) √ +增添自定义装备的教程(个性化-自定义装备) √ 重写教程的快速上手 √ 部分Bug修复 √