Commit 8635c2dd authored by KesaubeEire's avatar KesaubeEire

feat: 侧边栏主题选择.

parent 8b16b0e4
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
'winter' 'winter'
]; ];
/**导航栏注入对象*/ /**导航栏&侧边栏 -> 注入功能对象*/
const injectText = [ const injectText = [
{ {
id: 'search', id: 'search',
...@@ -83,9 +83,10 @@ ...@@ -83,9 +83,10 @@
} }
]; ];
// -----------------------------
/**search input DOM元素*/ /**search input DOM元素*/
let searchInputDom; let searchInputDom;
/**执行搜索 /**执行搜索
* @param event 事件对象 * @param event 事件对象
*/ */
...@@ -104,6 +105,13 @@ ...@@ -104,6 +105,13 @@
// }, 1000); // }, 1000);
} }
/**设定网站主题*/
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
$_theme = theme;
console.log('切换主题:\t', theme);
}
// ----------------------------- // -----------------------------
// FIXME: 环境变量 -> 处理生产模式和开发模式的文件网络路径问题 // FIXME: 环境变量 -> 处理生产模式和开发模式的文件网络路径问题
...@@ -199,7 +207,7 @@ ...@@ -199,7 +207,7 @@
/> />
</div> </div>
<!-- NOTE: 功能区遍历 --> <!-- NOTE: (导航栏) 功能区遍历 -->
{#each injectText as Item} {#each injectText as Item}
<li> <li>
<div class="p-3 tooltip tooltip-left" data-tip={Item.hint}> <div class="p-3 tooltip tooltip-left" data-tip={Item.hint}>
...@@ -227,9 +235,7 @@ ...@@ -227,9 +235,7 @@
<button <button
data-theme={theme} data-theme={theme}
on:click={() => { on:click={() => {
document.documentElement.setAttribute('data-theme', theme); setTheme(theme);
$_theme = theme;
console.log('切换主题:\t', theme);
}} }}
class="rounded my-1 flex justify-between items-center" class="rounded my-1 flex justify-between items-center"
> >
...@@ -258,12 +264,43 @@ ...@@ -258,12 +264,43 @@
<div class="drawer-side z-[40]"> <div class="drawer-side z-[40]">
<label for="my-drawer-3" aria-label="close sidebar" class="drawer-overlay" /> <label for="my-drawer-3" aria-label="close sidebar" class="drawer-overlay" />
<ul class="menu p-4 w-60 min-h-full bg-base-200"> <ul class="menu p-4 w-60 min-h-full bg-base-200">
<!-- Sidebar content here --> <!-- NOTE: (侧边栏) 功能区遍历 -->
{#each injectText as Item} {#each injectText as Item}
<li> <li>
<button on:click={Item.click}>{Item.text}</button> <button on:click={Item.click}>{Item.text}</button>
</li> </li>
{/each} {/each}
<!-- NOTE: 主题 -->
<li>
<details>
<summary>主题选择</summary>
<ul>
{#each themes as theme}
<li>
<button
data-theme={theme}
on:click={() => {
setTheme(theme);
}}
class="rounded my-1 flex justify-between items-center"
>
<div>
{theme}
</div>
<div class="flex h-full flex-shrink-0 flex-wrap gap-1">
<span class="bg-primary w-4 h-4 rounded-box" />
<span class="bg-secondary w-4 h-4 rounded-box" />
<span class="bg-accent w-4 h-4 rounded-box" />
<span class="bg-neutral w-4 h-4 rounded-box" />
</div>
</button>
</li>
{/each}
</ul>
</details>
</li>
</ul> </ul>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment