shouldDisplay = $shouldDisplay; } /** * 按钮标题 * * @return string */ public function title() { return '立即刷新'; } /** * 确认提示 * * @return string */ public function confirm() { return '确定要立即刷新种子配置JSON数据吗?'; } /** * 处理请求 * * @param Request $request * @return mixed */ public function handle(Request $request) { try { // 强制刷新缓存 FarmSeedJsonConfig::getData([], true); return $this->response()->success('刷新成功')->refresh(); } catch (\Exception $e) { Log::error('Refresh farm seed JSON exception: '.$e->getMessage()); return $this->response()->error('刷新失败:'.$e->getMessage()); } } /** * 渲染按钮 * * @return string */ public function render() { if (!$this->shouldDisplay) { return ''; } return parent::render(); } /** * 判断是否应该显示按钮 * * @return bool */ public static function shouldDisplay(): bool { return true; } }