diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index 67559723e..ab0a26707 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -238,7 +238,7 @@ * @returns {number} * @constructor */ - Time(v) { + Time(v = undefined) { let time if (typeof v === "string" && this.strExists(v, "-")) { v = v.replace(/-/g, '/'); @@ -702,6 +702,38 @@ return this.rightDelete(url.replace("?&", "?"), '?'); }, + /** + * 刷新当前地址 + * @param url + * @param key + * @returns {string} + */ + reloadUrl(url = undefined, key = undefined) { + url = key || window.location.href; + key = (key || '_') + '=' + let reg = new RegExp(key + '\\d+'); + let timestamp = this.Time(); + if (url.indexOf(key) > -1) { + url = url.replace(reg, key + timestamp); + } else { + if (url.indexOf('\?') > -1) { + let urlArr = url.split('\?'); + if (urlArr[1]) { + url = urlArr[0] + '?' + key + timestamp + '&' + urlArr[1]; + } else { + url = urlArr[0] + '?' + key + timestamp; + } + } else { + if (url.indexOf('#') > -1) { + url = url.split('#')[0] + '?' + key + timestamp + location.hash; + } else { + url = url + '?' + key + timestamp; + } + } + } + window.location.href = url + }, + /** * 链接字符串 * @param value 第一个参数为连接符 diff --git a/resources/assets/js/pages/login.vue b/resources/assets/js/pages/login.vue index fced9fce2..dc6f29734 100644 --- a/resources/assets/js/pages/login.vue +++ b/resources/assets/js/pages/login.vue @@ -312,7 +312,7 @@ export default { setServerUrl(value) { if (value != this.cacheServerUrl) { $A.setStorage("cacheServerUrl", value) - window.location.reload(); + $A.reloadUrl(); } }, diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 7d6442f7c..5e4000b3d 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -773,9 +773,9 @@ export default { case 'clearCache': this.$store.dispatch("handleClearCache", null).then(() => { $A.setStorage("clearCache", $A.randomString(6)) - window.location.reload() + $A.reloadUrl() }).catch(() => { - window.location.reload() + $A.reloadUrl() }); return; case 'logout': diff --git a/resources/assets/js/pages/manage/setting/index.vue b/resources/assets/js/pages/manage/setting/index.vue index bf6f37ead..3f5e00048 100644 --- a/resources/assets/js/pages/manage/setting/index.vue +++ b/resources/assets/js/pages/manage/setting/index.vue @@ -117,9 +117,9 @@ export default { case 'clearCache': this.$store.dispatch("handleClearCache", null).then(() => { $A.setStorage("clearCache", $A.randomString(6)) - window.location.reload() + $A.reloadUrl() }).catch(() => { - window.location.reload() + $A.reloadUrl() }); break;