@@ -7,12 +7,14 @@ import {changeLanguage} from "@/lang/i18n"
77
88<script lang="ts">
99import {CUSTOM_THEME_COLOR } from " @/config"
10- import {setColorScheme } from " mdui"
10+ import {getTheme , setColorScheme , setTheme } from " mdui"
1111import i18n from " @/lang/i18n"
12+ import type {Theme } from " mdui/internal/theme" ;
1213
1314if (CUSTOM_THEME_COLOR ) setColorScheme (CUSTOM_THEME_COLOR )
1415let path = document .location .pathname .split (' /' ).pop ()
1516let title = (path ) ? ` menu.${path } ` : ' menu.home'
17+
1618function rgbToHex(rgb : string ) {
1719 // 匹配 rgb 或 rgba 值
1820 let result = rgb .match (/ ^ rgba? \( (\d + ),\s * (\d + ),\s * (\d + )(?:,\s * ([01] | 0? \. \d + ))? \) $ / );
@@ -28,7 +30,9 @@ function rgbToHex(rgb: string) {
2830
2931 return ` #${r }${g }${b } ` .toUpperCase (); // 返回大写的 HEX 颜色
3032}
33+
3134document .title = ` ${i18n .global .t (title )} - AIDE Plus `
35+ setTheme ((localStorage .getItem (' theme' ) as Theme ) ?? ' auto' )
3236export default {
3337 data() {
3438 return {
@@ -37,18 +41,18 @@ export default {
3741 }
3842 },
3943 methods: {
40- menuButton() {
44+ async menuButton() {
4145 this .isOpen = ! this .isOpen
4246 },
4347 async menuClick(path : string , title : string ) {
4448 this .$router .push (path ).then (() => {
49+ title = this .$t (title )
50+ this .appBarTitle = title
51+ document .title = ` ${title } - AIDE Plus `
52+ if (window .innerWidth < 840 ) this .isOpen = false
4553 }).catch ((e ) => {
4654 console .log (e )
4755 })
48- title = this .$t (title )
49- this .appBarTitle = title
50- document .title = ` ${title } - AIDE Plus `
51- if (window .innerWidth < 840 ) this .isOpen = false
5256 },
5357 async setColor(event : any ) {
5458 let background = rgbToHex (window .getComputedStyle (event .target , null )
@@ -59,6 +63,10 @@ export default {
5963 async handleColorChange(event : any ) {
6064 localStorage .setItem (' themeColor' , event .target ?.value )
6165 setColorScheme (event .target ?.value )
66+ },
67+ async changeTheme(theme : string ) {
68+ setTheme (theme as Theme )
69+ localStorage .setItem (' theme' , theme )
6270 }
6371 }
6472}
@@ -77,6 +85,16 @@ export default {
7785 </mdui-menu >
7886 </mdui-dropdown >
7987
88+ <mdui-dropdown trigger =" hover" >
89+ <mdui-button-icon icon =" light_mode" slot =" trigger" ></mdui-button-icon >
90+ <mdui-menu class =" menu-theme" selects =" single" :value =" getTheme()" >
91+ <mdui-menu-item class =" light" value =" light" @click =" changeTheme('light')" >{{ $t('menu.theme.light') }}</mdui-menu-item >
92+ <mdui-menu-item class =" dark" value =" dark" @click =" changeTheme('dark')" >{{ $t('menu.theme.dark') }}</mdui-menu-item >
93+ <mdui-divider ></mdui-divider >
94+ <mdui-menu-item class =" auto" value =" auto" @click =" changeTheme('auto')" >{{ $t('menu.theme.auto') }}</mdui-menu-item >
95+ </mdui-menu >
96+ </mdui-dropdown >
97+
8098 <mdui-dropdown trigger =" hover" >
8199 <mdui-button-icon icon =" color_lens" slot =" trigger" ></mdui-button-icon >
82100 <mdui-card data-v-e56655cb =" " class =" card" variant =" elevated" >
0 commit comments