mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-05 07:41:58 +08:00
✨ Feature: add workflow for mac
for uploading images from context menu in macOS
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import Uploader from './utils/uploader.js'
|
||||
import { app, BrowserWindow, Tray, Menu, Notification, clipboard, ipcMain, globalShortcut, dialog } from 'electron'
|
||||
import db from '../datastore'
|
||||
import beforeOpen from './utils/beforeOpen'
|
||||
import pasteTemplate from './utils/pasteTemplate'
|
||||
import updateChecker from './utils/updateChecker'
|
||||
import { getPicBeds } from './utils/getPicBeds'
|
||||
@@ -10,6 +11,9 @@ import pkg from '../../package.json'
|
||||
import picgoCoreIPC from './utils/picgoCoreIPC'
|
||||
import fixPath from 'fix-path'
|
||||
import { getUploadFiles } from './utils/handleArgv'
|
||||
if (process.platform === 'darwin') {
|
||||
beforeOpen()
|
||||
}
|
||||
/**
|
||||
* Set `__static` path to static files in production
|
||||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
||||
|
||||
23
src/main/utils/beforeOpen.js
Normal file
23
src/main/utils/beforeOpen.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
if (process.env.DEBUG_ENV === 'debug') {
|
||||
global.__static = path.join(__dirname, '../../../static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
function beforeOpen () {
|
||||
const dest = `${os.homedir}/Library/Services/Upload pictures with PicGo.workflow`
|
||||
if (fs.existsSync(dest)) {
|
||||
return true
|
||||
} else {
|
||||
try {
|
||||
fs.copySync(path.join(__static, 'Upload pictures with PicGo.workflow'), dest)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default beforeOpen
|
||||
Reference in New Issue
Block a user