{"version":3,"sources":["tplus-api/../src/model/Channel.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,OAAO,OAAO;IAE1B,SAAS,EAAC,MAAM,CAAC;IACjB,YAAY,EAAC,OAAO,CAAC;IAErB,MAAM,CAAC,SAAS,CAAC,SAAS,KAAA;gBAId,SAAS,KAAA;WASR,UAAU;IAOvB,MAAM,CAAC,UAAU,CAAC,SAAS,KAAA;IAO3B,KAAK;IASL,MAAM,CAAC,KAAK,CAAC,GAAG,KAAA;IAUhB,MAAM,CAAC,OAAO;IAmBd,MAAM,CAAC,KAAK;CAMb","file":"Channel.d.ts","sourcesContent":["import LoginApi from '../api/LoginApi';\nimport {proxyServer,channelKey,channelKeys} from '../const/app';\nimport {localStore} from 'mutants-microfx';\nimport tools from '../util/tools';\nconst emptyChannel = {\n  throughProxy: false,\n  targetURL: 'http://t.chanjet.com/tplus/',\n}\n\nconst userHttpDomain = ['https://t.chanjet.com','https://xjhwt.chanjet.com'];\n\nexport default class Channel {\n\n  targetURL:string;\n  throughProxy:boolean;\n\n  static filterURL(targetURL){\n    return targetURL;\n  }\n\n  constructor(targetURL){\n    this.targetURL = Channel.filterURL(targetURL);\n    if(targetURL.indexOf(proxyServer) > -1){\n      this.throughProxy = true;\n    }else{\n      this.throughProxy = false;\n    }\n  }\n\n  static async getChannel(){\n    const targetURL = await LoginApi.getTargetURL();\n    let channel = new Channel(targetURL);\n    channel.cache();\n    return channel;\n  }\n\n  static setChannel(targetURL){\n    let channel = new Channel(targetURL);\n    channel.cache();\n    return channel;\n  }\n\n  //缓存数据\n  cache(){\n    localStore.set(channelKey,this);\n    channelKeys.forEach((channelKey)=>{\n      if(!tools.isNull(this[channelKey])){\n        localStore.set(channelKey,this[channelKey]);\n      }\n    });\n  }\n\n  static cache(obj){\n    localStore.set(channelKey,obj);\n    channelKeys.forEach((channelKey)=>{\n      if(!tools.isNull(this[channelKey])){\n        localStore.set(channelKey,this[channelKey]);\n      }\n    });\n  }\n\n  //恢复数据\n  static restore(){\n    // let channel =  localStore.get(channelKey);\n    // if(channel == null || channel == undefined){\n    //   channel = emptyChannel;\n    // }\n    // return channel;\n\n    const targetURL = localStore.get('targetURL');\n    if(!tools.isNull(targetURL)){\n      let cacheObj = {};\n      channelKeys.forEach((key)=>{\n        cacheObj[key] = localStore.get(key);\n      });\n      return cacheObj; \n    }\n    return emptyChannel;\n  }\n\n  //清空数据\n  static clear(){\n    localStore.remove(channelKey);\n    channelKeys.forEach((key)=>{\n      localStore.remove(key);\n    });\n  }\n}"]}