🚧 WIP: almost finish shortKey system

This commit is contained in:
Molunerfinn
2019-12-22 17:22:32 +08:00
parent b8ec879e23
commit fec4360043
17 changed files with 384 additions and 341 deletions

View File

@@ -37,7 +37,7 @@ class DB {
this.db.set('settings.shortKey[picgo:upload]', {
enable: true,
key: 'CommandOrControl+Shift+P',
name: 'picgo:upload',
name: 'upload',
label: '快捷上传'
}).write()
}
@@ -58,6 +58,9 @@ class DB {
// @ts-ignore
return this.read().get(key).insert(value).write()
}
unset (key: string, value: any): boolean {
return this.read().get(key).unset(value).write()
}
}
export default new DB()

View File

@@ -1,9 +1,9 @@
// global
interface Obj {
interface IObj {
[propName: string]: any
}
interface ObjT<T> {
interface IObjT<T> {
[propName: string]: T
}
@@ -31,6 +31,14 @@ interface IShortKeyConfig {
key: string // 按键
name: string
label: string
from?: string
}
interface IPluginShortKeyConfig {
key: string
name: string
label: string
handle: IShortKeyHandler
}
interface IShortKeyConfigs {
@@ -41,6 +49,11 @@ interface IOldShortKeyConfigs {
upload: string
}
interface IKeyCommandType {
key: string,
command: string
}
// Main process
interface IBrowserWindowOptions {
height: number,
@@ -83,7 +96,7 @@ declare type ILogType = 'success' | 'info' | 'warn' | 'error'
declare var __static: string
// PicGo Types
type ICtx = import('picgo')
interface IPicGoPlugin {
name: string
author: string
@@ -135,14 +148,53 @@ interface INPMSearchResultObject {
}
// GuiApi
interface IGuiApi {
showInputBox: (options: IShowInputBoxOption) => Promise<string>
showFileExplorer: (options: IShowFileExplorerOption) => Promise<string>
upload: (input: IUploadOption) => Promise<ImgInfo[]>
showNotification: (options?: IShowNotificationOption) => void
showMessageBox: (options?: IShowMessageBoxOption) => Promise<IShowMessageBoxResult>
}
interface IShowInputBoxOption {
title: string
placeholder: string
}
// PicBeds
type IShowFileExplorerOption = IObj
type IUploadOption = undefined | string[]
interface IShowNotificationOption {
title: string
body: string
}
interface IShowMessageBoxOption {
title: string
message: string
type: string
buttons: string[]
}
interface IShowMessageBoxResult {
result: number
checkboxChecked: boolean
}
interface IShortKeyHandlerObj {
handle: IShortKeyHandler
key: string
label: string
}
type IShortKeyHandler = (ctx: ICtx, guiApi?: IGuiApi) => Promise<void | ICtx>
interface shortKeyHandlerMap {
from: string
handle: IShortKeyHandler
}
// PicBeds
interface IAliYunConfig {
accessKeyId: string
accessKeySecret: string,
@@ -193,3 +245,5 @@ interface IUpYunConfig {
options: string,
path: string
}
type ILoggerType = string | Error | boolean | number | undefined

View File

@@ -9,6 +9,6 @@ interface ISettingForm {
logLevel: string[]
}
interface ShortKeyMap {
interface IShortKeyMap {
[propName: string]: string
}