mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-09 01:16:55 +08:00
@@ -201,6 +201,8 @@ export function createTray () {
|
|||||||
tray!.setImage(`${__static}/menubar.png`)
|
tray!.setImage(`${__static}/menubar.png`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// drop-files only be supported in macOS
|
||||||
|
// so the tray window must be available
|
||||||
tray.on('drop-files', async (event: Event, files: string[]) => {
|
tray.on('drop-files', async (event: Event, files: string[]) => {
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const uploadClipboardFiles = async (): Promise<string> => {
|
|||||||
let img = await uploader.setWebContents(win!.webContents).upload()
|
let img = await uploader.setWebContents(win!.webContents).upload()
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
handleCopyUrl(pasteTemplate(pasteStyle, img[0]))
|
handleCopyUrl(pasteTemplate(pasteStyle, img[0]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
@@ -24,8 +24,9 @@ export const uploadClipboardFiles = async (): Promise<string> => {
|
|||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
db.insert('uploaded', img[0])
|
db.insert('uploaded', img[0])
|
||||||
trayWindow.webContents.send('clipboardFiles', [])
|
// trayWindow just be created in mac/windows, not in linux
|
||||||
trayWindow.webContents.send('uploadFiles', img)
|
trayWindow?.webContents?.send('clipboardFiles', [])
|
||||||
|
trayWindow?.webContents?.send('uploadFiles', img)
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||||
}
|
}
|
||||||
@@ -64,7 +65,8 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
|||||||
result.push(handleUrlEncode(imgs[i].imgUrl!))
|
result.push(handleUrlEncode(imgs[i].imgUrl!))
|
||||||
}
|
}
|
||||||
handleCopyUrl(pasteText.join('\n'))
|
handleCopyUrl(pasteText.join('\n'))
|
||||||
windowManager.get(IWindowList.TRAY_WINDOW)!.webContents.send('uploadFiles', imgs)
|
// trayWindow just be created in mac/windows, not in linux
|
||||||
|
windowManager.get(IWindowList.TRAY_WINDOW)?.webContents?.send('uploadFiles', imgs)
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user