mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-28 03:26:56 +08:00
🐛 Fix: fix macos right click menu file bug
This commit is contained in:
@@ -16,6 +16,30 @@ function beforeOpen () {
|
|||||||
resolveOtherI18nFiles()
|
resolveOtherI18nFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyFileOutsideOfElectronAsar (
|
||||||
|
sourceInAsarArchive: string,
|
||||||
|
destOutsideAsarArchive: string
|
||||||
|
) {
|
||||||
|
if (fs.existsSync(sourceInAsarArchive)) {
|
||||||
|
// file will be copied
|
||||||
|
if (fs.statSync(sourceInAsarArchive).isFile()) {
|
||||||
|
const file = destOutsideAsarArchive
|
||||||
|
const dir = path.dirname(file)
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true })
|
||||||
|
}
|
||||||
|
fs.writeFileSync(file, fs.readFileSync(sourceInAsarArchive))
|
||||||
|
} else if (fs.statSync(sourceInAsarArchive).isDirectory()) {
|
||||||
|
fs.readdirSync(sourceInAsarArchive).forEach(function (fileOrFolderName) {
|
||||||
|
copyFileOutsideOfElectronAsar(
|
||||||
|
`${sourceInAsarArchive}/${fileOrFolderName}`,
|
||||||
|
`${destOutsideAsarArchive}/${fileOrFolderName}`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macOS 右键菜单
|
* macOS 右键菜单
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +47,7 @@ function resolveMacWorkFlow () {
|
|||||||
const dest = `${os.homedir()}/Library/Services/Upload pictures with PicList.workflow`
|
const dest = `${os.homedir()}/Library/Services/Upload pictures with PicList.workflow`
|
||||||
if (fs.existsSync(dest)) return true
|
if (fs.existsSync(dest)) return true
|
||||||
try {
|
try {
|
||||||
fs.copySync(path.join(__static, 'Upload pictures with PicList.workflow'), dest)
|
copyFileOutsideOfElectronAsar(path.join(__static, 'Upload pictures with PicList.workflow'), dest)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user