mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
✨ Feat: add auto bookmark support (#55)
This commit is contained in:
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
- :tada: Feat: add reading progress bar support ([#191](https://github.com/hugo-fixit/FixIt/issues/191))
|
||||
- :tada: Feat: add b2t scroll percent support ([#192](https://github.com/hugo-fixit/FixIt/issues/192))
|
||||
- :sparkles: Feat: add auto bookmark support ([#55](https://github.com/hugo-fixit/FixIt/issues/55))
|
||||
- :sparkles: Feat: add `raw` shortcode
|
||||
- :sparkles: Feat(menu): add params: `icon`, `type` for menu items
|
||||
- :sparkles: Feat: add custom aside template in post page ([#172](https://github.com/hugo-fixit/FixIt/issues/172))
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -67,6 +67,9 @@
|
||||
# FixIt 0.2.14 | NEW FixIt will, by default, inject a theme meta tag in the HTML head on the home page only.
|
||||
# You can turn it off, but we would really appreciate if you don’t, as this is a good way to watch FixIt's popularity on the rise.
|
||||
disableThemeInject = false
|
||||
# FixIt 0.2.16 | NEW Auto Bookmark Support
|
||||
# If true, save the reading progress when closing the page.
|
||||
autoBookmark = false
|
||||
|
||||
# FixIt 0.2.0 | NEW App icon config
|
||||
[params.app]
|
||||
|
||||
+1
-1
Submodule docs updated: b0b14feb88...354ff59435
@@ -240,6 +240,11 @@
|
||||
{{- $config = dict "enablePWA" .Site.Params.enablePWA | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Auto Bookmark */ -}}
|
||||
{{- with .Site.Params.autoBookmark -}}
|
||||
{{- $config = dict "autoBookmark" . | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $params.library.css -}}
|
||||
{{- dict "Source" . "Fingerprint" $fingerprint | dict "Scratch" $.Scratch "Data" | partial "scratch/style.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
+22
-3
@@ -943,7 +943,7 @@ class FixIt {
|
||||
}
|
||||
|
||||
initPangu() {
|
||||
// TODO 待优化:只渲染
|
||||
// TODO 待优化:只渲染
|
||||
this.config.enablePangu && pangu.autoSpacingPage();
|
||||
}
|
||||
|
||||
@@ -985,11 +985,11 @@ class FixIt {
|
||||
}
|
||||
|
||||
initMDevtools() {
|
||||
const type = this.config?.mDevtools
|
||||
const type = this.config?.mDevtools;
|
||||
if (typeof window.orientation === 'undefined') {
|
||||
return;
|
||||
}
|
||||
if(type === 'vConsole') {
|
||||
if (type === 'vConsole') {
|
||||
const vConsole = new VConsole({
|
||||
target: '.widgets',
|
||||
theme: this.isDark ? 'dark' : 'light'
|
||||
@@ -1010,6 +1010,24 @@ class FixIt {
|
||||
}
|
||||
}
|
||||
|
||||
initAutoMark() {
|
||||
if (!this.config.autoBookmark) {
|
||||
return;
|
||||
}
|
||||
window.addEventListener('beforeunload', () => {
|
||||
const scrollTop = this.util.getScrollTop();
|
||||
scrollTop && localStorage.setItem(`fixit-bookmark/#${location.pathname}`, scrollTop);
|
||||
});
|
||||
const scrollTop = Number(localStorage.getItem(`fixit-bookmark/#${location.pathname}`));
|
||||
// If the page opens with a specific hash, just jump out
|
||||
if (scrollTop && location.hash === '') {
|
||||
window.scrollTo({
|
||||
top: scrollTop,
|
||||
behavior: "smooth"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onScroll() {
|
||||
const $headers = [];
|
||||
const ACCURACY = 20;
|
||||
@@ -1137,6 +1155,7 @@ class FixIt {
|
||||
this.initServiceWorker();
|
||||
this.initWatermark();
|
||||
this.initMDevtools();
|
||||
this.initAutoMark();
|
||||
|
||||
window.setTimeout(() => {
|
||||
this.initComment();
|
||||
|
||||
Reference in New Issue
Block a user