This commit is contained in:
toom1996
2025-07-17 11:37:15 +08:00
parent 9a76ce372b
commit f0eed20b0a
5 changed files with 37 additions and 6 deletions

View File

@ -21,6 +21,8 @@ namespace App\Model;
* @property int $is_record
* @property string $cover
* @property int $is_delete
* @property string $source_url
* @property string $source_platform
* @property-read mixed $created_at
*/
class AppNews extends Model
@ -44,6 +46,6 @@ class AppNews extends Model
public function getCreatedAtAttribute($value)
{
return date('Y-m-d H:i:s', intval($value));
return date('Y-m-d', intval($value));
}
}

View File

@ -10,6 +10,7 @@ class RpcResponse
public array $meta = [];
public string $title = '';
public array $pageModule = [];
public array $extra = [];
public function setData(array $data)
@ -18,6 +19,12 @@ class RpcResponse
return $this;
}
public function setExtra($extraKey = '', $value = '')
{
$this->extra[$extraKey] = $value;
return $this;
}
public function setCode(int $code)
{
$this->code = $code;
@ -32,10 +39,17 @@ class RpcResponse
public function send()
{
return [
$resp = [
'code' => $this->code,
'msg' => $this->msg,
'data' => $this->data,
];
if ($this->extra) {
foreach ($this->extra as $key => $item) {
$resp[$key] = $item;
}
}
return $resp;
}
}

View File

@ -64,8 +64,8 @@ class NewsService extends BaseService
$query->where('platform', $id);
}
$query->select(['id'])
->orderBy('id', 'desc');;
$query->select(['id'])->orderBy('id', 'desc');
$total = $query->count();
$pagination = $query->paginate($limit, page: $page);
$ids = [];
foreach ($pagination->items() as $item) {
@ -74,6 +74,14 @@ class NewsService extends BaseService
$value = AppNews::query()->whereIn('id', $ids)->orderBy('id', 'desc')->get()->toArray();
return $this->getResponse()->setData($value)->setCode(0)->send();
$about = AppNews::formatQuery(['created_at'])
->where('platform', $id)
->where('is_delete', 0)
->select(['title', 'id', 'cover'])
->limit(10)
->orderBy('id', 'desc')
->get()
->toArray();
return $this->getResponse()->setExtra('about', $about)->setExtra('total', round($total / $limit))->setData($value)->setCode(0)->send();
}
}

View File

@ -18,7 +18,7 @@ class WebsiteService extends BaseService
*/
public function config($host): array
{
$query = AppWebsiteConfig::query()->where('app_domain', $host)->where('is_delete', 0)->first()?->toArray();
$query = AppWebsiteConfig::query()->where('app_domain', 'like' , "%$host%")->where('is_delete', 0)->first()?->toArray();
if (!$query) {
return $this->getResponse()->setCode(404)->send();

View File

@ -369,6 +369,13 @@ $articleLocation = array_map(fn($case) => [
});
</script>
<style>
h1, .h1, h2, .h2, h3, .h3, p {
font-family: 'Microsoft Yahei",Helvetica,Arial,sans-serif'; /* 常见的、现代的无衬线字体,增加可读性 */
text-indent: unset !important;
margin-top: 0.5rem;
margin-bottom: unset;
}
.res-options {
padding: 0 10px;
line-height: 36px;