import { TypeCommonData } from '../types/types' // 初始动态数据 const commonData: TypeCommonData = { wxLoginStatus: 0, // 0不在线,1在线 globalWxWorkInfo: null, globalGroupList: [], globalWorkTimeArr: [], groupsData: null, sendMsgProcessing: false, accInfo: null, selfwxid: '', isBein: false, hasWelcome: false, // 定时群欢迎,19:30 access_token: '', waitMsgNum: 0 // 未发队列count } // 导出数据 export default { // @ts-ignore 多场景下,这里的类型定义会有问题 get: (key: string): T => commonData[key] as T, set: (key: string, newData: unknown): void => { // 在这里可以添加一些逻辑来验证或处理新数据 // dynamicData = newData; if ( ['selfwxid', 'accInfo', 'access_token', 'wxLoginStatus'].includes(key) && JSON.stringify(newData) !== JSON.stringify(commonData[key]) ) { console.log('commonData.set', key, JSON.stringify(newData)) } commonData[key] = newData } }