GithubHelp home page GithubHelp logo

sancerain / wp-h5plus-update Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 7 KB

h5+ App通过Wordpress检查更新

Home Page: https://sancerain.com/88.shtml

License: MIT License

PHP 100.00%
wordpress wordpress-plugin update-checker update-service dcloud h5plus wap2app sancerain

wp-h5plus-update's Introduction

WP H5Plus Update

简介

通过Wordpress,dcloud旗下的h5+应用(包括但不限于5+、wap2app等格式)可以借助此插件灵活地在线检测新版本。 插件由山茨昕雨开发并开源,使用MIT协议进行分发。

快速上手

配置参数

在阁下Wordpress网站后台中,进入 设置>APP参数修改,按需修改以下参数:

  • 应用ID
  • 应用版本号
  • 内部版本号
  • 更新标题
  • 更新日志 此项目可用php换行符“\n”对文本进行换行
  • 下载链接
  • 重要性 此项目分两种,字符“1”为重要,字符“0”为不重要

以上参数中部分可以在你的应用源码中的mainfest.json文件中查看,保存更新后需要手动更新页面来查看你配置的参数

新建页面

在Wordpress中新建一个页面,选择页面类型为“安卓更新接口模板”,设置好Url即可开始请求

调试页面

在阁下的Url后面添加并修改以下字符:?appid=阁下的应用ID&version=阁下的应用版本号 例如:https://exmaple.com/check/update?appid=__W2A__exmaple.com&version=1.0

客户端配置

JavaScript代码分两种模式,本代码仅包含Core,配置时请更改检查更新地址,其他业务实现请自行编辑代码。

开屏自动更新

var ua = navigator.userAgent;
//Html5Plus环境,但不是流应用环境  
if (ua.indexOf('Html5Plus') > -1 && ua.indexOf('StreamApp') == -1) {
	var url = "https://exmaple.com/check/update"; //检查更新地址  
	var req = { //升级检测数据
		"appid": plus.runtime.appid,
		"version": plus.runtime.version
	};
	wap2app.ajax.get(url, req, function(rsp) {
		if (rsp.level == 1) { //判断是否重要(是1就更新
			if (rsp && rsp.status) {
				//需要更新,提示用户
				plus.nativeUI.confirm(rsp.note, function(event) {
					if (0 == event.index) { //用户点击了“立即更新”按钮  
						plus.runtime.openURL(rsp.url);
					}
				}, rsp.title, ["立即更新", " ", "取消"]);
			}
		}
	});
}

该模式仅在App更新级别为重要时才会进行更新

关于页检测更新

var ua = navigator.userAgent;
//Html5Plus环境,但不是流应用环境  
if (ua.indexOf('Html5Plus') > -1 && ua.indexOf('StreamApp') == -1) {
	var url = "https://exmaple.com/check/update"; //检查更新地址  
	var req = { //升级检测数据  
		"appid": plus.runtime.appid,
		"version": plus.runtime.version
	};
	wap2app.ajax.get(url, req, function(rsp) {
		if (rsp && rsp.status) {
			//需要更新,提示用户  
			plus.nativeUI.confirm(rsp.note, function(event) {
				if (0 == event.index) { //用户点击了“立即更新”按钮  
					plus.runtime.openURL(rsp.url);
				}
			}, rsp.title, ["立即更新", " ", "取消"]);
		} else {
			plus.nativeUI.toast("没有可用的版本更新");
		}
	});
}

该模式可以检查最新级别的更新,如无更新会弹出原生提示

版权信息

本协议采用MIT进行分发,项目官方地址为:https://github.com/sancerain/wp-h5plus-update 项目作者:@finderz&@江程训 所属组织:廊坊市山茨网络科技有限公司 Sancerain LLC

使用 StackEdit进行Markdown编辑

wp-h5plus-update's People

Contributors

censujiang avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.