How to use the @ant-design/react-native.Toast.loading function in @ant-design/react-native

To help you get started, we’ve selected a few @ant-design/react-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github czy0729 / Bangumi / utils / fetch.js View on Github external
let toastId
  if (isGet) {
    _config.method = 'GET'
    _config.headers = {
      ...defaultHeaders,
      ..._config.headers
    }
    if (Object.keys(body).length) {
      _url += `${_url.includes('?') ? '&' : '?'}${urlStringify(body)}`
    }
  } else {
    _config.method = 'POST'
    _config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    _config.body = urlStringify(body)
    toastId = Toast.loading('Loading...', 8)
  }
  if (SHOW_LOG) {
    log(`[fetchHTML] ${_url}`)
  }

  const isDev = require('../stores/system').default.state.dev
  return fetch(_url, _config)
    .then(res => {
      // 开发模式
      if (isDev) {
        Alert.alert(
          'dev',
          `${JSON.stringify(_url)} ${JSON.stringify(_config)} ${res._bodyInit}`
        )
      }
      if (!isGet) log(method, 'success', _url, _config, res)
github czy0729 / Bangumi / utils / fetch.js View on Github external
export function xhr(
  { method = 'POST', url, data = {} } = {},
  success = Function.prototype,
  fail = Function.prototype
) {
  // 避免userStore循环引用
  const userStore = require('../stores/user').default
  const { cookie: userCookie, userAgent } = userStore.userCookie

  const toastId = Toast.loading('Loading...', 0)
  const request = new XMLHttpRequest()
  request.onreadystatechange = () => {
    if (request.readyState !== 4) {
      return
    }

    if (toastId) {
      Portal.remove(toastId)
    }

    if (request.status === 200) {
      success(request.responseText)
    } else {
      fail(request)
    }
  }
github czy0729 / Bangumi / utils / fetch.js View on Github external
}

  let _url = url
  let toastId
  if (isGet) {
    _config.method = 'GET'

    // 随机数防止接口CDN缓存
    body.state = getTimestamp()
    _url += `?${urlStringify(body)}`
  } else {
    _config.method = 'POST'
    _config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    _config.body = urlStringify(body)
    if (!noConsole) {
      toastId = Toast.loading('Loading...', 0)
    }
  }
  if (SHOW_LOG) {
    log(`[fetchAPI] ${info || _url}`)
  }

  return fetch(_url, _config)
    .then(response => {
      if (toastId) Portal.remove(toastId)
      return response.json()
    })
    .then(json => {
      // 成功后清除失败计数
      if (isGet) {
        const key = `${url}|${urlStringify(data)}`
        if (_retry[key]) _retry[key] = 0
github czy0729 / Bangumi / utils / fetch.ios.js View on Github external
...data
  }

  let _url = url
  let toastKey
  if (isGet) {
    // 随机数防止接口CDN缓存
    body.state = getTimestamp()
    _url = `${url}?${urlStringify(body)}`
  } else {
    _config.method = 'POST'
    _config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    _config.body = urlStringify(body)

    if (!noConsole) {
      toastKey = Toast.loading('Loading...', 0)
    }
  }
  // log(info, _url, !isGet && _config)

  return fetch(_url, _config)
    .then(response => {
      if (toastKey) {
        Portal.remove(toastKey)
      }
      return response.json()
    })
    .then(json => {
      // 成功后清除失败计数
      if (isGet) {
        const key = `${url}|${urlStringify(data)}`
        if (retryCount[key]) {
github czy0729 / Bangumi / utils / fetch.ios.js View on Github external
export function xhr(
  { method = 'POST', url, data = {} } = {},
  success = Function.prototype,
  fail = Function.prototype
) {
  // 避免userStore循环引用
  const userStore = require('../stores/user').default
  const { cookie: userCookie, userAgent } = userStore.userCookie

  const toastKey = Toast.loading('Loading...', 0)
  const request = new XMLHttpRequest()
  request.onreadystatechange = () => {
    if (request.readyState !== 4) {
      return
    }

    if (toastKey) {
      Portal.remove(toastKey)
    }
    if (request.status === 200) {
      success(request.responseText)
    } else {
      fail()
    }
  }
github czy0729 / Bangumi / utils / fetch.ios.js View on Github external
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
      'Accept-Encoding': 'gzip, deflate',
      'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
      'Cache-Control': 'no-cache',
      Connection: 'keep-alive',
      Pragma: 'no-cache',
      Referer: HOST
    }
    if (Object.keys(body).length) {
      _url += `${_url.includes('?') ? '&' : '?'}${urlStringify(body)}`
    }
  } else {
    _config.method = 'POST'
    _config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    _config.body = urlStringify(body)
    toastKey = Toast.loading('Loading...', 8)
  }
  log(`[fetchHTML] ${_url}`)

  const systemStore = require('../stores/system').default
  return fetch(_url, _config)
    .then(res => {
      // 开发模式
      if (systemStore.state.dev) {
        Alert.alert(
          'dev',
          `${JSON.stringify(_url)} ${JSON.stringify(_config)} ${res._bodyInit}`
        )
      }

      // POST打印结果
      if (!isGet) {

@ant-design/react-native

基于蚂蚁金服移动设计规范的 React Native 组件库

MIT
Latest version published 2 days ago

Package Health Score

81 / 100
Full package analysis