修复自定义主题背景路径存在空格时无法显示的问题

pull/1053/head
lyswhut 2022-11-16 19:18:59 +08:00
parent 7daa626d55
commit a6fd41900f
6 changed files with 12 additions and 6 deletions

View File

@ -177,8 +177,7 @@ export const sortInsert = (arr: Array<{ num: number, data: any }>, data: { num:
}
export const encodePath = (path: string) => {
// https://github.com/lyswhut/lx-music-desktop/issues/963
return path.replaceAll('%', '%25')
return encodeURI(path.replaceAll('\\', '/'))
}

View File

@ -36,3 +36,8 @@ export const clipboardReadText = (): string => {
return clipboard.readText()
}
export const encodePath = (path: string) => {
// https://github.com/lyswhut/lx-music-desktop/issues/963
return path.replaceAll('%', '%25')
}

View File

@ -3,7 +3,7 @@ import { BrowserWindow } from 'electron'
import fs from 'fs'
import { join } from 'path'
import { openDevTools as handleOpenDevTools } from '@main/utils'
import { encodePath } from '@common/utils'
import { encodePath } from '@common/utils/electron'
let browserWindow: Electron.BrowserWindow | null = null

View File

@ -1,8 +1,9 @@
import { join } from 'path'
import { BrowserWindow } from 'electron'
import { debounce, encodePath, isLinux } from '@common/utils'
import { debounce, isLinux } from '@common/utils'
import { getLyricWindowBounds } from './utils'
import { mainSend } from '@common/mainIpc'
import { encodePath } from '@common/utils/electron'
// require('./event')
// require('./rendererEvent')

View File

@ -1,10 +1,11 @@
import { BrowserWindow, dialog } from 'electron'
import { join } from 'path'
import { createTaskBarButtons, getWindowSizeInfo } from './utils'
import { encodePath, isLinux, isWin } from '@common/utils'
import { isLinux, isWin } from '@common/utils'
import { openDevTools as handleOpenDevTools } from '@main/utils'
import { mainSend } from '@common/mainIpc'
import { sendFocus, sendTaskbarButtonClick } from './rendererEvent'
import { encodePath } from '@common/utils/electron'
let browserWindow: Electron.BrowserWindow | null = null

View File

@ -250,7 +250,7 @@ export const getTheme = () => {
theme.config.extInfo['--background-image'] =
isUrl(theme.config.extInfo['--background-image'])
? `url(${theme.config.extInfo['--background-image']})`
: `url(file:///${encodePath(joinPath(global.lxDataPath, 'theme_images', theme.config.extInfo['--background-image']).replaceAll('\\', '/'))})`
: `url(file:///${encodePath(joinPath(global.lxDataPath, 'theme_images', theme.config.extInfo['--background-image']))})`
}
} else {
themeId = global.lx.appSetting['theme.id'] == 'auto' && shouldUseDarkColors ? 'black' : 'green'