2 Star 11 Fork 4

呐喊 / autoUpdater

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简介

autoUpgrader是基于QT的通用桌面程序自动升级更新解决方案。

QT版本

5.15.X

开发工具

Qt Creator

后端接口配置格式

后端接口配置为json格式文件,这里保存的文件名为autoUpgrader.json,可自定义。

{
    "version": 101,
    "versionStr": "1.0.1",
    "type": 1,
    "zipurl": "http://192.168.1.5/autoupdate/dist.zip",
    "mainAppName":"客户端.exe",
    "filelist": [
        {
            "path": "/",
            "sublist": [
                "http://192.168.1.5/autoupdate/dist/opengl32sw-01.dll",
                "http://192.168.1.5/autoupdate/dist/客户端.exe"
            ]
        },
        {
        	"path": "html",
            "sublist": [
                "http://192.168.1.5/autoupdate/dist/html/error.html",
                "http://192.168.1.5/autoupdate/dist/html/index.html"
            ]
        }
    ]
}

其中:

  • version为纯数字版本号(这是升级判断的依据);
  • versionStr为显示的版本号;
  • type为更新模式,1表示更新指定文件(即是filelist字段内容,此时zipurl可为空),2表示压缩包方式更新,压缩包为zip压缩(此时filelist可为[]);
  • mainAppName是主程序名称,更新完毕后会自动启动主程序;
  • zipurl压缩包地址,type为2时候有效,必须为zip格式压缩;
  • filelist 是指定文件更新方式,其中path为空或/ 表示主目录,有具体目录名称表示子目录(子目录前请后勿加/)

压缩包内容示例(dist是待压缩的目录):

dist
├── html
│   ├── error.html
│   └── index.html
├── 客户端.exe
└── opengl32sw-01.dll

本程序相关配置

  • 版本号文件为version.dat二进制文件(可由本项目的子项目generateVersionDat生成),只记录纯数字版本号,写入版本号示例代码(写入版本号101):
	QString configFilePath = QDir::currentPath()+"/version.dat";
    configFilePath = QDir::toNativeSeparators(configFilePath);
    QFile writeFile(configFilePath);
    writeFile.open(QIODevice::WriteOnly);
    QDataStream out(&writeFile);
    out << 101;
    writeFile.close();
  • 后端配置地址,位于当前目录的setting.ini文件内的upgrade节点,如:

[upgrade]
url=http://192.168.1.5/autoupdate/autoUpgrader.json

发布

Windows环境打包

  1. 用Release模式运行一遍;
  2. 在Build directory目录下的dist目录中会生成autoUpgrader.exe可执行文件;
  3. 打开QT命令行(开始菜单里面/QT下),进入dist目录;
  4. 执行:windeployqt autoUpgrader.exe
  5. 将系统盘windows/system32/下的msvcp140_1.dll和vcruntime140_1.dll复制到dist目录。
MIT License Copyright (c) 2022 呐喊hlinfocc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于QT的通用桌面程序自动升级更新程序 展开 收起
C++ 等 2 种语言
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/hlinfo/autoUpdater.git
git@gitee.com:hlinfo/autoUpdater.git
hlinfo
autoUpdater
autoUpdater
master

搜索帮助