兼容url格式的主题背景图片
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// return listId == 'download' ? downloadList : getListFromState(listId)
|
||||
// }
|
||||
import { commonColorNames, commonDarkColorValues, commonLightColorValues } from '@common/config'
|
||||
import { isUrl } from '@common/utils/common'
|
||||
import { joinPath } from '@common/utils/nodejs'
|
||||
import { markRaw, shallowReactive } from '@common/utils/vueTools'
|
||||
import { getThemes as getTheme } from '@renderer/utils/ipc'
|
||||
@@ -15,6 +16,12 @@ export const assertApiSupport = (source: LX.Source): boolean => {
|
||||
return source == 'local' || qualityList.value[source] != null
|
||||
}
|
||||
|
||||
export const buildBgUrl = (originUrl: string, dataPath: string): string => {
|
||||
return isUrl(originUrl)
|
||||
? `url(${originUrl})`
|
||||
: `url(file:///${joinPath(dataPath, originUrl).replaceAll('\\', '/')})`
|
||||
}
|
||||
|
||||
export const getThemes = (callback: (themeInfo: LX.ThemeInfo) => void) => {
|
||||
if (themeInfo.themes.length) return callback(themeInfo)
|
||||
void getTheme().then(info => {
|
||||
@@ -27,7 +34,7 @@ export const getThemes = (callback: (themeInfo: LX.ThemeInfo) => void) => {
|
||||
export const buildThemeColors = (theme: LX.Theme, dataPath: string) => {
|
||||
if (theme.isCustom && theme.config.extInfo['--background-image'] != 'none') {
|
||||
theme = copyTheme(theme)
|
||||
theme.config.extInfo['--background-image'] = `url(file:///${joinPath(dataPath, theme.config.extInfo['--background-image']).replaceAll('\\', '/')})`
|
||||
theme.config.extInfo['--background-image'] = buildBgUrl(theme.config.extInfo['--background-image'], dataPath)
|
||||
}
|
||||
const colors: Record<string, string> = {
|
||||
...theme.config.themeColors,
|
||||
|
||||
Reference in New Issue
Block a user