uni-app框架实现自动更新并安装【完美解决】

参考:http://ask.dcloud.net.cn/article/35096

uni-app客户端代码: 

 

服务器端代码

@api.route("/version_update", methods=["POST"])
# 必传参数【version】,更新客户端版本到最新
def version_update():
    form_data = request.get_json()
    GlobalUtils.check_field_exit_dict(form_data, "version")
    if not GlobalValidator.is_price_type(form_data["version"]) and GlobalValidator.is_price_type(
            current_app.config["VERSION"]):
        raise Fail("version版本必须是价格类型【如:1.01小数或小数字符串类型】")
    version_dict = {
        "isUpdate": True,
        "downloadAndroidUrl": current_app.config["DOWNLOAD_ANDROID_URL"],
        "downloadIOSUrl": current_app.config["DOWNLOAD_IOS_URL"],
        "note": "版本已更新,请下载最新版本",
    } if form_data["version"] < current_app.config["VERSION"] else {
        "isUpdate": False,
        "note": "当前已经是最新版本",
    }
    return GlobalUtils.jsonify_support_none_and_decimal(version_dict)

 

你可能感兴趣的:(uni-app框架实现自动更新并安装【完美解决】)