From 9bdb515a6d5d9c4e9698fca2685fdda111cf496b Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Sun, 4 Feb 2024 17:18:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98icon=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/images/icon/theme.png | Bin 0 -> 712 bytes src/layout/components/Navbar.vue | 28 ++++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/assets/images/icon/theme.png diff --git a/src/assets/images/icon/theme.png b/src/assets/images/icon/theme.png new file mode 100644 index 0000000000000000000000000000000000000000..afdc1cae5f462bcfe8a9834507e045ee9a4c0529 GIT binary patch literal 712 zcmV;(0yq7MP)Px%f=NU{R9Hvtmpy0{Q4q)fvpEoKw2b#=FK3ikMU-?_T8W6Dq9WQv5QL~87D5D# z(VU=7LI2QHO6#%p7-2ZJKhM8F{XovvLZ6l z+S;1WWHO&s^^S9Hf9f7k)kBqb$^&>X)qcAh0q}kQp{njs)t8><^{VPKB06KO9Y_L9 z_iwfUDn#6IRI^KZL7jCybWNPstyv--TBy*RRD(poLAK$=iJfM zbD)~Cawg21ftg*Oe4I7k1x -
- 深色主题 - 浅色主题 +
+ +
@@ -94,7 +95,8 @@ export default { Avatar: Avatar, defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"', msgList: [], - themeValue: localStorage.getItem('themeValue') ? localStorage.getItem('themeValue') : 'dark' + isTheme: false, + themeValue: localStorage.getItem('themeValue') ? localStorage.getItem('themeValue') : 'light' } }, @@ -126,7 +128,7 @@ export default { created() { this.getMsgList() if (!localStorage.getItem('themeValue')) { - this.changetheme('dark') + this.changetheme('light') } }, methods: { @@ -211,7 +213,14 @@ export default { handleClose(done) { done() }, - changetheme(theme) { + changetheme() { + this.isTheme = !this.isTheme + let theme = '' + if (this.isTheme) { + theme = 'light' + } else { + theme = 'dark' + } window.document.documentElement.setAttribute('data-theme', theme) localStorage.setItem('themeValue', theme) } @@ -315,4 +324,11 @@ export default { } } } +.theme-btn{ + display: block; + width: 20px; + height: 20px; + background: url("~@/assets/images/icon/theme.png") no-repeat; + background-size: 100% 100%; +}