改进升级页面样式

This commit is contained in:
Wisp X
2022-02-28 09:14:15 +08:00
parent ebb352782f
commit cfc898bda8
4 changed files with 90 additions and 60 deletions
+21 -10
View File
@@ -39,6 +39,7 @@ class UpgradeService
'icon' => 'https://raw.githubusercontent.com/wisp-x/lsky-pro/master/public/static/app/images/icon.png',
'name' => 'V 2.0.1',
'size' => '33.5 MB',
'md5' => '12',
'changelog' => (new \Parsedown())->parse('### Added
- 一键复制全部链接 ([#167](https://github.com/wisp-x/lsky-pro/issues/167))
@@ -53,7 +54,7 @@ FAQ:
'),
'pushed_at' => '2022-02-26 12:21',
'download_url' => 'https://github.com/wisp-x/lsky-pro/archive/v1.6.4.zip',
'download_url' => 'https://software.download.prss.microsoft.com/sg/Win10_21H2_Chinese(Simplified)_x64.iso?t=cc16df27-a503-4843-928b-fa38631f2a70&e=1646095954&h=47dc652437cb5752e720648dd2f74faa0b5d1966c9f6cfb6b8557f32dddec97c',
],
];
}
@@ -69,17 +70,21 @@ FAQ:
return false;
}
file_put_contents($lock, '');
$package = base_path('upgrade.zip');
$version = $this->getVersions()->first();
// 如果有安装包则直接进行安装,否则下载安装包
if (! file_exists($package)) {
$this->setProgress('开始下载安装包...');
$this->setProgress('正在下载安装包...');
if (! $this->check()) {
throw new \Exception('No need to upgrade.');
}
$version = $this->getVersions()->first();
$response = Http::timeout(1800)->get($version['download_url'])->onError(function () {
$this->setProgress('安装包下载异常');
$response = Http::withOptions([
'timeout' => 600,
])->timeout(600)->get($version['download_url'])->onError(function () {
throw new \Exception('安装包下载异常');
});
if ($response->successful()) {
file_put_contents($package, $response->body());
@@ -88,29 +93,35 @@ FAQ:
}
$this->setProgress('正在解压安装包...');
$name = md5_file($package);
$md5 = md5_file($package);
if ($md5 !== $version['md5']) {
throw new \Exception('md5 校验失败');
}
$zip = new ZipArchive;
if (! $zip->open($package)) {
throw new \Exception('Installation package decompression failed.');
}
$zip->extractTo(base_path($name));
$zip->extractTo(base_path($md5));
$zip->close();
$this->setProgress('执行安装中...');
// TODO 读取已存在的软连接,移动到更新目录
// TODO 移动本地文件到更新目录
Artisan::call('cache:clear');
// 清除配置缓存
Cache::forget('configs');
Artisan::call('package:discover');
} catch (\Throwable $e) {
Log::error('升级失败', ['message' => $e->getMessage(), $e->getTraceAsString()]);
$this->setProgress('安装失败,请刷新页面重试', 'fail');
$this->setProgress($e->getMessage(), 'fail');
@unlink($lock);
return false;
}
$this->setProgress('安装成功,请刷新页面', 'success');
@unlink($lock);
@unlink($package);
return true;
}
Generated
+32 -31
View File
@@ -334,16 +334,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.209.31",
"version": "3.209.30",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "595a97c3ca53ba1f33f5bacbb6a8e48ccb45f068"
"reference": "54c1e491b8de74360bbe94d727706db384c8d9a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/595a97c3ca53ba1f33f5bacbb6a8e48ccb45f068",
"reference": "595a97c3ca53ba1f33f5bacbb6a8e48ccb45f068",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/54c1e491b8de74360bbe94d727706db384c8d9a8",
"reference": "54c1e491b8de74360bbe94d727706db384c8d9a8",
"shasum": "",
"mirrors": [
{
@@ -425,9 +425,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.209.31"
"source": "https://github.com/aws/aws-sdk-php/tree/3.209.30"
},
"time": "2022-02-24T22:02:07+00:00"
"time": "2022-02-23T19:14:31+00:00"
},
{
"name": "brick/math",
@@ -2765,16 +2765,16 @@
},
{
"name": "league/flysystem",
"version": "3.0.9",
"version": "3.0.10",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "fb0801a60b7f9ea4188f01c25cb48aed26db7fb6"
"reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/fb0801a60b7f9ea4188f01c25cb48aed26db7fb6",
"reference": "fb0801a60b7f9ea4188f01c25cb48aed26db7fb6",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/bbc5026adb5a423dfcdcecec74c7e15943ff6115",
"reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115",
"shasum": "",
"mirrors": [
{
@@ -2788,6 +2788,7 @@
"php": "^8.0.2"
},
"conflict": {
"aws/aws-sdk-php": "3.209.31 || 3.210.0",
"guzzlehttp/guzzle": "<7.0",
"guzzlehttp/ringphp": "<1.1.1",
"symfony/http-client": "<5.2"
@@ -2840,7 +2841,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.0.9"
"source": "https://github.com/thephpleague/flysystem/tree/3.0.10"
},
"funding": [
{
@@ -2856,20 +2857,20 @@
"type": "tidelift"
}
],
"time": "2022-02-22T07:37:40+00:00"
"time": "2022-02-26T11:09:13+00:00"
},
{
"name": "league/flysystem-aws-s3-v3",
"version": "3.0.9",
"version": "3.0.10",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git",
"reference": "457042c76eec01f150a3e54e96d37ddb48da7833"
"reference": "79c63dc761b6a389a38bd409c2bf8ced73c29261"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/457042c76eec01f150a3e54e96d37ddb48da7833",
"reference": "457042c76eec01f150a3e54e96d37ddb48da7833",
"url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/79c63dc761b6a389a38bd409c2bf8ced73c29261",
"reference": "79c63dc761b6a389a38bd409c2bf8ced73c29261",
"shasum": "",
"mirrors": [
{
@@ -2916,9 +2917,9 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem-aws-s3-v3/issues",
"source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.0.9"
"source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.0.10"
},
"time": "2022-02-22T07:32:04+00:00"
"time": "2022-02-26T10:59:05+00:00"
},
{
"name": "league/flysystem-ftp",
@@ -6322,12 +6323,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -7272,12 +7273,12 @@
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\String\\": ""
},
"files": [
"Resources/functions.php"
],
"psr-4": {
"Symfony\\Component\\String\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
@@ -10711,16 +10712,16 @@
},
{
"name": "spatie/flare-client-php",
"version": "1.0.2",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/spatie/flare-client-php.git",
"reference": "5d48e00716e3bab813cafffe223bc85c5732a410"
"reference": "9b54db8774b6bd7ad7cfa4c035820ef63ea1a75c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/flare-client-php/zipball/5d48e00716e3bab813cafffe223bc85c5732a410",
"reference": "5d48e00716e3bab813cafffe223bc85c5732a410",
"url": "https://api.github.com/repos/spatie/flare-client-php/zipball/9b54db8774b6bd7ad7cfa4c035820ef63ea1a75c",
"reference": "9b54db8774b6bd7ad7cfa4c035820ef63ea1a75c",
"shasum": "",
"mirrors": [
{
@@ -10769,7 +10770,7 @@
],
"support": {
"issues": "https://github.com/spatie/flare-client-php/issues",
"source": "https://github.com/spatie/flare-client-php/tree/1.0.2"
"source": "https://github.com/spatie/flare-client-php/tree/1.0.3"
},
"funding": [
{
@@ -10777,7 +10778,7 @@
"type": "github"
}
],
"time": "2022-02-16T16:14:24+00:00"
"time": "2022-02-25T11:05:23+00:00"
},
{
"name": "spatie/ignition",
+3
View File
@@ -1229,6 +1229,9 @@ select {
.break-words {
overflow-wrap: break-word;
}
.break-all {
word-break: break-all;
}
.rounded-md {
border-radius: 0.375rem;
}
+34 -19
View File
@@ -145,7 +145,7 @@
<span class="text-gray-700">{{ \App\Utils::config(\App\Enums\ConfigKey::AppVersion) }}</span>
<span class="text-gray-500">已是最新版本</span>
</p>
<div id="have-update" style="display: none"></div>
<div id="have-update" class="break-words" style="display: none"></div>
</div>
</div>
@@ -238,24 +238,27 @@
};
};
$('#check-update').show();
axios.get('{{ route('admin.settings.check.update') }}').then(response => {
if (response.data.status && response.data.data.is_update) {
$('#check-update').hide();
let version = response.data.data.version;
let html = $('#update-tpl').html()
.replace(/__icon__/g, version.icon)
.replace(/__name__/g, version.name)
.replace(/__size__/g, version.size)
.replace(/__pushed_at__/g, version.pushed_at)
.replace(/__changelog__/g, version.changelog);
$('#have-update').html(html).show();
$('.markdown-body a').attr('target', '_blank');
} else {
$('#not-update').show();
$('#check-update').hide();
}
});
let getVersion = function (callback) {
$('#check-update').show();
axios.get('{{ route('admin.settings.check.update') }}').then(response => {
if (response.data.status && response.data.data.is_update) {
$('#check-update').hide();
let version = response.data.data.version;
let html = $('#update-tpl').html()
.replace(/__icon__/g, version.icon)
.replace(/__name__/g, version.name)
.replace(/__size__/g, version.size)
.replace(/__pushed_at__/g, version.pushed_at)
.replace(/__changelog__/g, version.changelog);
$('#have-update').html(html).show();
$('.markdown-body a').attr('target', '_blank');
callback && callback(version);
} else {
$('#not-update').show();
$('#check-update').hide();
}
});
}
let getProgress = function () {
axios.get('{{ route('admin.settings.upgrade.progress') }}').then(response => {
@@ -279,6 +282,18 @@
}
upgrade().start();
});
@if(cache()->has('upgrade_progress'))
getVersion(() => {
$('#icon').addClass('animate-spin')
$('#install').attr('disabled', true).removeClass('bg-blue-500').addClass('cursor-not-allowed bg-gray-400').text('正在升级...')
$('#upgrade-message').text('请稍等...').removeClass('text-red-500').addClass('text-gray-500');
timer = setInterval(getProgress, 1500);
});
@else
getVersion();
@endif
</script>
@endpush