处理路径中存在百分号导致的问题
parent
209bf9e0aa
commit
11d3754c08
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "lx-music-desktop",
|
||||
"version": "2.0.0-beta.3",
|
||||
"version": "2.0.0-beta.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "lx-music-desktop",
|
||||
"version": "2.0.0-beta.3",
|
||||
"version": "2.0.0-beta.4",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "lx-music-desktop",
|
||||
"version": "2.0.0-beta.3",
|
||||
"version": "2.0.0-beta.4",
|
||||
"description": "一个免费的音乐查找助手",
|
||||
"main": "./dist/main.js",
|
||||
"productName": "lx-music-desktop",
|
||||
|
|
|
@ -175,3 +175,8 @@ export const sortInsert = (arr: Array<{ num: number, data: any }>, data: { num:
|
|||
|
||||
arr.splice(left, 0, data)
|
||||
}
|
||||
|
||||
export const encodePath = (path: string) => {
|
||||
// https://github.com/lyswhut/lx-music-desktop/issues/963
|
||||
return path.replaceAll('%', '%25')
|
||||
}
|
||||
|
|
|
@ -27,11 +27,6 @@ export function compareVer(currentVer: string, targetVer: string): -1 | 0 | 1 {
|
|||
return 0
|
||||
}
|
||||
|
||||
export const encodePath = (path: string) => {
|
||||
// https://github.com/lyswhut/lx-music-desktop/issues/963
|
||||
return path.replaceAll('%', '%25')
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
log,
|
||||
|
|
|
@ -7,7 +7,7 @@ import { navigationUrlWhiteList } from '@common/config'
|
|||
import defaultSetting from '@common/defaultSetting'
|
||||
import { closeWindow, isExistWindow as isExistMainWindow, showWindow as showMainWindow } from './modules/winMain'
|
||||
import { createAppEvent, createListEvent } from '@main/event'
|
||||
import { encodePath, isMac, log } from '@common/utils'
|
||||
import { isMac, log } from '@common/utils'
|
||||
import createWorkers from './worker'
|
||||
import { migrateDBData } from './utils/migrate'
|
||||
|
||||
|
@ -84,8 +84,8 @@ export const setUserDataPath = () => {
|
|||
}
|
||||
|
||||
const userDataPath = app.getPath('userData')
|
||||
global.lxDataPath = join(encodePath(userDataPath.replaceAll('\\', '/')), 'LxDatas')
|
||||
global.lxOldDataPath = encodePath(userDataPath.replaceAll('\\', '/'))
|
||||
global.lxOldDataPath = userDataPath
|
||||
global.lxDataPath = join(userDataPath, 'LxDatas')
|
||||
if (!existsSync(global.lxDataPath)) mkdirSync(global.lxDataPath)
|
||||
}
|
||||
|
||||
|
|
|
@ -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, isWin } from '@common/utils'
|
||||
import { encodePath } from '@common/utils'
|
||||
|
||||
let browserWindow: Electron.BrowserWindow | null = null
|
||||
|
||||
|
@ -27,14 +27,14 @@ const winEvent = () => {
|
|||
|
||||
export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
|
||||
await closeWindow()
|
||||
if (!dir) dir = global.isDev ? webpackUserApiPath : join(encodePath(isWin ? __dirname.replaceAll('\\', '/') : __dirname), 'userApi')
|
||||
if (!dir) dir = global.isDev ? webpackUserApiPath : join(encodePath(__dirname), 'userApi')
|
||||
|
||||
if (!html) {
|
||||
html = await fs.promises.readFile(join(dir, 'renderer/user-api.html'), 'utf8')
|
||||
}
|
||||
const preloadUrl = global.isDev
|
||||
? `${join(encodePath(isWin ? __dirname.replaceAll('\\', '/') : __dirname), '../dist/user-api-preload.js')}`
|
||||
: `${join(encodePath(isWin ? __dirname.replaceAll('\\', '/') : __dirname), 'user-api-preload.js')}`
|
||||
? `${join(encodePath(__dirname), '../dist/user-api-preload.js')}`
|
||||
: `${join(encodePath(__dirname), 'user-api-preload.js')}`
|
||||
// console.log(preloadUrl)
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { join } from 'path'
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { debounce, encodePath, isLinux, isWin } from '@common/utils'
|
||||
import { debounce, encodePath, isLinux } from '@common/utils'
|
||||
import { getLyricWindowBounds } from './utils'
|
||||
import { mainSend } from '@common/mainIpc'
|
||||
|
||||
|
@ -133,7 +133,7 @@ export const createWindow = () => {
|
|||
},
|
||||
})
|
||||
|
||||
const winURL = global.isDev ? 'http://localhost:9081/lyric.html' : `file://${join(encodePath(isWin ? __dirname.replaceAll('\\', '/') : __dirname), 'lyric.html')}`
|
||||
const winURL = global.isDev ? 'http://localhost:9081/lyric.html' : `file://${join(encodePath(__dirname), 'lyric.html')}`
|
||||
void browserWindow.loadURL(winURL + `?dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`)
|
||||
|
||||
winEvent()
|
||||
|
|
|
@ -93,7 +93,7 @@ export const createWindow = () => {
|
|||
}
|
||||
browserWindow = new BrowserWindow(options)
|
||||
|
||||
const winURL = global.isDev ? 'http://localhost:9080' : `file://${join(encodePath(isWin ? __dirname.replaceAll('\\', '/') : __dirname), 'index.html')}`
|
||||
const winURL = global.isDev ? 'http://localhost:9080' : `file://${join(encodePath(__dirname), 'index.html')}`
|
||||
void browserWindow.loadURL(winURL + `?dt=${!!global.envParams.cmdParams.dt}&dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`)
|
||||
|
||||
winEvent()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { isUrl, throttle } from '@common/utils'
|
||||
import { encodePath, isUrl, throttle } from '@common/utils'
|
||||
import migrateSetting from '@common/utils/migrateSetting'
|
||||
import getStore from '@main/utils/store'
|
||||
import { STORE_NAMES, URL_SCHEME_RXP } from '@common/constants'
|
||||
|
@ -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:///${joinPath(global.lxDataPath, 'theme_images', theme.config.extInfo['--background-image']).replaceAll('\\', '/')})`
|
||||
: `url(file:///${encodePath(joinPath(global.lxDataPath, 'theme_images', theme.config.extInfo['--background-image']).replaceAll('\\', '/'))})`
|
||||
}
|
||||
} else {
|
||||
themeId = global.lx.appSetting['theme.id'] == 'auto' && shouldUseDarkColors ? 'black' : 'green'
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue