diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-04 17:57:18 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-04 17:57:18 +0800 |
| commit | 49a2f514becd7677288b8dc711297ef56340b0e9 (patch) | |
| tree | 89d91faf99b2f3f7622ccfd9a96667e0cab8e0f1 | |
| parent | c62fcde3ef6b7bbc11ee625dcf7c00b551795f87 (diff) | |
Add day/night theme switching and GitHub corner to docs
| -rw-r--r-- | docs/_zh_CN/index.html | 36 | ||||
| -rw-r--r-- | docs/css/dark.css | 118 | ||||
| -rw-r--r-- | docs/css/light.css (renamed from docs/css/vue.css) | 4 | ||||
| -rw-r--r-- | docs/index.html | 28 | ||||
| -rw-r--r-- | docs/scripts/day-night-switch.js | 27 | ||||
| -rw-r--r-- | docs/scripts/docsify-corner.js | 97 |
6 files changed, 269 insertions, 41 deletions
diff --git a/docs/_zh_CN/index.html b/docs/_zh_CN/index.html index 80ed30d..2e265c7 100644 --- a/docs/_zh_CN/index.html +++ b/docs/_zh_CN/index.html @@ -13,27 +13,42 @@ content="Quick start with Mingling and build your command-line program!" /> - <link rel="stylesheet" href="../css/vue.css" /> + <link rel="stylesheet" href="../css/light.css" /> + <link + id="dark-style" + rel="stylesheet" + href="../css/dark.css" + disabled + /> </head> <body> <nav> - <a href="https://docs.rs/mingling/latest/mingling/">Docs.rs</a> - <a href="https://crates.io/crates/mingling">Crates.io</a> - | - <a href="https://github.com/CatilGrass/mingling">GitHub</a> - | + <a href="https://crates.io/crates/mingling">发布页</a> + <a href="https://docs.rs/mingling/latest/mingling/">API文档</a> <a href="https://git.catilgrass.cn/catilgrass/mingling.git" - ><b>Source</b></a + ><b>源代码</b></a + > + <a + href="#" + onclick=" + toggleTheme(); + return false; + " + >🌗 主题</a > - | - <a href="../"><b>EN Docs</b></a> + <a href="../"><b>英文文档</b></a> </nav> <div id="app"></div> <script> window.$docsify = { name: "Mingling 中文文档", + repo: "true", + corner: { + url: "https://github.com/catilgrass/mingling", + icon: "github", + }, auto2top: true, loadSidebar: true, maxLevel: 0, @@ -68,6 +83,9 @@ <script src="../scripts/prism-bash.min.js"></script> <script src="../scripts/prism-toml.min.js"></script> <script src="../scripts/prism-rust.js"></script> + <script src="../scripts/docsify-corner.js"></script> <script src="../scripts/docsify-plugin-flexible-alerts.js"></script> + + <script src="../scripts/day-night-switch.js"></script> </body> </html> diff --git a/docs/css/dark.css b/docs/css/dark.css index 12535bc..e7f7ac0 100644 --- a/docs/css/dark.css +++ b/docs/css/dark.css @@ -74,7 +74,8 @@ html { body { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; - color: #34495e; + background-color: #121212 !important; + color: #f4fefe; font-family: Source Sans Pro, Helvetica Neue, @@ -220,7 +221,7 @@ main.hidden { transition: all 0.3s; } .anchor span { - color: #34495e; + color: #f4fefe; } .anchor:hover { text-decoration: underline; @@ -292,7 +293,7 @@ main.hidden { } .sidebar-toggle { background-color: transparent; - background-color: hsla(0, 0%, 100%, 0.8); + background-color: transparent; border: 0; outline: none; padding: 10px; @@ -328,12 +329,15 @@ body.sticky .sidebar-toggle { bottom: 0; left: 300px; transition: left 0.25s ease; + background-color: #121212; } .markdown-section { margin: 0 auto; - max-width: 80%; - padding: 30px 15px 40px; + max-width: 100%; + padding: 30px 45px 40px; position: relative; + background-color: #121212; + color: #fefefe; } .markdown-section > * { box-sizing: border-box; @@ -344,7 +348,7 @@ body.sticky .sidebar-toggle { } .markdown-section hr { border: none; - border-bottom: 1px solid #eee; + border-bottom: 1px solid #323232; margin: 2em 0; } .markdown-section iframe { @@ -365,15 +369,15 @@ body.sticky .sidebar-toggle { } .markdown-section td, .markdown-section th { - border: 1px solid #ddd; + border: 1px solid #333; padding: 6px 13px; } .markdown-section tr { - border-top: 1px solid #ccc; + border-top: 1px solid #222; } .markdown-section p.tip, .markdown-section tr:nth-child(2n) { - background-color: #f8f8f8; + background-color: #252525; } .markdown-section p.tip { border-bottom-right-radius: 2px; @@ -408,7 +412,7 @@ body.sticky .sidebar-toggle { background-color: #efefef; } .markdown-section p.tip em { - color: #34495e; + color: #f4fefe; } .markdown-section p.warn { background: rgba(66, 185, 131, 0.1); @@ -476,7 +480,6 @@ body.close .content { transform: translateX(300px); } body.close .sidebar-toggle { - background-color: hsla(0, 0%, 100%, 0.8); transition: background-color 1s; width: 284px; padding: 10px; @@ -615,13 +618,14 @@ body { background-color: #fefefe; } .sidebar { - color: #364149; + background-color: #080808; + color: #fefefe; } .sidebar li { margin: 6px 0; } .sidebar ul li a { - color: #505d6b; + color: #fefefe; font-size: 14px; font-weight: 400; overflow: hidden; @@ -660,7 +664,7 @@ body { .markdown-section h3, .markdown-section h4, .markdown-section strong { - color: #2c3e50; + color: #f2fefe; font-weight: 600; } .markdown-section a { @@ -732,7 +736,7 @@ body { } .markdown-section code, .markdown-section pre { - background-color: #f2f2f2; + background-color: #212121; } .markdown-section output, .markdown-section pre { @@ -753,7 +757,7 @@ body { } .markdown-section code { border-radius: 2px; - color: #f44336; + color: #f64739; margin: 0 2px; padding: 3px 5px; white-space: pre-wrap; @@ -777,6 +781,62 @@ body { overflow: inherit; white-space: inherit; } +.markdown-section pre code { + color: #eee; +} +.markdown-section pre code .token.punctuation { + color: #eee; +} +.alert.callout.note { + border: 1px solid #00bcd4; + box-shadow: 0 2px 8px rgba(0, 188, 212, 0.2); +} +.alert.callout.tip { + border: 1px solid #4caf50; + box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2); +} +.alert.callout.important { + border: 1px solid #7c4dff; + box-shadow: 0 2px 8px rgba(124, 77, 255, 0.2); +} +.alert.callout.warning { + border: 1px solid #ffc107; + box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2); +} +.alert.callout.attention { + border: 1px solid #f44336; + box-shadow: 0 2px 8px rgba(244, 67, 54, 0.2); +} +.alert.callout.note code { + color: #00c1d9; +} +.alert.callout.tip code { + color: #51af55; +} +.alert.callout.important code { + color: #8152ff; +} +.alert.callout.warning code { + color: #ffc60c; +} +.alert.callout.attention code { + color: #f9483b; +} +.alert.callout.note a { + color: #00c1d9; +} +.alert.callout.tip a { + color: #51af55; +} +.alert.callout.important a { + color: #8152ff; +} +.alert.callout.warning a { + color: #ffc60c; +} +.alert.callout.attention a { + color: #f9483b; +} .markdown-section output { padding: 1.7rem 1.4rem; border: 1px dotted #ccc; @@ -896,7 +956,7 @@ code .token { /* App name link styles */ .app-name-link { display: inline-block; - color: #34495e; + color: #f4fefe; font-size: 1.5rem; font-weight: 700; text-decoration: none; @@ -905,6 +965,11 @@ code .token { } /* Search styles */ +.search { + background-color: #101010; + border-bottom-width: 0px !important; +} + .search .input-wrap { position: relative; display: flex; @@ -913,12 +978,17 @@ code .token { .search .input-wrap input[type="search"] { width: 100%; padding: 8px 40px 8px 12px; - border: 1px solid #ccc; + border: 1px solid #444; border-radius: 4px; font-size: 14px; outline: none; transition: border-color 0.3s; box-sizing: border-box; + background-color: #1f1f1f; + color: #f4fefe; +} +.search .input-wrap input[type="search"]::placeholder { + color: #888; } .search .input-wrap input[type="search"]:focus { border-color: #ff5722; @@ -934,18 +1004,20 @@ code .token { display: flex; align-items: center; justify-content: center; - opacity: 0.6; + opacity: 0.4; transition: opacity 0.3s; + color: #666; } .search .input-wrap .clear-button:hover { - opacity: 1; + opacity: 0.7; } .search .results-panel { margin-top: 8px; - border: 1px solid #e0e0e0; + border: 1px solid #444; border-radius: 4px; - background: #fff; + background: #2a2a2a; max-height: 300px; overflow-y: auto; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); + color: #f4fefe; } diff --git a/docs/css/vue.css b/docs/css/light.css index 12535bc..d4f93dd 100644 --- a/docs/css/vue.css +++ b/docs/css/light.css @@ -331,8 +331,8 @@ body.sticky .sidebar-toggle { } .markdown-section { margin: 0 auto; - max-width: 80%; - padding: 30px 15px 40px; + max-width: 100%; + padding: 30px 45px 40px; position: relative; } .markdown-section > * { diff --git a/docs/index.html b/docs/index.html index e77d32b..3142dbd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -13,27 +13,37 @@ content="Quick start with Mingling and build your command-line program!" /> - <link rel="stylesheet" href="css/vue.css" /> + <link rel="stylesheet" href="css/light.css" /> + <link id="dark-style" rel="stylesheet" href="css/dark.css" disabled /> </head> <body> <nav> - <a href="https://docs.rs/mingling/latest/mingling/">Docs.rs</a> <a href="https://crates.io/crates/mingling">Crates.io</a> - | - <a href="https://github.com/CatilGrass/mingling">GitHub</a> - | + <a href="https://docs.rs/mingling/latest/mingling/">API Docs</a> <a href="https://git.catilgrass.cn/catilgrass/mingling.git" ><b>Source</b></a > - | - <a href="./_zh_CN/"><b>🇨🇳CN Docs</b></a> + <a + href="#" + onclick=" + toggleTheme(); + return false; + " + >🌗 Theme</a + > + <a href="./_zh_CN/"><b>🇨🇳 CN Docs</b></a> </nav> <div id="app"></div> <script> window.$docsify = { name: "Mingling Document", + repo: "true", + corner: { + url: "https://github.com/catilgrass/mingling", + icon: "github", + }, auto2top: true, loadSidebar: true, maxLevel: 0, @@ -69,12 +79,16 @@ <script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-toml.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-rust.js"></script> + <script src="https://cdn.jsdelivr.net/npm/docsify-corner/dist/docsify-corner.js"></script> <script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script>--> <script src="scripts/zoom-image.min.js"></script> <script src="scripts/search.js"></script> <script src="scripts/prism-bash.min.js"></script> <script src="scripts/prism-toml.min.js"></script> <script src="scripts/prism-rust.js"></script> + <script src="scripts/docsify-corner.js"></script> <script src="scripts/docsify-plugin-flexible-alerts.js"></script> + + <script src="scripts/day-night-switch.js"></script> </body> </html> 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 '<svg viewBox="0 0 250 250" aria-hidden="true">' + + '<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>' + + '<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' + + '<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>' + + '</svg>' + } + + if (icon === 'gitlab') { + return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 492.50943 453.67966"><path d="M0,-20 L1150,1150 L1300,1150 L500,14 L500,25 L2500,0 Z"></path><path d="M491.58891 259.39833l-27.55867-84.81467L409.41291 6.48633c-2.80934-8.648-15.04533-8.648-17.856 0l-54.61867 168.09733H155.57158l-54.62-168.09733c-2.80933-8.648-15.04533-8.648-17.856 0L28.47825 174.58366.92092 259.39833c-2.514669 7.736.24 16.21066 6.82 20.992l238.51333 173.28933 238.51466-173.28933c6.58-4.78134 9.33333-13.256 6.82-20.992" fill="#fc6d26" transform="translate(330 -20) rotate(45) scale(0.5)"></path></svg>' + } + + if (icon === 'spring') { + return '<svg viewBox="0 0 66.146 66.146" aria-hidden="true">' + + '<path d="M0 0l66.146 66.146.067-66.08z"></path><path fill="currentColor" d="M5.466 27.993c.586.473 1.446.385 1.918-.202.475-.585.386-1.445-.2-1.92-.585-.474-1.444-.383-1.92.202-.45.555-.392 1.356.115 1.844l-.266-.234C1.972 24.762 0 20.597 0 15.978 0 7.168 7.168 0 15.98 0c4.48 0 8.53 1.857 11.435 4.836.66-.898 1.232-1.902 1.7-3.015 2.036 6.118 3.233 11.26 2.795 15.31-.592 8.274-7.508 14.83-15.93 14.83-3.912 0-7.496-1.416-10.276-3.757l-.238-.21zm23.58-4.982c4.01-5.336 1.775-13.965-.085-19.48-1.657 3.453-5.738 6.094-9.262 6.93-3.303.788-6.226.142-9.283 1.318-6.97 2.68-6.86 10.992-3.02 12.86.002 0 .23.124.227.12 0-.002 5.644-1.122 8.764-2.274 4.56-1.684 9.566-5.835 11.213-10.657-.877 5.015-5.182 9.84-9.507 12.056-2.302 1.182-4.092 1.445-7.88 2.756-.464.158-.828.314-.828.314.96-.16 1.917-.212 1.917-.212 5.393-.255 13.807 1.516 17.745-3.73z" transform=translate(30,5) />' + + '</svg>' + } + + if (icon === 'spring2') { + return '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><g fill="none" fill-rule="evenodd"><path d="M0 0h32v32H0z"/><path fill="#70AD51" d="M5.466 27.993c.586.473 1.446.385 1.918-.202.475-.585.386-1.445-.2-1.92-.585-.474-1.444-.383-1.92.202-.45.555-.392 1.356.115 1.844l-.266-.234C1.972 24.762 0 20.597 0 15.978 0 7.168 7.168 0 15.98 0c4.48 0 8.53 1.857 11.435 4.836.66-.898 1.232-1.902 1.7-3.015 2.036 6.118 3.233 11.26 2.795 15.31-.592 8.274-7.508 14.83-15.93 14.83-3.912 0-7.496-1.416-10.276-3.757l-.238-.21zm23.58-4.982c4.01-5.336 1.775-13.965-.085-19.48-1.657 3.453-5.738 6.094-9.262 6.93-3.303.788-6.226.142-9.283 1.318-6.97 2.68-6.86 10.992-3.02 12.86.002 0 .23.124.227.12 0-.002 5.644-1.122 8.764-2.274 4.56-1.684 9.566-5.835 11.213-10.657-.877 5.015-5.182 9.84-9.507 12.056-2.302 1.182-4.092 1.445-7.88 2.756-.464.158-.828.314-.828.314.96-.16 1.917-.212 1.917-.212 5.393-.255 13.807 1.516 17.745-3.73z"/></g></svg>' + } + + if (icon === 'golang') { + return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><g fill-rule="evenodd" transform="translate(11,0) rotate(45) scale(0.5)"><path d="m14 15.01h1v-8.02c0-3.862-3.134-6.991-7-6.991-3.858 0-7 3.13-7 6.991v8.02h1v-8.02c0-3.306 2.691-5.991 6-5.991 3.314 0 6 2.682 6 5.991v8.02m-10.52-13.354c-.366-.402-.894-.655-1.48-.655-1.105 0-2 .895-2 2 0 .868.552 1.606 1.325 1.883.102-.321.226-.631.371-.93-.403-.129-.695-.507-.695-.953 0-.552.448-1 1-1 .306 0 .58.138.764.354.222-.25.461-.483.717-.699m9.04-.002c.366-.401.893-.653 1.479-.653 1.105 0 2 .895 2 2 0 .867-.552 1.606-1.324 1.883-.101-.321-.225-.632-.37-.931.403-.129.694-.507.694-.952 0-.552-.448-1-1-1-.305 0-.579.137-.762.353-.222-.25-.461-.483-.717-.699" fill="#fff"/><path d="m5.726 7.04h1.557v.124c0 .283-.033.534-.1.752-.065.202-.175.391-.33.566-.35.394-.795.591-1.335.591-.527 0-.979-.19-1.355-.571-.376-.382-.564-.841-.564-1.377 0-.547.191-1.01.574-1.391.382-.382.848-.574 1.396-.574.295 0 .57.06.825.181.244.12.484.316.72.586l-.405.388c-.309-.412-.686-.618-1.13-.618-.399 0-.733.138-1 .413-.27.27-.405.609-.405 1.015 0 .42.151.766.452 1.037.282.252.587.378.915.378.28 0 .531-.094.754-.283.223-.19.347-.418.373-.683h-.94v-.535m2.884.061c0-.53.194-.986.583-1.367.387-.381.853-.571 1.396-.571.537 0 .998.192 1.382.576.386.384.578.845.578 1.384 0 .542-.194 1-.581 1.379-.389.379-.858.569-1.408.569-.487 0-.923-.168-1.311-.505-.426-.373-.64-.861-.64-1.465m.574.007c0 .417.14.759.42 1.028.278.269.6.403.964.403.395 0 .729-.137 1-.41.272-.277.408-.613.408-1.01 0-.402-.134-.739-.403-1.01-.267-.273-.597-.41-.991-.41-.392 0-.723.137-.993.41-.27.27-.405.604-.405 1m-.184 3.918c.525.026.812.063.812.063.271.025.324-.096.116-.273 0 0-.775-.813-1.933-.813-1.159 0-1.923.813-1.923.813-.211.174-.153.3.12.273 0 0 .286-.037.81-.063v.477c0 .268.224.5.5.5.268 0 .5-.223.5-.498v-.252.25c0 .268.224.5.5.5.268 0 .5-.223.5-.498v-.478m-1-1.023c.552 0 1-.224 1-.5 0-.276-.448-.5-1-.5-.552 0-1 .224-1 .5 0 .276.448.5 1 .5" fill="#fff"/></g></svg>' + } + + // 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 `<img docsify-corner src=${cornerOptions.icon} width= ${width} height = ${heitht}>` +} + +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); |
