From 50dabc2f487e59f41e073e569441b9ddc9a4cdbd Mon Sep 17 00:00:00 2001 From: WispX <1591788658@qq.com> Date: Sun, 15 Mar 2020 08:28:37 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E6=88=90=E5=B9=B3?= =?UTF-8?q?=E6=BB=91=E5=8D=87=E7=BA=A7=E7=B3=BB=E7=BB=9F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- application/index/controller/admin/System.php | 4 +- application/index/view/common/base.html | 4 +- extend/Upgrade.php | 2 +- public/static/app/js/app.js | 94 +++++++++++++------ 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 7569adf7..438bf5ee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
-Lsky Pro - Your photo album on the cloud.
+Your photo album on the cloud.
[官网](https://www.lsky.pro) [手册](https://www.kancloud.cn/wispx/lsky-pro) diff --git a/application/index/controller/admin/System.php b/application/index/controller/admin/System.php index e018b346..a7832662 100644 --- a/application/index/controller/admin/System.php +++ b/application/index/controller/admin/System.php @@ -94,7 +94,7 @@ class System extends Base Db::startTrans(); $backup = 'backup-' . date('YmdHis') . '.zip'; try { - $upgrade = new \Upgrade(app()->getRootPath(), 'v' . $this->config['system_version']); + $upgrade = new \Upgrade(app()->getRootPath(), $this->config['system_version']); $release = $upgrade->release(); // 获取最新版 // 判断是否已经是最新版 if ($upgrade->check($release->version)) { @@ -198,7 +198,7 @@ class System extends Base { $release = null; try { - $upgrade = new \Upgrade(app()->getRootPath(), 'v' . $this->config['system_version']); + $upgrade = new \Upgrade(app()->getRootPath(), $this->config['system_version']); $release = $upgrade->release(); // 获取安装包列表 if (!$release) { throw new \Exception('获取版本时遇到错误'); diff --git a/application/index/view/common/base.html b/application/index/view/common/base.html index fe21c2e2..aebaf499 100644 --- a/application/index/view/common/base.html +++ b/application/index/view/common/base.html @@ -173,7 +173,7 @@ }); $('#update').click(function () { - app.upgrade(true); + app.getLastVer(ver, true); }); $('body').on('click', '.markdown-body a', function (e) { @@ -184,7 +184,7 @@ {if $user and $user.is_admin and !cookie('?no_update')} {/if} {$config.statistics_code|raw} diff --git a/extend/Upgrade.php b/extend/Upgrade.php index aeca57cd..b7b88611 100644 --- a/extend/Upgrade.php +++ b/extend/Upgrade.php @@ -46,7 +46,7 @@ class Upgrade { $this->rootPath = rtrim(str_replace('\\', '/', $path), '/') . '/'; $this->workspace = $this->rootPath . 'runtime/.tmp/'; - $this->version = $version; + $this->version = ltrim('v', strtolower($version)); if (!class_exists('ZipArchive')) { throw new \Exception('无法继续执行, 请确保 ZipArchive 正确安装'); diff --git a/public/static/app/js/app.js b/public/static/app/js/app.js index aa787f5d..fd8d8e07 100644 --- a/public/static/app/js/app.js +++ b/public/static/app/js/app.js @@ -120,26 +120,79 @@ var app = { */ bytesToSize: function (bytes) { if (bytes === 0) return '0 B'; - var k = 1024, sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], i = Math.floor(Math.log(bytes) / Math.log(k)); + var k = 1024, sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + i = Math.floor(Math.log(bytes) / Math.log(k)); return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i]; }, + versionCompare: function (ver, newVer) { + var sources = ver.split('.'); + var dests = newVer.split('.'); + var maxL = Math.max(sources.length, dests.length); + var result = 0; + for (var i = 0; i < maxL; i++) { + let preValue = sources.length > i ? sources[i] : 0; + let preNum = isNaN(Number(preValue)) ? preValue.charCodeAt() : Number(preValue); + let lastValue = dests.length > i ? dests[i] : 0; + let lastNum = isNaN(Number(lastValue)) ? lastValue.charCodeAt() : Number(lastValue); + if (preNum < lastNum) { + result = -1; + break; + } else if (preNum > lastNum) { + result = 1; + break; + } + } + return result; + }, /** - * 更新系统 + * 执行更新 + */ + upgrade: function () { + var loading = false; + if (loading) return; + loading = true; + $d = mdui.dialog({ + overlay: true, + modal: true, + buttons: [], + closeOnEsc: false, + content: '