mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-28 03:30:24 +08:00
🐛 Fix: macos clipboard image can't show on tray page
ISSUES CLOSED: #961
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import fs from 'fs-extra'
|
||||
import db from '~/main/apis/core/datastore'
|
||||
import { clipboard, Notification, dialog } from 'electron'
|
||||
|
||||
@@ -69,3 +70,19 @@ export const calcDurationRange = (duration: number) => {
|
||||
// max range
|
||||
return 100000
|
||||
}
|
||||
|
||||
/**
|
||||
* macOS public.file-url will get encoded file path,
|
||||
* so we need to decode it
|
||||
*/
|
||||
export const ensureFilePath = (filePath: string, prefix = 'file://'): string => {
|
||||
filePath = filePath.replace(prefix, '')
|
||||
if (fs.existsSync(filePath)) {
|
||||
return `${prefix}${filePath}`
|
||||
}
|
||||
filePath = decodeURIComponent(filePath)
|
||||
if (fs.existsSync(filePath)) {
|
||||
return `${prefix}${filePath}`
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user