-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathcommon.ts
More file actions
43 lines (38 loc) · 1.26 KB
/
common.ts
File metadata and controls
43 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export type LimitReason =
& Required<Pick<timer.limit.Rule, 'id' | 'cond'>>
& Partial<Pick<timer.limit.Item, 'delayCount' | 'allowDelay'>>
& {
type: timer.limit.ReasonType
getVisitTime?: () => number
}
export function isSameReason(a: LimitReason, b: LimitReason): boolean {
if (a?.id !== b?.id || a?.type !== b?.type) return false
if (a?.type === 'DAILY' || a?.type === 'VISIT') {
// Need judge allow delay
if (a?.allowDelay !== b?.allowDelay) return false
}
return true
}
export interface MaskModal {
addReason(...reasons: LimitReason[]): void
removeReason(...reasons: LimitReason[]): void
removeReasonsByType(...types: timer.limit.ReasonType[]): void
addDelayHandler(handler: () => void): void
}
export type ModalContext = {
url: string
modal: MaskModal
}
export interface Processor {
handleMsg(code: timer.mq.ReqCode, data: unknown): timer.mq.Response | Promise<timer.mq.Response>
init(): void | Promise<void>
}
export async function exitFullscreen(): Promise<void> {
if (!document?.fullscreenElement) return
if (!document?.exitFullscreen) return
try {
await document.exitFullscreen()
} catch (e) {
console.warn('Failed to exit fullscreen', e)
}
}