-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe9e19a
commit f21940e
Showing
7 changed files
with
149 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// from v2.1.2 | ||
const updateShortKeyFromVersion212 = (db, shortKeyConfig) => { | ||
let needUpgrade = false | ||
Object.keys(shortKeyConfig).forEach(item => { | ||
if (typeof shortKeyConfig[item] === 'string') { | ||
needUpgrade = true | ||
shortKeyConfig[item] = { | ||
enable: true, | ||
key: shortKeyConfig[item], | ||
name: `picgo:${item}`, | ||
lable: '快捷上传' | ||
} | ||
} | ||
}) | ||
if (needUpgrade) { | ||
db.read().set('settings.shortKey', shortKeyConfig).write() | ||
return shortKeyConfig | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
export { | ||
updateShortKeyFromVersion212 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { EventEmitter } from 'events' | ||
|
||
const bus = new EventEmitter() | ||
|
||
export default bus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import bus from '../utils/eventBus' | ||
/** | ||
* | ||
* @param {string} name | ||
*/ | ||
const shortKeyHandler = (name) => { | ||
if (name.includes('picgo:')) { | ||
bus.emit(name) | ||
} else if (name.includes('picgo-plugin-')) { | ||
// TODO: 处理插件快捷键 | ||
} | ||
} | ||
|
||
// 初始化阶段的注册 | ||
const initShortKeyRegister = (globalShortcut, shortKeys) => { | ||
let errorList = [] | ||
for (let i in shortKeys) { | ||
try { | ||
if (shortKeys[i].enable) { | ||
globalShortcut.register(shortKeys[i].key, () => { | ||
shortKeyHandler(shortKeys[i].name) | ||
}) | ||
} | ||
} catch (e) { | ||
errorList.push(shortKeys[i]) | ||
} | ||
} | ||
} | ||
|
||
export { | ||
initShortKeyRegister | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,26 @@ | ||
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1 | ||
|
||
param($imagePath) | ||
|
||
# https://github.com/PowerShell/PowerShell/issues/7233 | ||
# fix the output encoding bug | ||
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding | ||
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1 | ||
|
||
Add-Type -Assembly PresentationCore | ||
function main { | ||
$img = [Windows.Clipboard]::GetImage() | ||
|
||
if ($img -eq $null) { | ||
"no image" | ||
Exit 1 | ||
} | ||
$img = [Windows.Clipboard]::GetImage() | ||
|
||
if (-not $imagePath) { | ||
"no image" | ||
Exit 1 | ||
} | ||
|
||
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0) | ||
$stream = [IO.File]::Open($imagePath, "OpenOrCreate") | ||
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder | ||
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null | ||
$encoder.Save($stream) | out-null | ||
$stream.Dispose() | out-null | ||
|
||
$imagePath | ||
if ($img -eq $null) { | ||
"no image" | ||
Exit 1 | ||
} | ||
|
||
try { | ||
# For WIN10 | ||
$file = Get-Clipboard -Format FileDropList | ||
if ($file -ne $null) { | ||
Convert-Path $file | ||
Exit 1 | ||
} | ||
} catch { | ||
# For WIN7 WIN8 WIN10 | ||
main | ||
if (-not $imagePath) { | ||
"no image" | ||
Exit 1 | ||
} | ||
|
||
main | ||
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0) | ||
$stream = [IO.File]::Open($imagePath, "OpenOrCreate") | ||
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder | ||
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null | ||
$encoder.Save($stream) | out-null | ||
$stream.Dispose() | out-null | ||
|
||
$imagePath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1 | ||
param($imagePath) | ||
|
||
# https://github.com/PowerShell/PowerShell/issues/7233 | ||
# fix the output encoding bug | ||
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding | ||
|
||
Add-Type -Assembly PresentationCore | ||
function main { | ||
$img = [Windows.Clipboard]::GetImage() | ||
|
||
if ($img -eq $null) { | ||
"no image" | ||
Exit 1 | ||
} | ||
|
||
if (-not $imagePath) { | ||
"no image" | ||
Exit 1 | ||
} | ||
|
||
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0) | ||
$stream = [IO.File]::Open($imagePath, "OpenOrCreate") | ||
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder | ||
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null | ||
$encoder.Save($stream) | out-null | ||
$stream.Dispose() | out-null | ||
|
||
$imagePath | ||
} | ||
|
||
try { | ||
# For WIN10 | ||
$file = Get-Clipboard -Format FileDropList | ||
if ($file -ne $null) { | ||
Convert-Path $file | ||
Exit 1 | ||
} | ||
} catch { | ||
# For WIN7 WIN8 WIN10 | ||
main | ||
} | ||
|
||
main |