| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  | {{define "component/themeSwitchTemplate"}} | 
					
						
							|  |  |  | <template> | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |   <a-menu :theme="themeSwitcher.currentTheme" mode="inline" selected-keys=""> | 
					
						
							|  |  |  |     <a-sub-menu> | 
					
						
							|  |  |  |       <span slot="title"> | 
					
						
							|  |  |  |         <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon> | 
					
						
							| 
									
										
										
										
											2025-03-17 11:26:07 +00:00
										 |  |  |         <span>{{ i18n "menu.theme" }}</span> | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |       </span> | 
					
						
							| 
									
										
										
										
											2025-03-17 11:26:07 +00:00
										 |  |  |       <a-menu-item id="change-theme" class="ant-menu-theme-switch" @mousedown="themeSwitcher.animationsOff()">  | 
					
						
							|  |  |  |         <span>{{ i18n "menu.dark" }}</span> | 
					
						
							|  |  |  |         <a-switch style="margin-left: 2px;" size="small" :default-checked="themeSwitcher.isDarkTheme" @change="themeSwitcher.toggleTheme()"></a-switch> | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |       </a-menu-item> | 
					
						
							| 
									
										
										
										
											2025-03-17 11:26:07 +00:00
										 |  |  |       <a-menu-item id="change-theme-ultra" v-if="themeSwitcher.isDarkTheme" class="ant-menu-theme-switch" @mousedown="themeSwitcher.animationsOffUltra()">  | 
					
						
							|  |  |  |         <span>{{ i18n "menu.ultraDark" }}</span> | 
					
						
							|  |  |  |         <a-checkbox style="margin-left: 2px;" :checked="themeSwitcher.isUltra" @click="themeSwitcher.toggleUltra()"></a-checkbox> | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |       </a-menu-item> | 
					
						
							|  |  |  |     </a-sub-menu> | 
					
						
							|  |  |  |   </a-menu> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | {{end}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | {{define "component/themeSwitchTemplateLogin"}} | 
					
						
							|  |  |  | <template> | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  |   <a-menu @mousedown="themeSwitcher.animationsOff()" id="change-theme" :theme="themeSwitcher.currentTheme" mode="inline" | 
					
						
							|  |  |  |     selected-keys=""> | 
					
						
							| 
									
										
										
										
											2024-03-09 13:06:16 +00:00
										 |  |  |     <a-menu-item mode="inline" class="ant-menu-theme-switch"> | 
					
						
							|  |  |  |       <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon> | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  |       <a-switch size="small" :default-checked="themeSwitcher.isDarkTheme" | 
					
						
							|  |  |  |         @change="themeSwitcher.toggleTheme()"></a-switch> | 
					
						
							| 
									
										
										
										
											2024-03-09 13:06:16 +00:00
										 |  |  |       <template v-if="themeSwitcher.isDarkTheme"> | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  |         <a-checkbox style="margin-left: 1rem; vertical-align: middle;" :checked="themeSwitcher.isUltra" | 
					
						
							|  |  |  |           @click="themeSwitcher.toggleUltra()">Ultra</a-checkbox> | 
					
						
							| 
									
										
										
										
											2024-03-09 13:06:16 +00:00
										 |  |  |       </template> | 
					
						
							|  |  |  |     </a-menu-item> | 
					
						
							|  |  |  |   </a-menu> | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  | </template> | 
					
						
							|  |  |  | {{end}} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-17 11:26:07 +00:00
										 |  |  | {{define "component/aThemeSwitch"}} | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  | <script> | 
					
						
							|  |  |  |   function createThemeSwitcher() { | 
					
						
							|  |  |  |     const isDarkTheme = localStorage.getItem('dark-mode') === 'true'; | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |     const isUltra = localStorage.getItem('isUltraDarkThemeEnabled') === 'true'; | 
					
						
							|  |  |  |     if (isUltra) { | 
					
						
							|  |  |  |       document.documentElement.setAttribute('data-theme', 'ultra-dark'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |     const theme = isDarkTheme ? 'dark' : 'light'; | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |     document.querySelector('body').setAttribute('class', theme); | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |     return { | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |       animationsOff() { | 
					
						
							|  |  |  |         document.documentElement.setAttribute('data-theme-animations', 'off'); | 
					
						
							|  |  |  |         const themeAnimations = document.querySelector('#change-theme'); | 
					
						
							|  |  |  |         themeAnimations.addEventListener('mouseleave', () => { | 
					
						
							|  |  |  |           document.documentElement.removeAttribute('data-theme-animations'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         themeAnimations.addEventListener('touchend', () => { | 
					
						
							|  |  |  |           document.documentElement.removeAttribute('data-theme-animations'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       animationsOffUltra() { | 
					
						
							|  |  |  |         document.documentElement.setAttribute('data-theme-animations', 'off'); | 
					
						
							|  |  |  |         const themeAnimationsUltra = document.querySelector('#change-theme-ultra'); | 
					
						
							|  |  |  |         themeAnimationsUltra.addEventListener('mouseleave', () => { | 
					
						
							|  |  |  |           document.documentElement.removeAttribute('data-theme-animations'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         themeAnimationsUltra.addEventListener('touchend', () => { | 
					
						
							|  |  |  |           document.documentElement.removeAttribute('data-theme-animations'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |       isDarkTheme, | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |       isUltra, | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |       get currentTheme() { | 
					
						
							|  |  |  |         return this.isDarkTheme ? 'dark' : 'light'; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       toggleTheme() { | 
					
						
							|  |  |  |         this.isDarkTheme = !this.isDarkTheme; | 
					
						
							|  |  |  |         localStorage.setItem('dark-mode', this.isDarkTheme); | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |         document.querySelector('body').setAttribute('class', this.isDarkTheme ? 'dark' : 'light'); | 
					
						
							| 
									
										
										
										
											2024-02-21 12:02:18 +00:00
										 |  |  |         document.getElementById('message').className = themeSwitcher.currentTheme; | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |       toggleUltra() { | 
					
						
							|  |  |  |         this.isUltra = !this.isUltra; | 
					
						
							|  |  |  |         if (this.isUltra) { | 
					
						
							|  |  |  |           document.documentElement.setAttribute('data-theme', 'ultra-dark'); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           document.documentElement.removeAttribute('data-theme'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         localStorage.setItem('isUltraDarkThemeEnabled', this.isUltra.toString()); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   const themeSwitcher = createThemeSwitcher(); | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  |   Vue.component('a-theme-switch', { | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |     template: `{{template "component/themeSwitchTemplate"}}`, | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |     data: () => ({ | 
					
						
							|  |  |  |       themeSwitcher | 
					
						
							|  |  |  |     }), | 
					
						
							| 
									
										
										
										
											2024-02-21 12:02:18 +00:00
										 |  |  |     mounted() { | 
					
						
							| 
									
										
										
										
											2024-02-28 11:05:01 +00:00
										 |  |  |       this.$message.config({ | 
					
						
							|  |  |  |         getContainer: () => document.getElementById('message') | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2024-02-21 12:02:18 +00:00
										 |  |  |       document.getElementById('message').className = themeSwitcher.currentTheme; | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  |   Vue.component('a-theme-switch-login', { | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |     template: `{{template "component/themeSwitchTemplateLogin"}}`, | 
					
						
							|  |  |  |     data: () => ({ | 
					
						
							|  |  |  |       themeSwitcher | 
					
						
							|  |  |  |     }), | 
					
						
							|  |  |  |     mounted() { | 
					
						
							|  |  |  |       this.$message.config({ | 
					
						
							|  |  |  |         getContainer: () => document.getElementById('message') | 
					
						
							| 
									
										
										
										
											2024-04-01 07:08:22 +00:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2024-04-20 18:45:36 +00:00
										 |  |  |       document.getElementById('message').className = themeSwitcher.currentTheme; | 
					
						
							| 
									
										
										
										
											2024-02-21 12:02:18 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-08 13:45:08 +00:00
										 |  |  |   }); | 
					
						
							|  |  |  | </script> | 
					
						
							| 
									
										
										
										
											2025-03-08 15:41:27 +00:00
										 |  |  | {{end}} |