From a6fd41900f1522f7dba480b73c19b8201cbf1945 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Wed, 16 Nov 2022 19:18:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=83=8C=E6=99=AF=E8=B7=AF=E5=BE=84=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=A9=BA=E6=A0=BC=E6=97=B6=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/utils/common.ts | 3 +-- src/common/utils/electron.ts | 5 +++++ src/main/modules/userApi/main.ts | 2 +- src/main/modules/winLyric/main.ts | 3 ++- src/main/modules/winMain/main.ts | 3 ++- src/main/utils/index.ts | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/utils/common.ts b/src/common/utils/common.ts index 6671cb03..8153f4c3 100644 --- a/src/common/utils/common.ts +++ b/src/common/utils/common.ts @@ -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('\\', '/')) } diff --git a/src/common/utils/electron.ts b/src/common/utils/electron.ts index 25382dda..d772e676 100644 --- a/src/common/utils/electron.ts +++ b/src/common/utils/electron.ts @@ -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') +} diff --git a/src/main/modules/userApi/main.ts b/src/main/modules/userApi/main.ts index fe4a8476..9337f64d 100644 --- a/src/main/modules/userApi/main.ts +++ b/src/main/modules/userApi/main.ts @@ -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 diff --git a/src/main/modules/winLyric/main.ts b/src/main/modules/winLyric/main.ts index d5c25ff4..2ce0ee79 100644 --- a/src/main/modules/winLyric/main.ts +++ b/src/main/modules/winLyric/main.ts @@ -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') diff --git a/src/main/modules/winMain/main.ts b/src/main/modules/winMain/main.ts index e10bd246..10c1fa26 100644 --- a/src/main/modules/winMain/main.ts +++ b/src/main/modules/winMain/main.ts @@ -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 diff --git a/src/main/utils/index.ts b/src/main/utils/index.ts index 0b2d975c..e80cd971 100644 --- a/src/main/utils/index.ts +++ b/src/main/utils/index.ts @@ -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'