123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { FeedbackStatusEnum } from "@/enums";
- const CacheMap: Record<string, Record<string, any>> = {};
- class FeedBackStatus {
- current: number = 0;
- waitList: string[] = [];
- status: FeedbackStatusEnum = FeedbackStatusEnum.NONE;
- set(module: string, key: string, value: any) {
- if (!CacheMap[module]) {
- CacheMap[module] = {};
- }
- CacheMap[module][key] = value;
- this.status = FeedbackStatusEnum.RUNNING;
- }
- get(module: string, key: string) {
- if (!CacheMap[module]) {
- return null;
- }
- return CacheMap[module][key];
- }
- removeKey(module: string, key: string) {
- this.status = FeedbackStatusEnum.NONE;
- if (!CacheMap[module]) {
- return;
- }
- delete CacheMap[module][key];
- }
- removeModule(module: string) {
- if (!CacheMap[module]) {
- return;
- }
- delete CacheMap[module];
- }
- getAll() {
- return CacheMap;
- }
- getStatus() {
- return this.status;
- }
- setStatus(status: FeedbackStatusEnum) {
- this.status = status;
- }
- }
- const feedbackStatus = new FeedBackStatus();
- export default feedbackStatus;
|