卢春龙
2026-08-17 f525b6c3cc105bd1a997d893937689bebcc9570d
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
class GlobalState {
  private data: any;
 
  constructor() {
    this.data = {
      HEADER_LAYOUT: {
        height: 0,
        width: 0,
        x: 0,
        y: 0,
      },
    };
  }
 
  setState(key: string, value: any) {
    this.data[key] = value;
  }
 
  getState(key: string, defaultValue: any = undefined) {
    return this.data[key] || defaultValue;
  }
}
 
export interface GlobalStateType {
  getState: (key: string, defaultValue?: any) => any,
  setState: (key: string, value: any) => void,
}
 
export default new GlobalState();