diff --git a/server/Application/Api/Controller/AdminUpdateController.class.php b/server/Application/Api/Controller/AdminUpdateController.class.php index 63923b628..66de76bad 100644 --- a/server/Application/Api/Controller/AdminUpdateController.class.php +++ b/server/Application/Api/Controller/AdminUpdateController.class.php @@ -28,8 +28,21 @@ public function download(){ $this->checkAdmin(); set_time_limit(1000); ini_set('memory_limit','500M'); - $new_version = I("new_version") ; - $file_url = I("file_url") ; + //获取当前版本 + $text = file_get_contents("../composer.json"); + $composer = json_decode($text, true); + $version = $composer['version'] ; + $url = "https://www.showdoc.cc/server/api/open/checkUpdate"; + $res = http_post($url , array("version"=>$version)); + $res_array = json_decode($res,true); + $new_version =$res_array['data']['new_version'] ; + $file_url =$res_array['data']['file_url'] ; + + if(!$file_url){ + $this->sendError(10101,'检测更新时异常'); + return ; + } + $version_num = str_replace("v","",$new_version) ; $showdoc_path = "../" ; diff --git a/web_src/src/components/admin/about/Index.vue b/web_src/src/components/admin/about/Index.vue index 105c7c4ab..2e49bcea8 100644 --- a/web_src/src/components/admin/about/Index.vue +++ b/web_src/src/components/admin/about/Index.vue @@ -65,8 +65,7 @@ export default { isUpdate: false, cur_version: '', new_version: '', - url: '', - file_url: '' + url: '' } }, methods: { @@ -81,7 +80,6 @@ export default { this.request('/api/adminUpdate/checkUpdate', {}).then(data => { if (data && data.data && data.data.url) { this.url = data.data.url - this.file_url = data.data.file_url this.new_version = data.data.new_version this.cur_version = data.data.version this.isUpdate = true @@ -92,10 +90,7 @@ export default { let loading = this.$loading({ text: '正在下载更新包...' }) - this.request('/api/adminUpdate/download', { - new_version: this.new_version, - file_url: this.file_url - }).then( + this.request('/api/adminUpdate/download', {}).then( data => { loading.close() loading = this.$loading({