Skip to content

Commit 3677496

Browse files
committed
fix(site): add mock button for switch theme
1 parent 1799218 commit 3677496

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/sites/public/static/js/design-common.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const headerHtml = `
2727
<span class="header-detail-name">TinyVue</span>
2828
2929
<div class="nav-menus nav-menus-left"></div>
30+
<button id="switchTheme" style="margin-left:150px">切换主题</button>
3031
</div>
3132
</div>
3233
</div>`
@@ -147,6 +148,10 @@ class DesignCommon {
147148
link.href = '/static/css/design-common.css'
148149
link.rel = 'stylesheet'
149150
document.head.append(link)
151+
152+
document.getElementById('switchTheme').addEventListener('click', () => {
153+
document.querySelector('html').classList.toggle('dark')
154+
})
150155
}
151156
renderFooter() {
152157
document.getElementById('footer').innerHTML = footerHtml

0 commit comments

Comments
 (0)