no message

This commit is contained in:
kuaifan 2021-12-19 22:56:12 +08:00
parent 5181010d22
commit fa8c209ea3

View File

@ -237,37 +237,45 @@ class SystemController extends AbstractController
'list' => [], 'list' => [],
]; ];
// //
$file = base_path("electron/package.json"); $files = [
base_path("package.json"),
base_path("electron/package.json")
];
$dist = base_path("electron/dist"); $dist = base_path("electron/dist");
if (file_exists($file)) { foreach ($files as $file) {
$packageArray = json_decode(file_get_contents($file), true); if (file_exists($file)) {
$array['name'] = $packageArray['name'] ?? 'No app'; $packageArray = json_decode(file_get_contents($file), true);
$array['version'] = $packageArray['version'] ?? ''; $array['name'] = $packageArray['name'] ?? 'No app';
// $array['version'] = $packageArray['version'] ?? '';
$list = [ //
[ $list = [
'icon' => 'logo-apple', [
'name' => 'macOS Intel', 'icon' => 'logo-apple',
'file' => "{$array['name']}-{$array['version']}.dmg" 'name' => 'macOS Intel',
], 'file' => "{$array['name']}-{$array['version']}.dmg"
[ ],
'icon' => 'logo-apple', [
'name' => 'macOS M1', 'icon' => 'logo-apple',
'file' => "{$array['name']}-{$array['version']}-arm64.dmg" 'name' => 'macOS M1',
], 'file' => "{$array['name']}-{$array['version']}-arm64.dmg"
[ ],
'icon' => 'logo-windows', [
'name' => 'Windows x64', 'icon' => 'logo-windows',
'file' => "{$array['name']} Setup {$array['version']}.exe" 'name' => 'Windows x64',
] 'file' => "{$array['name']} Setup {$array['version']}.exe"
]; ]
foreach ($list as $item) { ];
if (file_exists("{$dist}/{$item['file']}")) { foreach ($list as $item) {
$item['url'] = Base::fillUrl('api/system/get/appdown?file=' . urlencode($item['file'])); if (file_exists("{$dist}/{$item['file']}")) {
$item['size'] = filesize("{$dist}/{$item['file']}"); $item['url'] = Base::fillUrl('api/system/get/appdown?file=' . urlencode($item['file']));
$array['list'][] = $item; $item['size'] = filesize("{$dist}/{$item['file']}");
$array['list'][] = $item;
}
} }
} }
if (count($array['list']) > 0) {
break;
}
} }
// //
if (count($array['list']) == 0) { if (count($array['list']) == 0) {