From 49a2f514becd7677288b8dc711297ef56340b0e9 Mon Sep 17 00:00:00 2001
From: 魏曹先生 <1992414357@qq.com>
Date: Mon, 4 May 2026 17:57:18 +0800
Subject: Add day/night theme switching and GitHub corner to docs
---
docs/scripts/day-night-switch.js | 27 +++++++++++
docs/scripts/docsify-corner.js | 97 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+)
create mode 100644 docs/scripts/day-night-switch.js
create mode 100644 docs/scripts/docsify-corner.js
(limited to 'docs/scripts')
diff --git a/docs/scripts/day-night-switch.js b/docs/scripts/day-night-switch.js
new file mode 100644
index 0000000..91cebd1
--- /dev/null
+++ b/docs/scripts/day-night-switch.js
@@ -0,0 +1,27 @@
+function setTheme(theme) {
+ const dark = document.getElementById("dark-style");
+ if (theme === "dark") {
+ dark.disabled = false;
+ } else {
+ dark.disabled = true;
+ }
+ localStorage.setItem("theme", theme);
+}
+
+function toggleTheme() {
+ const currentTheme = localStorage.getItem("theme") || "light";
+ const newTheme = currentTheme === "dark" ? "light" : "dark";
+ setTheme(newTheme);
+}
+
+(function () {
+ const savedTheme = localStorage.getItem("theme");
+ if (savedTheme) {
+ setTheme(savedTheme);
+ } else {
+ const prefersDark =
+ window.matchMedia &&
+ window.matchMedia("(prefers-color-scheme: dark)").matches;
+ setTheme(prefersDark ? "dark" : "light");
+ }
+})();
diff --git a/docs/scripts/docsify-corner.js b/docs/scripts/docsify-corner.js
new file mode 100644
index 0000000..b059ef8
--- /dev/null
+++ b/docs/scripts/docsify-corner.js
@@ -0,0 +1,97 @@
+'use strict';
+
+function getIcon (cornerOptions) {
+ if (!cornerOptions.icon) {
+ return 'Not found the icon settings'
+ }
+
+ const icon = cornerOptions.icon.toLowerCase();
+
+ if (icon === 'github') {
+ return ''
+ }
+
+ if (icon === 'gitlab') {
+ return ''
+ }
+
+ if (icon === 'spring') {
+ return ''
+ }
+
+ if (icon === 'spring2') {
+ return ''
+ }
+
+ if (icon === 'golang') {
+ return ''
+ }
+
+ // if the icon is not in the preset, it should be the image url
+ const width = cornerOptions.width ? cornerOptions.width : cornerOptions.height ? cornerOptions.height : 100;
+ const heitht = cornerOptions.height ? cornerOptions.height : cornerOptions.width ? cornerOptions.width : 100;
+ return `
`
+}
+
+const cornerOptions = {
+
+ // the widtH of the icon image
+ width: '',
+ // the height of the icon image
+ height: '',
+ // the repo url
+ url: '',
+ // the target, align to site by default
+ target:'',
+ // the icon name/url
+ icon: '',
+ // the text of the title attribute is displayed as a tooltip
+ title: '',
+ // the corner background color, default false to use default color
+ background: false,
+ // the icon color, default false to use default color
+ color: false
+};
+
+function corner (hook, vm) {
+ // check if config the repo
+ if (!window.$docsify.repo) {
+ return
+ }
+
+ hook.mounted(function () {
+ const a = document.querySelector('a.github-corner');
+ a.innerHTML = getIcon(cornerOptions);
+
+ cornerOptions.url && (a.href = cornerOptions.url);
+ cornerOptions.title && (a.title = cornerOptions.title);
+
+ if(cornerOptions.target){
+ a.target = cornerOptions.target;
+ }
+
+ // icon color config
+ const cl = document.querySelector('.github-corner svg');
+
+ if (cl && cornerOptions.background) {
+ cl.style.setProperty('fill', cornerOptions.background);
+ }
+
+ if (cl && cornerOptions.color) {
+ cl.style.setProperty('color', cornerOptions.color);
+ }
+ });
+}
+
+// find corner plugin options
+window.$docsify.corner = Object.assign(
+ cornerOptions,
+ window.$docsify.corner
+);
+window.$docsify.plugins = [].concat(corner, window.$docsify.plugins);
--
cgit