tplus-api
TypeScript icon, indicating that this package has built-in type declarations

4.0.20 • Public • Published

tplusApi -> T+前端网关库

模块说明

  • 云账号登录/注销
  • 注销拦截器
  • 阿里云webtrace日志上报

编写说明

  • 使用typescript

依赖模块

  • mutants-microfx
  • mutants-jsbridge
  • mutants-log

登录 + 注销 + 拦截器 + 请求 + 阿里云日志(代码示例)

const login = async ()=>{
      registerLogoutMiddleWare('loginOut',()=>{
        console.log('注销后...');
      });
      //用户认证 获取企业列表
      const user:User = await User.authentication('${username}','${password}');
      //过滤企业
      let tcOrgs:Array<any> = _filter(user.orgList,org=>org.orgFullName === '${orgName}');
      if(tcOrgs.length > 0){
       const tcOrgId:string = tcOrgs[0].orgId;
       //初始化通道
       await user.initChannel(tcOrgId);
       //登录T+
       await user.loginTplus({});
       console.log('user.logined======',user);
       const response = await tApi({},'${methodName}',false,false);
       console.log('response======',response);
       //用户注销
       User.logout();
       try{
        const response1 = await tApi({},'${methodName}',false,false);
        console.log('logout.response======',response1);
       }catch(e){
        //将API错误日志进行上报
        serverLog('${logstore}',{eventId:'api_error',...e});
       }
      }
};

Readme

Keywords

Package Sidebar

Install

npm i tplus-api

Weekly Downloads

107

Version

4.0.20

License

ISC

Unpacked Size

428 kB

Total Files

113

Last publish

Collaborators

  • tplus