|
|
@@ -6,6 +6,9 @@ use App\Module\Game\DCache\ChestJsonConfig;
|
|
|
use App\Module\Game\DCache\FarmHouseJsonConfig;
|
|
|
use App\Module\Game\DCache\ItemJsonConfig;
|
|
|
use App\Module\Game\DCache\PetJsonConfig;
|
|
|
+use App\Module\GameItems\AdminControllers\Tools\RefreshCheckTool;
|
|
|
+use App\Module\GameItems\AdminControllers\Tools\SyncItemsJsonTool;
|
|
|
+use Carbon\Carbon;
|
|
|
use Dcat\Admin\Layout\Content;
|
|
|
use Dcat\Admin\Layout\Row;
|
|
|
use Dcat\Admin\Widgets\Card;
|
|
|
@@ -22,8 +25,10 @@ use Spatie\RouteAttributes\Attributes\Post;
|
|
|
*
|
|
|
* 用于显示和管理游戏中的各种配置表
|
|
|
*/
|
|
|
+#[Resource('game-jsonconfigs', names: 'dcat.admin.game-jsonconfigs')]
|
|
|
class GameConfigController extends AdminController
|
|
|
{
|
|
|
+
|
|
|
/**
|
|
|
* 页面标题
|
|
|
*
|
|
|
@@ -55,7 +60,7 @@ class GameConfigController extends AdminController
|
|
|
'物品配置表',
|
|
|
'items.json',
|
|
|
'gameitems:generate-json',
|
|
|
- 'game/configs/refresh-items',
|
|
|
+ SyncItemsJsonTool::make(),
|
|
|
$this->getItemConfigInfo()
|
|
|
));
|
|
|
|
|
|
@@ -64,7 +69,7 @@ class GameConfigController extends AdminController
|
|
|
'宝箱配置表',
|
|
|
'chest.json',
|
|
|
'gameitems:generate-chest-json',
|
|
|
- 'game/configs/refresh-chests',
|
|
|
+ 'game-jsonconfigs/refresh-chests',
|
|
|
$this->getChestConfigInfo()
|
|
|
));
|
|
|
})
|
|
|
@@ -74,7 +79,7 @@ class GameConfigController extends AdminController
|
|
|
'宠物配置表',
|
|
|
'pet_config.json, pet_level_config.json, pet_skill_config.json',
|
|
|
'pet:generate-json',
|
|
|
- 'game/configs/refresh-pets',
|
|
|
+ 'game-jsonconfigs/refresh-pets',
|
|
|
$this->getPetConfigInfo()
|
|
|
));
|
|
|
|
|
|
@@ -83,7 +88,7 @@ class GameConfigController extends AdminController
|
|
|
'农场房屋配置表',
|
|
|
'farm_house.json',
|
|
|
'farm:generate-house-json',
|
|
|
- 'game/configs/refresh-farm-house',
|
|
|
+ 'game-jsonconfigs/refresh-farm-house',
|
|
|
$this->getFarmHouseConfigInfo()
|
|
|
));
|
|
|
});
|
|
|
@@ -99,17 +104,17 @@ class GameConfigController extends AdminController
|
|
|
* @param array $info 配置信息
|
|
|
* @return Card
|
|
|
*/
|
|
|
- protected function createConfigCard($title, $filename, $command, $refreshUrl, $info)
|
|
|
+ protected function createConfigCard($title, $filename, $command, $refresh, $info)
|
|
|
{
|
|
|
- $headers = ['属性', '值'];
|
|
|
- $rows = [];
|
|
|
+ $headers = [ '属性', '值' ];
|
|
|
+ $rows = [];
|
|
|
|
|
|
foreach ($info as $key => $value) {
|
|
|
- $rows[] = [$key, $value];
|
|
|
+ $rows[] = [ $key, $value ];
|
|
|
}
|
|
|
|
|
|
$card = new Card($title, Table::make($headers, $rows));
|
|
|
- $card->tool('<a href="' . admin_url($refreshUrl) . '" class="btn btn-primary btn-sm"><i class="fa fa-refresh"></i> 刷新配置</a>');
|
|
|
+ $card->tool($refresh);
|
|
|
$card->footer("<code>文件: {$filename}</code><br><code>命令: php artisan {$command}</code>");
|
|
|
|
|
|
return $card;
|
|
|
@@ -124,9 +129,9 @@ class GameConfigController extends AdminController
|
|
|
{
|
|
|
$data = ItemJsonConfig::getData();
|
|
|
$info = [
|
|
|
- '生成时间' => $data['generated_at'] ?? '未知',
|
|
|
+ '生成时间' => Carbon::createFromTimestamp($data['generated_ts'])->toDateTimeString(),
|
|
|
'物品数量' => isset($data['items']) ? count($data['items']) : 0,
|
|
|
- '文件路径' => public_path('json/items.json'),
|
|
|
+
|
|
|
];
|
|
|
|
|
|
return $info;
|
|
|
@@ -141,9 +146,9 @@ class GameConfigController extends AdminController
|
|
|
{
|
|
|
$data = ChestJsonConfig::getData();
|
|
|
$info = [
|
|
|
- '生成时间' => $data['generated_at'] ?? '未知',
|
|
|
+ '生成时间' => Carbon::createFromTimestamp($data['generated_ts'])->toDateTimeString(),
|
|
|
'宝箱数量' => isset($data['chest']) ? count($data['chest']) : 0,
|
|
|
- '文件路径' => public_path('json/chest.json'),
|
|
|
+
|
|
|
];
|
|
|
|
|
|
return $info;
|
|
|
@@ -156,14 +161,14 @@ class GameConfigController extends AdminController
|
|
|
*/
|
|
|
protected function getPetConfigInfo()
|
|
|
{
|
|
|
- $data = PetJsonConfig::getData();
|
|
|
- $petConfig = $data['pet_config'] ?? [];
|
|
|
+ $data = PetJsonConfig::getData();
|
|
|
+ $petConfig = $data['pet_config'] ?? [];
|
|
|
$petLevelConfig = $data['pet_level_config'] ?? [];
|
|
|
$petSkillConfig = $data['pet_skill_config'] ?? [];
|
|
|
|
|
|
$info = [
|
|
|
- '生成时间' => $petConfig['generated_at'] ?? '未知',
|
|
|
- '宠物数量' => isset($petConfig['pets']) ? count($petConfig['pets']) : 0,
|
|
|
+ '生成时间' => Carbon::createFromTimestamp($data['generated_ts'])->toDateTimeString(),
|
|
|
+ '宠物数量' => isset($petConfig['pets']) ? count($petConfig['pets']) : 0,
|
|
|
'等级配置数量' => isset($petLevelConfig['pet_levels']) ? count($petLevelConfig['pet_levels']) : 0,
|
|
|
'技能配置数量' => isset($petSkillConfig['pet_skills']) ? count($petSkillConfig['pet_skills']) : 0,
|
|
|
];
|
|
|
@@ -180,147 +185,12 @@ class GameConfigController extends AdminController
|
|
|
{
|
|
|
$data = FarmHouseJsonConfig::getData();
|
|
|
$info = [
|
|
|
- '生成时间' => $data['generated_at'] ?? '未知',
|
|
|
+ '生成时间' => Carbon::createFromTimestamp($data['generated_ts'])->toDateTimeString(),
|
|
|
'房屋配置数量' => isset($data['house_configs']) ? count($data['house_configs']) : 0,
|
|
|
- '文件路径' => public_path('json/farm_house.json'),
|
|
|
];
|
|
|
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 刷新物品配置表
|
|
|
- *
|
|
|
- * @param Content $content
|
|
|
- * @return Content
|
|
|
- */
|
|
|
- #[Get('game/configs/refresh-items')]
|
|
|
- public function refreshItems(Content $content)
|
|
|
- {
|
|
|
- try {
|
|
|
- Artisan::call('gameitems:generate-json');
|
|
|
- $output = Artisan::output();
|
|
|
-
|
|
|
- // 强制刷新缓存
|
|
|
- ItemJsonConfig::getData([], true);
|
|
|
-
|
|
|
- admin_success('刷新成功', '物品配置表已成功刷新');
|
|
|
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新物品配置表')
|
|
|
- ->body(Card::make('命令输出', "<pre>{$output}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 2000);</script>");
|
|
|
- } catch (\Exception $e) {
|
|
|
- admin_error('刷新失败', '物品配置表刷新失败: ' . $e->getMessage());
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新物品配置表')
|
|
|
- ->body(Card::make('错误信息', "<pre>{$e->getMessage()}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 3000);</script>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新宝箱配置表
|
|
|
- *
|
|
|
- * @param Content $content
|
|
|
- * @return Content
|
|
|
- */
|
|
|
- #[Get('game/configs/refresh-chests')]
|
|
|
- public function refreshChests(Content $content)
|
|
|
- {
|
|
|
- try {
|
|
|
- Artisan::call('gameitems:generate-chest-json');
|
|
|
- $output = Artisan::output();
|
|
|
-
|
|
|
- // 强制刷新缓存
|
|
|
- ChestJsonConfig::getData([], true);
|
|
|
-
|
|
|
- admin_success('刷新成功', '宝箱配置表已成功刷新');
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新宝箱配置表')
|
|
|
- ->body(Card::make('命令输出', "<pre>{$output}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 2000);</script>");
|
|
|
- } catch (\Exception $e) {
|
|
|
- admin_error('刷新失败', '宝箱配置表刷新失败: ' . $e->getMessage());
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新宝箱配置表')
|
|
|
- ->body(Card::make('错误信息', "<pre>{$e->getMessage()}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 3000);</script>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新宠物配置表
|
|
|
- *
|
|
|
- * @param Content $content
|
|
|
- * @return Content
|
|
|
- */
|
|
|
- #[Get('game/configs/refresh-pets')]
|
|
|
- public function refreshPets(Content $content)
|
|
|
- {
|
|
|
- try {
|
|
|
- Artisan::call('pet:generate-json');
|
|
|
- $output = Artisan::output();
|
|
|
-
|
|
|
- // 强制刷新缓存
|
|
|
- PetJsonConfig::getData([], true);
|
|
|
-
|
|
|
- admin_success('刷新成功', '宠物配置表已成功刷新');
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新宠物配置表')
|
|
|
- ->body(Card::make('命令输出', "<pre>{$output}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 2000);</script>");
|
|
|
- } catch (\Exception $e) {
|
|
|
- admin_error('刷新失败', '宠物配置表刷新失败: ' . $e->getMessage());
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新宠物配置表')
|
|
|
- ->body(Card::make('错误信息', "<pre>{$e->getMessage()}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 3000);</script>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新农场房屋配置表
|
|
|
- *
|
|
|
- * @param Content $content
|
|
|
- * @return Content
|
|
|
- */
|
|
|
- #[Get('game/configs/refresh-farm-house')]
|
|
|
- public function refreshFarmHouse(Content $content)
|
|
|
- {
|
|
|
- try {
|
|
|
- Artisan::call('farm:generate-house-json');
|
|
|
- $output = Artisan::output();
|
|
|
-
|
|
|
- // 强制刷新缓存
|
|
|
- FarmHouseJsonConfig::getData([], true);
|
|
|
-
|
|
|
- admin_success('刷新成功', '农场房屋配置表已成功刷新');
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新农场房屋配置表')
|
|
|
- ->body(Card::make('命令输出', "<pre>{$output}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 2000);</script>");
|
|
|
- } catch (\Exception $e) {
|
|
|
- admin_error('刷新失败', '农场房屋配置表刷新失败: ' . $e->getMessage());
|
|
|
-
|
|
|
- return $content
|
|
|
- ->title($this->title)
|
|
|
- ->description('刷新农场房屋配置表')
|
|
|
- ->body(Card::make('错误信息', "<pre>{$e->getMessage()}</pre>"))
|
|
|
- ->body("<script>setTimeout(function(){ window.location.href = '" . admin_url('game/configs') . "'; }, 3000);</script>");
|
|
|
- }
|
|
|
- }
|
|
|
}
|