npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xgrn-fetch

v0.0.4

Published

RN容器-网络

Downloads

2

Readme

XGFetch

RN容器-网络模块

功能

网络模块

安装

私有库操作

nrm ls

如果提示nrm命令不存在,如下操作

npm install -g nrm

然后增加私有库地址并使用:


nrm add xgnpm  http://172.16.2.71:4873/
nrm use xgnpm
npm install

安装依赖

$ npm i xgrn-fetch -S

项目配置

Android

react-native link xgrn-fetch

iOS

react-native link xgrn-fetch

库升级

npm update xgrn-fetch    

配置

Android 在MainApplication的onCreat()方法中初始化网络库的操作:

    CoreUtils.init(this.getApplication());
    setDefaultEnv();
     private void initNetwork() {
          FetchService.init(new IFetchExternalParams() {
              @NonNull
              @Override
              public String clientId() {
                  return "tubobo";
              }

              @NonNull
              @Override
              public String clientSecret() {
                  return "tubobo";
              }

              @NonNull
              @Override
              public String clientSource() {
                  return "tubobo";
              }


              @Override
              public String userCenterHost() {
                  return EnvServers.getTBBUserApi();
              }

              @Override
              public String getBussinessApi() {
                  return EnvServers.getTBBApi();
              }

              @Override
              public String getPayApi() {
                  return EnvServers.getPayApi();
              }

              @Override
              public void tokenInValid() {
                  TokenUtils.exitLogin();
                  NavigationUtil.pushToJsPage("auth/LoginPage");
              }

              @Override
              public String mockHost() {
                  return null;
              }

              @Override
              public List<Interceptor> interceptors() {
                  List list = new ArrayList();
                  list.add(new HeadersInterceptor());
                  return list;
              }

              @Override
              public String appVersion() {
                  return "";
              }


              @Override
              public Context getContext() {
                  return getApplicationContext();
              }

              @Override
              public boolean isRelease() {
                  return BuildConfig.BUILD_TYPE.equals("release");
              }

          });
      }

其中clientId,clientSecret,clientSource为需要从服务端获取,baseHost为请求的host,这样初始化就完成了

iOS

pod安装(由于用到了fmdb)

cd ios
pod init
vim Podfile

插入下面的代码

source 'http://git.ops.com/XGN-IOS/xgn.git'
source 'https://github.com/CocoaPods/Specs.git'

target 'XGFetchProject' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for XGFetchProject
  pod 'XGHttpClient'
  pod 'XGAuthObjc'


end

找星云开通私有pod库权限,然后链接

pod repo add xgn http://git.ops.com/XGN-IOS/xgn.git

pod install


pod repo update xgn

pod install

用法

1. 导入XGNavigation
import XGFetch from 'xgrn-fetch'
2. 调用原生发送请求  可传多个参数
XGFetch.fetch(path, body).then((response) => {
     if (response.ok) {
     } else {
             }
 });

API介绍

1.业务层发起请求的调用方式

 /**
    * 业务层发起请求的调用方式(目前仅支持POST请求)
    * @param path      String
    * @param body      Object  请求body
    * @param hostKey      String  主机地址对应的Key
    * @param header    Object  请求header
    * @param option    Object  额外配置.目前仅会添加timeout字段,单位s(秒)
    * @return {*|Promise.<any>|Promise}
    *  返回值格式:
    *      ok:             bool    请求是否成功,resultCode === 0
    *      resultCode:     number  请求状态码。可能为http status 或 系统网络底层错误码 或 业务层错误码
    *      resultDesc:     string  描述一定不空
    *      resultData:     any     当且仅当http(200~300,且业务数据解析正确,且resultCode===0时,服务器返回的数据)
    *  option说明:
    *  目前支持设置timeout, requireToken 不设置会使用默认值
    *  timeout默认值60
    *  requireToken默认值true
    */
   async fetch(path,body,hostKey,header,option){}

2. 登录 (新光用户中心统一登录)

/**
       * 登录
       * @param phone
       * @param password
       * @param type
       * @returns {*|Promise}
       */
login(phone, password, type = "username") {}

3.注册

/**
     * 注册
     * @param phone
     * @param password
     * @param verifyCode
     * @param type
     */
    register(phone, password, verifyCode, type = "name") {}

4.找回密码

   /**
     * 找回密码
     * @param phone
     * @param password
     * @param verifyCode
     * @returns {*}
     */
    findPwd(phone, password, verifyCode) {}

5.发送验证码

  /**
     * 获取验证码
     * @param phone
     * @param type
     * @returns {*}
     */
    sendSMS(phone, type) {}

6.修改密码

/**
      * 修改密码
      * @param newPassword
      * @param oldPassword
      * @returns {*}
      */
 modifyPwd(newPassword, oldPassword) {}

7.获取当前环境

 /**
    * 获取当前环境
    * @returns {*|number}
    * 0 开发环境
    * 1 测试环境
    * 2 预发环境
    * 4 生产环境
    */
   getEnv() {}

8.切换当前环境

 /**
      * 切换当前环境
      * @param envNumber
      * 0 开发环境
      * 1 测试环境
      * 2 预发环境
      * 4 生产环境
      * @returns {*}
      */
 switchEnv(envNumber) {}

9.获取当前环境下key所对应的值

     /**
         * 获取当前环境下key所对应的值
         * @param key
         * @returns {*}
         */
      getEnvValue(key) {

10.清空Token

 /**
  * 清空Token
 */
  clearToken() {}

11.单张图片上传

/**
     * 单张图片上传
     *
     * @param imagePath 需要上传图片的本地路径
     * @param hostKey 图片服务器地址对应的Key
     * @param path 图片服务器地址路径
     * @returns {Promise.<void>}
     */
     
    uploadImage(imagePath,path,hostKey)