Update common.ts

This commit is contained in:
全栈小学生 2025-04-03 15:01:51 +08:00
parent 070dd9ff61
commit 981fd22caa

View File

@ -629,19 +629,20 @@ export function setThemeColor (path: string) {
if (route != 'app') { if (route != 'app') {
try { try {
currTheme = theme_color_list[route]; currTheme = theme_color_list[route];
if(currTheme && currTheme.theme){ if (currTheme && currTheme.theme) {
configStore.themeColor = themeColorToHex(currTheme.theme) configStore.themeColor = themeColorToHex(currTheme.theme)
uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme))); uni.setStorageSync("current_theme_color", JSON.stringify(themeColorToHex(currTheme.theme)))
}else if( !currTheme && current_theme_color){ } else if (!currTheme && current_theme_color) {
configStore.themeColor = '' configStore.themeColor = ""
}else{ } else {
currTheme = theme_color_list.app || Object.values(theme_color_list)[0]; currTheme = theme_color_list.app || Object.values(theme_color_list)[0]
configStore.themeColor = themeColorToHex(currTheme.theme) configStore.themeColor = themeColorToHex(currTheme.theme)
uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme))); uni.setStorageSync("current_theme_color", JSON.stringify(themeColorToHex(currTheme.theme)))
} }
} catch (e) { } catch (e) {
// 设置插件应用的主色调发生错误,若不存在则使用最后有效的主色调 // 设置插件应用的主色调发生错误,若不存在则使用最后有效的主色调
if(!current_theme_color && theme_color_list){
if(!current_theme_color && theme_color_list && theme_color_list.length>0){
currTheme = theme_color_list.app || Object.values(theme_color_list)[0]; currTheme = theme_color_list.app || Object.values(theme_color_list)[0];
configStore.themeColor = themeColorToHex(currTheme.theme) configStore.themeColor = themeColorToHex(currTheme.theme)
uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme))); uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme)));
@ -650,10 +651,10 @@ export function setThemeColor (path: string) {
} }
} }
}else if(!current_theme_color && theme_color_list){ }else if (!current_theme_color && theme_color_list && theme_color_list.length > 0) {
currTheme = theme_color_list.app || Object.values(theme_color_list)[0]; currTheme = theme_color_list.app || Object.values(theme_color_list)[0]
configStore.themeColor = themeColorToHex(currTheme.theme) configStore.themeColor = themeColorToHex(currTheme.theme)
uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme))); uni.setStorageSync("current_theme_color", JSON.stringify(themeColorToHex(currTheme.theme)))
} }
} }