From c9bdc6c2f38291ad8d1675899b918449f9efaa64 Mon Sep 17 00:00:00 2001 From: yutent Date: Sun, 12 Feb 2023 17:04:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96hmr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants.js | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 19742c5..557ba95 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -16,12 +16,16 @@ export const COMMON_HEADERS = { } export const HMR_SCRIPT = ` -!(function(){ +!(function vue_live_hmr(){ var ws = new WebSocket(\`ws\${location.protocol === 'https:' ? 's' : ''}://\${location.host}/ws-vue-live\`) ws.addEventListener('open', function (r) { console.log('vue-live hmr ready...') }) + + ws.addEventListener('close', function(){ + setTimeout(vue_live_hmr, 1000) + }) ws.addEventListener('message', function (ev) { var { action, data } = JSON.parse(ev.data) diff --git a/package.json b/package.json index e38711b..26e482b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@bytedo/vue-live", "type": "module", - "version": "0.1.5", + "version": "0.1.6", "bin": { "vue-live": "index.js" },