mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
✨ Feature: support commandline -> upload images in clipboard
This commit is contained in:
parent
407b821aca
commit
74c7016d2c
@ -501,7 +501,10 @@ if (!gotTheLock) {
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
let files = getUploadFiles(commandLine, workingDirectory)
|
||||
if (files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动
|
||||
if (files === null || files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动
|
||||
if (files === null) {
|
||||
uploadClipboardFiles()
|
||||
} else {
|
||||
let win
|
||||
if (miniWindow && miniWindow.isVisible()) {
|
||||
win = miniWindow
|
||||
@ -509,6 +512,7 @@ if (!gotTheLock) {
|
||||
win = settingWindow || window || createSettingWindow()
|
||||
}
|
||||
uploadChoosedFiles(win.webContents, files)
|
||||
}
|
||||
} else {
|
||||
if (settingWindow) {
|
||||
if (settingWindow.isMinimized()) {
|
||||
@ -542,7 +546,10 @@ app.on('ready', () => {
|
||||
})
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
let files = getUploadFiles()
|
||||
if (files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动
|
||||
if (files === null || files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动
|
||||
if (files === null) {
|
||||
uploadClipboardFiles()
|
||||
} else {
|
||||
let win
|
||||
if (miniWindow && miniWindow.isVisible()) {
|
||||
win = miniWindow
|
||||
@ -552,6 +559,7 @@ app.on('ready', () => {
|
||||
uploadChoosedFiles(win.webContents, files)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
@ -2,6 +2,11 @@ import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
const getUploadFiles = (argv = process.argv, cwd = process.cwd()) => {
|
||||
let files = argv.slice(1)
|
||||
if (files.length > 0 && files[0] === 'upload') {
|
||||
if (files.length === 1) {
|
||||
return null // for uploading images in clipboard
|
||||
} else if (files.length > 1) {
|
||||
files = argv.slice(1)
|
||||
let result = []
|
||||
if (files.length > 0) {
|
||||
result = files.map(item => {
|
||||
@ -22,6 +27,9 @@ const getUploadFiles = (argv = process.argv, cwd = process.cwd()) => {
|
||||
}).filter(item => item !== null)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export {
|
||||
|
Loading…
Reference in New Issue
Block a user