no message
This commit is contained in:
parent
6d84b243a5
commit
78159864af
47
app/Models/Option.php
Executable file
47
app/Models/Option.php
Executable file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Option extends Model
|
||||
{
|
||||
protected $table = 'option';
|
||||
public $timestamps = false;
|
||||
protected $primaryKey = 'k';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
public static function _hit($k)
|
||||
{
|
||||
$v = self::where("k", $k)->first()?->v;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
public static function _list()
|
||||
{
|
||||
$oSelf = self::get();
|
||||
|
||||
return self::_filterList($oSelf);
|
||||
}
|
||||
|
||||
public static function _filter($oOption)
|
||||
{
|
||||
$arr = [];
|
||||
$arr[$oOption->k] = $oOption->v;
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function _filterList($oOption)
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($oOption as $oOptionRow) {
|
||||
$arr[] = self::_filter($oOptionRow);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,14 +14,14 @@ use App\Models\Option as ModelOption;
|
||||
// $this->oDog->_setInFormat(["type"]); // 可选,zero^int,^date,^dateFull
|
||||
// $this->oDog->_setOutFormat(["time" => "date"]); // 可选,date,dateFull
|
||||
|
||||
class Dog extends Base {
|
||||
class Dog extends Mod\Base {
|
||||
|
||||
public $oModelSelf;
|
||||
public $sPrimaryKey = "id";
|
||||
public $iStrMaxLen = 50;
|
||||
public $aStrField = [];
|
||||
public $inFormat = [];
|
||||
public $outFormat = [];
|
||||
public $aInFormat = [];
|
||||
public $aOutFormat = [];
|
||||
public $sDogName;
|
||||
|
||||
public function __construct($oModelSelf = false)
|
||||
|
||||
49
app/Services/TG/Hook/Mod/Option.php
Normal file
49
app/Services/TG/Hook/Mod/Option.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\TG\Hook\Mod;
|
||||
use App\Models\Option as ModelOption;
|
||||
use App\Services\TG\Hook\Dog;
|
||||
|
||||
class Option extends Base {
|
||||
|
||||
private $oDog;
|
||||
|
||||
public function __construct($aUpdate = [])
|
||||
{
|
||||
$this->oDog = new Dog(new ModelOption());
|
||||
$this->oDog->_setPrimaryKey("k"); // 可选,默认id
|
||||
$this->oDog->_setDogName("option"); // 必须
|
||||
}
|
||||
|
||||
public function __call($sName, $aArg)
|
||||
{
|
||||
return $this->oDog->$sName($aArg[0]);
|
||||
}
|
||||
|
||||
// public function Pause($aParam)
|
||||
// {
|
||||
// $v = $aParam['aArg'][1];
|
||||
//
|
||||
// // 获取第一个匹配的选项
|
||||
// $oOption = ModelOption::where("type", "pause")->first();
|
||||
//
|
||||
// // 检查是否找到了选项
|
||||
// if ($oOption) {
|
||||
// $oOption->value = $v;
|
||||
//
|
||||
// // 保存并返回结果
|
||||
// return json_encode($oOption->save());
|
||||
// }
|
||||
//
|
||||
// // 如果没有找到选项,返回一个错误信息
|
||||
// return json_encode(['error' => 'Option not found']);
|
||||
// }
|
||||
//
|
||||
// public function List()
|
||||
// {
|
||||
// $aOptionList = ModelOption::all()->toArray();
|
||||
//
|
||||
// return json_encode($aOptionList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
// }
|
||||
|
||||
}
|
||||
@ -347,7 +347,9 @@ $(document).ready(function(){
|
||||
|
||||
if (event.shiftKey && event.metaKey && event.key === 'Enter') {
|
||||
|
||||
submit("input");
|
||||
//submit("input");
|
||||
|
||||
submit($('input[name="cmd_text"]').first(), "input");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user