处理路径中存在百分号导致的问题
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { encodePath } from '@common/utils/common'
|
||||
import { updateListMusics } from '@renderer/store/list/action'
|
||||
import { saveLyric, saveMusicUrl } from '@renderer/utils/ipc'
|
||||
import { getLocalFilePath } from '@renderer/utils/music'
|
||||
@@ -19,7 +20,7 @@ export const getMusicUrl = async({ musicInfo, isRefresh, onToggleSource = () =>
|
||||
}): Promise<string> => {
|
||||
if (!isRefresh) {
|
||||
const path = await getLocalFilePath(musicInfo)
|
||||
if (path) return path
|
||||
if (path) return encodePath(path)
|
||||
}
|
||||
onToggleSource()
|
||||
const otherSource = await getOtherSource(musicInfo)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// return listId == 'download' ? downloadList : getListFromState(listId)
|
||||
// }
|
||||
import { commonColorNames, commonDarkColorValues, commonLightColorValues } from '@common/config'
|
||||
import { isUrl } from '@common/utils/common'
|
||||
import { encodePath, 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'
|
||||
@@ -19,7 +19,7 @@ export const assertApiSupport = (source: LX.Source): boolean => {
|
||||
export const buildBgUrl = (originUrl: string, dataPath: string): string => {
|
||||
return isUrl(originUrl)
|
||||
? `url(${originUrl})`
|
||||
: `url(file:///${joinPath(dataPath, originUrl).replaceAll('\\', '/')})`
|
||||
: `url(file:///${encodePath(joinPath(dataPath, originUrl).replaceAll('\\', '/'))})`
|
||||
}
|
||||
|
||||
export const getThemes = (callback: (themeInfo: LX.ThemeInfo) => void) => {
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
import { joinPath, extname, copyFile, checkPath, createDir, removeFile, moveFile, basename } from '@common/utils/nodejs'
|
||||
import { nextTick, ref, watch } from '@common/utils/vueTools'
|
||||
import { applyTheme, buildThemeColors, getThemes, copyTheme } from '@renderer/store/utils'
|
||||
import { isUrl } from '@common/utils/common'
|
||||
import { isUrl, encodePath } from '@common/utils/common'
|
||||
// import { appSetting, updateSetting } from '@renderer/store/setting'
|
||||
// import { applyTheme, getThemes } from '@renderer/store/utils'
|
||||
import { createThemeColors } from '@common/theme/utils'
|
||||
@@ -158,6 +158,7 @@ export default {
|
||||
const isDark = ref(false)
|
||||
const preview = ref(false)
|
||||
const bgImg = ref('')
|
||||
let bgImgRaw = ''
|
||||
let originBgName = ''
|
||||
let currentBgPath = ''
|
||||
|
||||
@@ -243,11 +244,13 @@ export default {
|
||||
currentBgPath = ''
|
||||
if (theme.config.extInfo['--background-image'] == 'none') {
|
||||
bgImg.value = ''
|
||||
bgImgRaw = ''
|
||||
originBgName = ''
|
||||
} else {
|
||||
bgImg.value = isUrl(theme.config.extInfo['--background-image'])
|
||||
bgImgRaw = isUrl(theme.config.extInfo['--background-image'])
|
||||
? theme.config.extInfo['--background-image']
|
||||
: joinPath(themeInfo.dataPath, theme.config.extInfo['--background-image'])
|
||||
bgImg.value = encodePath(bgImgRaw)
|
||||
originBgName = theme.config.extInfo['--background-image']
|
||||
}
|
||||
appBgColorOrigin = theme.config.extInfo['--color-app-background']
|
||||
@@ -372,7 +375,8 @@ export default {
|
||||
const bgPath = joinPath(tempDir, fileName)
|
||||
if (!await checkPath(tempDir)) await createDir(tempDir)
|
||||
await copyFile(path, bgPath)
|
||||
currentBgPath = bgImg.value = bgPath
|
||||
currentBgPath = bgImgRaw = bgPath
|
||||
bgImg.value = encodePath(bgImgRaw)
|
||||
theme.config.extInfo['--background-image'] = 'temp/' + fileName
|
||||
|
||||
createPreview()
|
||||
@@ -383,6 +387,7 @@ export default {
|
||||
currentBgPath = ''
|
||||
}
|
||||
bgImg.value = ''
|
||||
bgImgRaw = ''
|
||||
theme.config.extInfo['--background-image'] = 'none'
|
||||
createPreview()
|
||||
}
|
||||
@@ -474,9 +479,9 @@ export default {
|
||||
const name = basename(currentBgPath)
|
||||
await moveFile(currentBgPath, joinPath(themeInfo.dataPath, name))
|
||||
theme.config.extInfo['--background-image'] = name
|
||||
} else if (bgImg.value) {
|
||||
const fileName = `${theme.id}_${Date.now()}${extname(bgImg.value)}`
|
||||
await copyFile(bgImg.value, joinPath(themeInfo.dataPath, fileName))
|
||||
} else if (bgImgRaw) {
|
||||
const fileName = `${theme.id}_${Date.now()}${extname(bgImgRaw)}`
|
||||
await copyFile(bgImgRaw, joinPath(themeInfo.dataPath, fileName))
|
||||
theme.config.extInfo['--background-image'] = fileName
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user