From a85c32c440048bed80ef30675290889e5bd9e0f1 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Sat, 5 Dec 2020 14:50:09 +0800 Subject: [PATCH] fix(h5): force reload when route id is undefined --- .../packages/h5-vue-router/dist/vue-router.common.js | 10 ++++++---- .../packages/h5-vue-router/dist/vue-router.esm.js | 10 ++++++---- .../packages/h5-vue-router/dist/vue-router.js | 10 ++++++---- .../packages/h5-vue-router/dist/vue-router.min.js | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js index 13510bae8..71c786fdf 100644 --- a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js +++ b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.common.js @@ -2204,8 +2204,9 @@ var HTML5History = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ // fixed by xxxxxx @@ -2353,8 +2354,9 @@ var HashHistory = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ diff --git a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js index a29ea4bd4..976ca667d 100644 --- a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js +++ b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.esm.js @@ -2202,8 +2202,9 @@ var HTML5History = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ // fixed by xxxxxx @@ -2351,8 +2352,9 @@ var HashHistory = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ diff --git a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js index ffb58af8d..cfbc1a230 100644 --- a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js +++ b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.js @@ -2208,8 +2208,9 @@ var HTML5History = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ // fixed by xxxxxx @@ -2357,8 +2358,9 @@ var HashHistory = (function (History$$1) { // fixed by xxxxxx var id = e.state && e.state.id; if (!id) { - // TODO - id = router.id; + // 当手动切换页面时,强制刷新 + return window.location.reload() + // id = router.id } this$1.transitionTo({ diff --git a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js index ebfc2844b..b5ed6a18b 100644 --- a/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js +++ b/packages/vue-cli-plugin-uni/packages/h5-vue-router/dist/vue-router.min.js @@ -3,4 +3,4 @@ * (c) 2020 Evan You * @license MIT */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function l(t){return-1=e.length?n():e[t]?r(e[t],function(){o(t+1)}):o(t+1)};o(0)}function ct(r){return function(t,e,u){var c=!1,p=0,f=null;pt(r,function(r,t,n,o){if("function"==typeof r&&void 0===r.cid){c=!0,p++;var e,i=lt(function(t){var e;((e=t).__esModule||ht&&"Module"===e[Symbol.toStringTag])&&(t=t.default),r.resolved="function"==typeof t?t:d.extend(t),n.components[o]=t,--p<=0&&u()}),a=lt(function(t){var e="Failed to resolve async component "+o+": "+t;f||(f=l(t)?t:new Error(e),u(f))});try{e=r(i,a)}catch(t){a(t)}if(e)if("function"==typeof e.then)e.then(i,a);else{var s=e.component;s&&"function"==typeof s.then&&s.then(i,a)}}}),c||u()}}function pt(t,r){return ft(t.map(function(e){return Object.keys(e.components).map(function(t){return r(e.components[t],e.instances[t],e,t)})}))}function ft(t){return Array.prototype.concat.apply([],t)}var ht="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function lt(r){var n=!1;return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!n)return n=!0,r.apply(this,t)}}var dt=function(t,e){this.router=t,this.base=function(t){if(!t)if(v){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=O,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function yt(t,i,a,e){var r=pt(t,function(t,e,r,n){var o=function(t,e){"function"!=typeof t&&(t=d.extend(t));return t.options[e]}(t,i);if(o)return Array.isArray(o)?o.map(function(t){return a(t,e,r,n)}):a(o,e,r,n)});return ft(e?r.reverse():r)}function vt(t,e){if(e)return function(){return t.apply(e,arguments)}}dt.prototype.listen=function(t){this.cb=t},dt.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},dt.prototype.onError=function(t){this.errorCbs.push(t)},dt.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(e){r&&r(e),e&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(t){t(e)}))})},dt.prototype.confirmTransition=function(r,e,t){var n=this,o=this.current,i=function(e){l(e)&&(n.errorCbs.length?n.errorCbs.forEach(function(t){t(e)}):console.error(e)),t&&t(e)},a=function(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=this.stack.length)){var n=this.stack[r];this.confirmTransition(n,function(){e.index=r,e.updateRoute(n)})}},t.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},t.prototype.ensureURL=function(){},t}(dt),jt=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=F(t.routes||[],this),this.id=t.id||1,this.minId=t.id||1;var e=t.mode||"hash";switch(this.fallback="history"===e&&!et&&!1!==t.fallback,this.fallback&&(e="hash"),v||(e="abstract"),this.mode=e){case"history":this.history=new mt(this,t.base);break;case"hash":this.history=new _t(this,t.base,this.fallback);break;case"abstract":this.history=new Et(this,t.base)}},Ot={currentRoute:{configurable:!0}};function Ct(e,r){return e.push(r),function(){var t=e.indexOf(r);-1=e.length?n():e[t]?r(e[t],function(){o(t+1)}):o(t+1)};o(0)}function ct(r){return function(t,e,u){var c=!1,p=0,f=null;pt(r,function(r,t,n,o){if("function"==typeof r&&void 0===r.cid){c=!0,p++;var e,i=lt(function(t){var e;((e=t).__esModule||ht&&"Module"===e[Symbol.toStringTag])&&(t=t.default),r.resolved="function"==typeof t?t:d.extend(t),n.components[o]=t,--p<=0&&u()}),a=lt(function(t){var e="Failed to resolve async component "+o+": "+t;f||(f=l(t)?t:new Error(e),u(f))});try{e=r(i,a)}catch(t){a(t)}if(e)if("function"==typeof e.then)e.then(i,a);else{var s=e.component;s&&"function"==typeof s.then&&s.then(i,a)}}}),c||u()}}function pt(t,r){return ft(t.map(function(e){return Object.keys(e.components).map(function(t){return r(e.components[t],e.instances[t],e,t)})}))}function ft(t){return Array.prototype.concat.apply([],t)}var ht="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function lt(r){var n=!1;return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!n)return n=!0,r.apply(this,t)}}var dt=function(t,e){this.router=t,this.base=function(t){if(!t)if(v){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=O,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function yt(t,i,a,e){var r=pt(t,function(t,e,r,n){var o=function(t,e){"function"!=typeof t&&(t=d.extend(t));return t.options[e]}(t,i);if(o)return Array.isArray(o)?o.map(function(t){return a(t,e,r,n)}):a(o,e,r,n)});return ft(e?r.reverse():r)}function vt(t,e){if(e)return function(){return t.apply(e,arguments)}}dt.prototype.listen=function(t){this.cb=t},dt.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},dt.prototype.onError=function(t){this.errorCbs.push(t)},dt.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(e){r&&r(e),e&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(t){t(e)}))})},dt.prototype.confirmTransition=function(r,e,t){var n=this,o=this.current,i=function(e){l(e)&&(n.errorCbs.length?n.errorCbs.forEach(function(t){t(e)}):console.error(e)),t&&t(e)},a=function(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=this.stack.length)){var n=this.stack[r];this.confirmTransition(n,function(){e.index=r,e.updateRoute(n)})}},t.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},t.prototype.ensureURL=function(){},t}(dt),jt=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=F(t.routes||[],this),this.id=t.id||1,this.minId=t.id||1;var e=t.mode||"hash";switch(this.fallback="history"===e&&!et&&!1!==t.fallback,this.fallback&&(e="hash"),v||(e="abstract"),this.mode=e){case"history":this.history=new mt(this,t.base);break;case"hash":this.history=new _t(this,t.base,this.fallback);break;case"abstract":this.history=new Et(this,t.base)}},Ot={currentRoute:{configurable:!0}};function Ct(e,r){return e.push(r),function(){var t=e.indexOf(r);-1