Feature: add remoteNotice

This commit is contained in:
PiEgg
2022-10-30 16:08:29 +08:00
parent a355bc07f4
commit 9317871fdb
7 changed files with 277 additions and 4 deletions

View File

@@ -27,3 +27,22 @@ export enum IWindowList {
MINI_WINDOW = 'MINI_WINDOW',
RENAME_WINDOW = 'RENAME_WINDOW'
}
export enum IRemoteNoticeActionType {
OPEN_URL = 'OPEN_URL',
SHOW_NOTICE = 'SHOW_NOTICE', // notification
SHOW_DIALOG = 'SHOW_DIALOG', // dialog notice
COMMON = 'COMMON',
VOID = 'VOID', // do nothing
SHOW_MESSAGE_BOX = 'SHOW_MESSAGE_BOX'
}
export enum IRemoteNoticeTriggerHook {
APP_START = 'APP_START',
SETTING_WINDOW_OPEN = 'SETTING_WINDOW_OPEN',
}
export enum IRemoteNoticeTriggerCount {
ONCE = 'ONCE', // default
ALWAYS = 'ALWAYS'
}

View File

@@ -219,6 +219,8 @@ interface IPrivateShowNotificationOption extends IShowNotificationOption{
* click notification to copy the body
*/
clickToCopy?: boolean
copyContent?: string // something to copy
clickFn?: () => void
}
interface IShowMessageBoxOption {
@@ -348,3 +350,42 @@ interface II18nItem {
label: string
value: string
}
interface IRemoteNotice {
version: number
list: Array<{
versions: string[] // matched picgo version
actions: IRemoteNoticeAction[]
versionMatch?: 'exact' | 'gte' | 'lte'
}>
}
interface IRemoteNoticeAction {
type: import('#/types/enum').IRemoteNoticeActionType
// trigger time
hooks: import('#/types/enum').IRemoteNoticeTriggerHook[]
id: string
// trigger count: always or once; default: once
triggerCount: import('#/types/enum').IRemoteNoticeTriggerCount
data?: {
title?: string
content?: string
desc?: string // action desc
buttons?: IRemoteNoticeButton[]
url?: string
copyToClipboard?: string
options: any // for other case
}
}
interface IRemoteNoticeButton {
label: string
labelEN?: string
type: 'confirm' | 'cancel' | 'other'
action: IRemoteNoticeAction
}
interface IRemoteNoticeLocalCountStorage {
[id: string]: true | number
}

View File

@@ -41,3 +41,5 @@ export const simpleClone = (obj: any) => {
export const enforceNumber = (num: number | string) => {
return isNaN(Number(num)) ? 0 : Number(num)
}
export const isDev = process.env.NODE_ENV === 'development'