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

react-native-qiji-updater

v1.0.7

Published

<!-- react app更新模块 -->

Downloads

5

Readme

react-native-qiji-updater

npm version

React native应用更新的逻辑及UI的封装

TOC

Installation

Using npm:

npm install --save react-native-qiji-updater

or using yarn:

yarn add react-native-qiji-updater

Usage

import * as Updater from 'react-native-qiji-updater';

API

| Method | Return Type | Description | | ----------------------------------------------------------------- | ------------------- | ---------------- | | init(config:Object) | void | 初始化 | | checkUpdate() | Promise<> | 版本检测(兼容android,ios) | | checkAndroidUpdate() | Promise<> | android版本检测 | | checkIosUpdate() | Promise<> | ios版本检测 |


init(config:Object)

初始化更新参数

Examples

Updater.init({
    checkUrl:'http://127.0.0.1',
    checkSuccess:  (res) => {...},
    checkError: (err) => {...},
    downloadProgress: (res) => {...},
    downloadSuccess: (res) =>{...},
    downloadError: (err) => {...},
    installSuccess: (res) => {...},
    installError: (err) => {...},
    progressModal: this.progressModal.current
});

参数说明

| name | Type | Description |
| ----------------------------------------| ------------------- | ------------------ | | checkUrl | String | 更新检测服务端地址 |
| checkSuccess | Function | 检测成功回调 | | checkError | Function | 检测失败回调 | | downloadProgress | Function | 检测成功回调 | | downloadSuccess | Function | 检测成功回调 | | downloadError | Function | 检测失败回调 | | installSuccess | Function | 安装成功回调 | | installError | Function | 安装失败回调 | | progressModal | UI Component | 下载进度框 |

checkSuccess

Android
//有更新内容
{"data": {"app_id": "com.demo", "app_name": "更新DEMO", "app_url": "http://xxxxxx/xxx.apk", "description": "v1.0.1:新增支付模块", "is_force": false, "title": "更新安装包", "ver": "1.0.1"}, "success": true}
//无更新内容
{"data":false, "success": true}

Name | Type | Description | --------------------|-----------|---------------------------| app_id | String | 应用ID | app_name | String | 应用名称 | app_url | String | 安装包下载地址 | description | String | 更新描述 | is_force | boolean | 是否强制更新 | title | String | 更新提示标题 | ver | String | 版本 |

checkError

Android
{'success' => false, 'msg' => xxxxx];

checkUpdate()

更新检测

Examples

Updater.checkUpdate();

checkAndroidUpdate()

Android更新检测

Examples

Updater.checkAndroidUpdate();

checkIosUpdate()

IOS更新检测

Examples

Updater.checkIosUpdate();

UI组件


ProgressModal

进度提示框

Examples

<Updater.ProgressModal ref={this.refProgressModal} titleBgColor="#f7977a" title="下载安装包"></Updater.ProgressModal>

Props

Name | Default | Type | Description | --------------------|--------------------------------------|----------|---------------------------| title | 文件下载中 | String | 标题 | titleBgColor | #0080ff | String | 标题背景色 | barBgColor | #e0e0e0 | String | 进度条背景色 | barColor | #0080ff | String | 进度条颜色色 | visible | false | boolean | 是否显示 | onClose | 空 | Function | 窗口关闭时的回调 | total | 1 | Number | 总数 | progress | 0 | Number | 当前进度 |


示例

import React, { Component } from 'react';
import { StyleSheet, Button, View, SafeAreaView, Text} from 'react-native';
import * as Updater from 'react-native-qiji-updater';

const Separator = () => {
  return <View style={styles.separator} />;
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginHorizontal: 16,
  },
  title: {
    textAlign: 'center',
    marginVertical: 8,
  },
  fixToText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  separator: {
    marginVertical: 8,
    borderBottomColor: '#737373',
    borderBottomWidth: StyleSheet.hairlineWidth,
  },
});

export default class App extends Component {
  constructor(props) {
    super(props);
    this.refProgressModal = React.createRef();
  }
  componentDidMount() {
    Updater.init({
      progressModal: this.refProgressModal.current
    });
  }

  onUpdate() {
    Updater.checkUpdate();
  }
  render() {
    return (
      <SafeAreaView style={styles.container}>
        <Updater.ProgressModal ref={this.refProgressModal} titleBgColor="#f7977a" title="更新下载"></Updater.ProgressModal>
        <View>
          <Text style={styles.title}>
            点击按钮测试更新
          </Text>
          <Button
            title="更新检测"
            onPress={this.onUpdate.bind(this)}
          />
        </View>
        <Separator />
      </SafeAreaView>
    );
  }
}