marcusmyers / laravel-dashboard-accuweather-tile
为 Laravel Dashboard 提供的 AccuWeather 面板插件
Requires
- php: ^7.4|^8.0
- spatie/laravel-dashboard: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-08-30 01:09:54 UTC
README
与 Spatie 的 laravel-dashboard-time-weather-tile 类似,但使用 AccuWeather。
此插件可应用于 Laravel Dashboard。
安装
您可以通过 composer 安装此包
composer require marcusmyers/laravel-dashboard-accuweather-tile
使用方法
在 dashboard
配置文件中,您必须在 tiles
键中添加此配置。
在 https://developer.accuweather.com/ 注册以获取 ACCUWEAHTER_API_KEY
,您可以通过在 https://www.accuweather.com 搜索您的城市来找到您的位置键。结果 URL 应包含您的位置键,例如 https://www.accuweather.com/en/us/chicago/60608/weather-forecast/348308,芝加哥的位置键是 348308。AccuWeather 仅允许免费账户每天进行 50 次API请求。
数据可以以英制(华氏度)或公制(摄氏度)显示。这将影响每日面板和预报面板上显示的信息。
还可以更改面板的日期格式。有效的格式是 m/d 或 d/m。
// in config/dashboard.php return [ // ... 'tiles' => [ 'accuweather' => [ 'location_key' => '12345', 'api_key' => env('ACCUWEATHER_API_KEY'), 'system' => 'Metric', 'date_format' => 'd/m', ] ], ];
在 app\Console\Kernel.php
中,您应该安排 MarcusMyers\AccuWeatherTile\Commands\FetchAccuWeatherCurrentConditionsCommand
每小时运行一次。
如果您想使用预报,可以可选地安排 MarcusMyers\AccuWeatherTile\Commands\FetchAccuWeatherFiveDayForecastCommand
每天运行一次。
// in app/console/Kernel.php protected function schedule(Schedule $schedule) { // ... $schedule->command(MarcusMyers\AccuWeatherTile\Commands\FetchAccuWeatherCurrentConditionsCommand::class)->hourly(); $schedule->command(MarcusMyers\AccuWeatherTile\Commands\FetchAccuWeatherFiveDayForecastCommand::class)->daily(); }
在您的仪表板视图中,您可以使用 livewire:accuweather-current-conditions-tile
组件或 livewire:accuweather-five-day-forecast-tile
。
<x-dashboard> <livewire:accuweather-current-conditions-tile position="e1:e4" /> <livewire:accuweather-five-day-forecast-tile position="a14:d16" /> </x-dashboard>
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
贡献
有关详细信息,请参阅 CONTRIBUTING。
安全
如果您发现任何安全问题,请通过 :author_email 发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。