Update common.ts

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

View File

@ -631,17 +631,18 @@ export function setThemeColor (path: string) {
currTheme = theme_color_list[route];
if (currTheme && 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) {
configStore.themeColor = ''
configStore.themeColor = ""
} 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)
uni.setStorageSync('current_theme_color', JSON.stringify(themeColorToHex(currTheme.theme)));
uni.setStorageSync("current_theme_color", JSON.stringify(themeColorToHex(currTheme.theme)))
}
} 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];
configStore.themeColor = 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){
currTheme = theme_color_list.app || Object.values(theme_color_list)[0];
}else if (!current_theme_color && theme_color_list && theme_color_list.length > 0) {
currTheme = theme_color_list.app || Object.values(theme_color_list)[0]
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)))
}
}