Skip to content

Commit

Permalink
Security update / 安全性更新
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Mar 20, 2022
1 parent 6bc0852 commit bd792a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 15 additions & 2 deletions server/Application/Api/Controller/AdminUpdateController.class.php
Expand Up @@ -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 = "../" ;
Expand Down
9 changes: 2 additions & 7 deletions web_src/src/components/admin/about/Index.vue
Expand Up @@ -65,8 +65,7 @@ export default {
isUpdate: false,
cur_version: '',
new_version: '',
url: '',
file_url: ''
url: ''
}
},
methods: {
Expand All @@ -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
Expand All @@ -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({
Expand Down

0 comments on commit bd792a8

Please sign in to comment.