From c157644110b68de7c05882e6645495db7bfa5fc6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 16:10:31 +0900 Subject: [PATCH] Fix #952 --- src/web/assets/{help.js => 404.js} | 7 +++++++ src/web/assets/recover.html | 32 ++++++++++++++++++++++++++++++ src/web/server.ts | 4 +++- 3 files changed, 42 insertions(+), 1 deletion(-) rename src/web/assets/{help.js => 404.js} (73%) create mode 100644 src/web/assets/recover.html diff --git a/src/web/assets/help.js b/src/web/assets/404.js similarity index 73% rename from src/web/assets/help.js rename to src/web/assets/404.js index 475c506789..46fd004f14 100644 --- a/src/web/assets/help.js +++ b/src/web/assets/404.js @@ -2,6 +2,13 @@ const yn = window.confirm( 'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか?'); if (yn) { + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + location.reload(true); } else { alert('問題が解決しない場合はサーバー管理者までお問い合せください。'); diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html new file mode 100644 index 0000000000..8042d438c4 --- /dev/null +++ b/src/web/assets/recover.html @@ -0,0 +1,32 @@ + + + + + + Misskeyのリカバリ + + + diff --git a/src/web/server.ts b/src/web/server.ts index 791b75ce09..1d3687f89e 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -39,11 +39,13 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: ms('7 days') })); -app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/help.js`)); +app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/404.js`)); app.use('/assets', (req, res) => { res.sendStatus(404); }); +app.use('/recover', (req, res) => res.sendFile(`${__dirname}/assets/recover.html`)); + /** * ServiceWroker */