mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
34 lines
600 B
PHP
34 lines
600 B
PHP
<?php
|
|
|
|
namespace think\response;
|
|
|
|
use think\Response;
|
|
|
|
class Htmx extends Response
|
|
{
|
|
protected $triggerOptions = [];
|
|
|
|
public function addTrigger($name, $data = null)
|
|
{
|
|
$this->triggerOptions[$name] = $data;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function message($message)
|
|
{
|
|
$this->triggerOptions['layerMsg'] = ['type' => 1, 'title' => $message];
|
|
|
|
return $this;
|
|
}
|
|
|
|
protected function output($data)
|
|
{
|
|
$this->header([
|
|
'HX-Trigger' => json_encode($this->triggerOptions),
|
|
]);
|
|
|
|
return parent::output($data);
|
|
}
|
|
}
|