-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 修复强制升级展示 * chore: 升级版本号
- Loading branch information
Showing
8 changed files
with
99 additions
and
33 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,42 @@ | ||
import EventEmitter3 from 'eventemitter3'; | ||
|
||
export type IEventListener = EventEmitter3.EventListener<any, any>; | ||
|
||
export type IEventListenerRemover = () => void; | ||
|
||
class EventManager extends EventEmitter3 { | ||
listen( | ||
eventName: string, | ||
listener: IEventListener, | ||
once?: boolean, | ||
): IEventListenerRemover { | ||
if (once) { | ||
this.once(eventName, listener); | ||
} else { | ||
this.on(eventName, listener); | ||
} | ||
|
||
return () => { | ||
this.remove(eventName, listener); | ||
}; | ||
} | ||
|
||
listenOnce( | ||
eventName: string, | ||
listener: IEventListener, | ||
): IEventListenerRemover { | ||
return this.listen(eventName, listener, true); | ||
} | ||
|
||
remove(eventName: string, listener?: IEventListener) { | ||
this.off(eventName, listener); | ||
} | ||
|
||
notify(eventName: string, ...params: any) { | ||
this.emit(eventName, ...params); | ||
} | ||
} | ||
|
||
const eventManager = new EventManager(); | ||
|
||
export default eventManager; |
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,6 @@ | ||
export enum AppEvents { | ||
/** | ||
* 强制升级 | ||
*/ | ||
FORCE_UPGRADE_VERSION = 'FORCE_UPGRADE_VERSION', | ||
} |
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
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