summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-10-21 20:26:13 +0800
committerEltrac <hi@guhub.cn>2025-10-21 20:26:13 +0800
commit48b82af70feb7a20dc80490353da39540c83acec (patch)
tree94ed6721b74c9efc04530cd4bd16819bbd4b14fe
parent7e0fc22f87a26df392368bb78c7397451655af23 (diff)
remove: settings page
Former-commit-id: 4e40e1ed71a3ff5889c2a12848667eda03319f29
-rw-r--r--assets/js/settings.js79
-rw-r--r--config/_default/params.zh.yaml2
-rw-r--r--content/settings.md6
-rw-r--r--layouts/_partials/components/back-to-top.html97
-rw-r--r--layouts/_partials/scripts.html4
-rw-r--r--layouts/settings.html8
6 files changed, 46 insertions, 150 deletions
diff --git a/assets/js/settings.js b/assets/js/settings.js
deleted file mode 100644
index 6dcbdfa9..00000000
--- a/assets/js/settings.js
+++ /dev/null
@@ -1,79 +0,0 @@
-(() => {
- /**
- * ===========================
- * Initialize Settings Page
- * ===========================
- */
-
- // return if this is not the settings page
- if (!document.getElementById('settings')) return;
-
- const initializeSettingsPage = () => {
- // initialize text altering buttons
- function initTextAlterButtons() {
- const textAlterButtons = document.querySelectorAll('#text-alter-buttons button');
- textAlterButtons.forEach(button => {
- // highlight selected button
- if (button.dataset.textSize === localStorage.getItem('geedeapro.ui.fontSize')) {
- button.classList.add('bg-neutral-200/50', 'dark:bg-neutral-700/50');
- }
-
- // switch font size when clicked
- button.addEventListener('click', () => {
- setFontSize(button.dataset.textSize);
- // highlight selected button
- textAlterButtons.forEach(btn => btn.classList.remove('bg-neutral-200/50', 'dark:bg-neutral-700/50'));
- button.classList.add('bg-neutral-200/50', 'dark:bg-neutral-700/50');
- });
- });
- }
- initTextAlterButtons()
-
- // initialize checkbox options
- function initCheckboxes() {
- const checkboxOptions = [
- {
- id: 'hideBatrick',
- label: '隐藏 Batrick(返回顶部按钮)',
- storage: 'geedeapro.ui.hideBatrick',
- default: 'false'
- }
- ]
-
- checkboxOptions.forEach(checkboxOption => {
- // create checkbox
- const element = document.createElement('input');
- element.type = 'checkbox';
- element.id = checkboxOption.id;
- element.checked = localStorage.getItem(checkboxOption.storage) ||
- checkboxOption.default === 'true';
-
- // add event listener to checkbox
- element.addEventListener('change', () => {
- if (element.checked)
- localStorage.setItem(checkboxOption.storage, 1);
- else
- localStorage.removeItem(checkboxOption.storage);
- });
-
- // create label
- const label = document.createElement('label');
- label.htmlFor = element.id;
- label.textContent = checkboxOption.label;
-
- // wrap checkbox and label in a div
- const wrapper = document.createElement('div');
- wrapper.classList.add('flex', 'items-center', 'mb-2', 'gap-2');
- wrapper.appendChild(element);
- wrapper.appendChild(label);
-
- // append checkbox and label to container
- const container = document.getElementById('checkbox-options');
- container.appendChild(wrapper);
- });
- }
- initCheckboxes();
- };
-
- initializeSettingsPage();
-})();
diff --git a/config/_default/params.zh.yaml b/config/_default/params.zh.yaml
index 9daa5e91..8ffd285e 100644
--- a/config/_default/params.zh.yaml
+++ b/config/_default/params.zh.yaml
@@ -18,5 +18,3 @@ footerInternalLinks:
link: /highlights/
- name: 赞助
link: /sponsor/
- - name: 设置
- link: /settings/
diff --git a/content/settings.md b/content/settings.md
deleted file mode 100644
index 4b875aeb..00000000
--- a/content/settings.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title: 设置
-layout: settings
----
-
-🙋 网站设置正在测试中,如果在使用过程中遇到问题请联系我,谢谢!
diff --git a/layouts/_partials/components/back-to-top.html b/layouts/_partials/components/back-to-top.html
index bf094d5d..6ef367b6 100644
--- a/layouts/_partials/components/back-to-top.html
+++ b/layouts/_partials/components/back-to-top.html
@@ -14,64 +14,59 @@
</div>
<script>
-// hide Batrick if set
-if (localStorage.getItem('geedeapro.ui.hideBatrick')) {
- document.getElementById('back2top').classList.add('hidden');
-} else {
- // Batrick functionality
- const backToTop = document.getElementById("back2top")
- const backToTopButton = document.getElementById("back2top-button")
- const backToTopInstruction = document.getElementById("back2top-instruction")
- const seenAndUsedBat = localStorage.getItem("geedeapro.ui.seenAndUsedBat")
+// Batrick functionality
+const backToTop = document.getElementById("back2top")
+const backToTopButton = document.getElementById("back2top-button")
+const backToTopInstruction = document.getElementById("back2top-instruction")
+const seenAndUsedBat = localStorage.getItem("geedeapro.ui.seenAndUsedBat")
- function hideInstruction() {
- backToTopInstruction.remove()
- }
- if (seenAndUsedBat) hideInstruction()
+function hideInstruction() {
+ backToTopInstruction.remove()
+}
+if (seenAndUsedBat) hideInstruction()
- // listen to button click and scroll to top
- backToTopButton.addEventListener("click", () => {
- window.scrollTo({ top: 0, behavior: "smooth" })
- if (!seenAndUsedBat) {
- localStorage.setItem("geedeapro.ui.seenAndUsedBat", true);
- hideInstruction();
- }
- })
+// listen to button click and scroll to top
+backToTopButton.addEventListener("click", () => {
+ window.scrollTo({ top: 0, behavior: "smooth" })
+ if (!seenAndUsedBat) {
+ localStorage.setItem("geedeapro.ui.seenAndUsedBat", true);
+ hideInstruction();
+ }
+})
- // listen to scroll and toggle button visibility
- let lastOffset = window.scrollY
+// listen to scroll and toggle button visibility
+let lastOffset = window.scrollY
- window.addEventListener("scroll", () => {
- const offset = window.scrollY
- const batIsHidden = backToTop.classList.contains("-top-25")
- const enoughHeight = offset >= 2000
- const isScrollingUp = offset < lastOffset
- const isScrollingDown = offset > lastOffset
+window.addEventListener("scroll", () => {
+ const offset = window.scrollY
+ const batIsHidden = backToTop.classList.contains("-top-25")
+ const enoughHeight = offset >= 2000
+ const isScrollingUp = offset < lastOffset
+ const isScrollingDown = offset > lastOffset
- function hide() {
- backToTop.classList.remove("top-0")
- backToTop.classList.add("-top-25")
- backToTop.classList.remove("animate-head-shake")
- }
+ function hide() {
+ backToTop.classList.remove("top-0")
+ backToTop.classList.add("-top-25")
+ backToTop.classList.remove("animate-head-shake")
+ }
- function show() {
- backToTop.classList.remove("-top-25")
- backToTop.classList.add("top-0")
- backToTop.classList.add("animate-head-shake")
- }
+ function show() {
+ backToTop.classList.remove("-top-25")
+ backToTop.classList.add("top-0")
+ backToTop.classList.add("animate-head-shake")
+ }
- if (enoughHeight && isScrollingUp && batIsHidden) {
- // show only when scrolling up
- show()
- } else if (isScrollingDown && !batIsHidden) {
- // hide as soon as user scrolls down again
- hide()
- }
+ if (enoughHeight && isScrollingUp && batIsHidden) {
+ // show only when scrolling up
+ show()
+ } else if (isScrollingDown && !batIsHidden) {
+ // hide as soon as user scrolls down again
+ hide()
+ }
- // hide no matter what if too close to top
- if (!enoughHeight) hide()
+ // hide no matter what if too close to top
+ if (!enoughHeight) hide()
- lastOffset = offset
- })
-}
+ lastOffset = offset
+})
</script>
diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html
index bc43802d..87243f76 100644
--- a/layouts/_partials/scripts.html
+++ b/layouts/_partials/scripts.html
@@ -1,7 +1,3 @@
-{{ with resources.Get "js/settings.js" }}
-<script>{{ .Content | safeJS }}</script>
-{{ end }}
-
{{ with resources.Get "js/tooltip.js" }}
<script>{{ .Content | safeJS }}</script>
{{ end }}
diff --git a/layouts/settings.html b/layouts/settings.html
deleted file mode 100644
index 916336b8..00000000
--- a/layouts/settings.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{{ define "main" }}
- <article id="settings">
- {{ partial "header" . }}
- <div class="text-base">{{ .Content }}</div>
- <section id="checkbox-options" class="text-sm"></section>
- </article>
-{{ partial "footer.html" . }}
-{{ end }}