From 2ec113a89fcd2c82522ae50c3c382ddeb7386bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Willian=E5=A8=81=E5=BB=89?= <1410432625@qq.com> Date: Tue, 6 Jul 2021 11:17:55 +0000 Subject: [PATCH] =?UTF-8?q?update=20index.html.=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 52cd7d0..e0ff647 100644 --- a/index.html +++ b/index.html @@ -78,6 +78,34 @@ }, plugins: [ function (hook, vm) { + hook.ready(function (){ + // true = show debug log + let TARGET_QUERY = 'id' + let SCROLL_DELAY = 1500 // in milisecond + let location = window.location + let currentUrlWithoutHash = new URL( + location.origin+location.pathname+ + location.search+location.hash.substring(1) + ) + let urlQueryParam = currentUrlWithoutHash.searchParams + let isUrlHasIdQuery = urlQueryParam.has(TARGET_QUERY) + if(isUrlHasIdQuery){ + let urlId = urlQueryParam.get(TARGET_QUERY) + // run delayed, to make sure everything loaded + setTimeout(function() { + try{ + if(window.localStorage.getItem(urlId)==undefined) + { + location.reload() + window.localStorage.setItem(urlId, '1'); + } + } catch(e){} + }, SCROLL_DELAY); + setTimeout(function(){ + window.localStorage.removeItem(urlId) + },2000) + } + }), hook.beforeEach(function (html) { var url = 'https://gitee.com/rtthread/docs-online/blob/master/' + vm.route.file var editHtml = '[:pencil: 修改此文档 ](' + url + ')      [:page_with_curl:《修改规范说明》](/README?id=在线文档开发介绍)\n' @@ -86,7 +114,7 @@ editHtml + html + '\n\n----\n' + - '>我有疑问: [RT-Thread 官方论坛](https://club.rt-thread.org/)'+'