mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-03 02:58:42 +00:00
启用Horizion 并添加对应安装需要内容
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
@@ -28,10 +29,8 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
*/
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
], true);
|
||||
Gate::define('viewHorizon', function (User $user) {
|
||||
return $user->hasPermissionTo('horizon.index');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Telescope\IncomingEntry;
|
||||
use Laravel\Telescope\Telescope;
|
||||
@@ -60,8 +61,8 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewTelescope', function ($user) {
|
||||
return $user->hasRole('Super Admin');
|
||||
Gate::define('viewTelescope', function (User $user) {
|
||||
return $user->hasPermissionTo('telescope.index');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,12 +87,12 @@ class IP
|
||||
{ // 开发依据: https://ip-api.com/docs/api:json
|
||||
$key = config('services.ip.ip-api_key');
|
||||
if ($key) {
|
||||
$response = Http::timeout(15)->withHeaders(['Origin' => 'https://members.ip-api.com'])->acceptJson()->get("https://pro.ip-api.com/json/$ip?fields=49881&key=$key&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
$response = Http::timeout(10)->withHeaders(['Origin' => 'https://members.ip-api.com'])->acceptJson()->get("https://pro.ip-api.com/json/$ip?fields=49881&key=$key&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
if (! $response->ok()) {
|
||||
$response = Http::timeout(15)->acceptJson()->get("http://ip-api.com/json/$ip?fields=49881&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
$response = Http::timeout(10)->acceptJson()->get("http://ip-api.com/json/$ip?fields=49881&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
}
|
||||
} else {
|
||||
$response = Http::timeout(15)->acceptJson()->get("http://ip-api.com/json/$ip?fields=49881&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
$response = Http::timeout(10)->acceptJson()->get("http://ip-api.com/json/$ip?fields=49881&lang=".str_replace('_', '-', app()->getLocale()));
|
||||
}
|
||||
|
||||
if ($response->ok()) {
|
||||
@@ -124,7 +124,7 @@ class IP
|
||||
} else {
|
||||
$url = "https://qifu-api.baidubce.com/ip/geo/v1/district?ip=$ip";
|
||||
}
|
||||
$response = Http::timeout(15)->get($url);
|
||||
$response = Http::timeout(10)->get($url);
|
||||
$data = $response->json();
|
||||
if ($response->ok()) {
|
||||
if ($data['code'] === 'Success') {
|
||||
@@ -149,7 +149,7 @@ class IP
|
||||
|
||||
private static function TenAPI(string $ip): ?array
|
||||
{ // 开发依据: https://docs.tenapi.cn/utility/getip.html
|
||||
$response = Http::timeout(15)->asForm()->post('https://tenapi.cn/v2/getip', ['ip' => $ip]);
|
||||
$response = Http::timeout(10)->asForm()->post('https://tenapi.cn/v2/getip', ['ip' => $ip]);
|
||||
if ($response->ok()) {
|
||||
$data = $response->json();
|
||||
|
||||
@@ -159,7 +159,7 @@ class IP
|
||||
'region' => $data['data']['province'],
|
||||
'city' => $data['data']['city'],
|
||||
'isp' => $data['data']['isp'],
|
||||
'area' => $data['data']['area'],
|
||||
'area' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +157,6 @@ return [
|
||||
*/
|
||||
|
||||
'providers' => ServiceProvider::defaultProviders()->merge([
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
@@ -169,6 +165,7 @@ return [
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\HorizonServiceProvider::class,
|
||||
])->toArray(),
|
||||
|
||||
/*
|
||||
|
||||
38
install.sh
38
install.sh
@@ -78,20 +78,39 @@ set_permissions() {
|
||||
chmod -R 777 storage/
|
||||
}
|
||||
|
||||
set_crontab() {
|
||||
cmd="php $(dirname "$path")/artisan schedule:run >> /dev/null 2>&1"
|
||||
set_schedule() {
|
||||
cmd="php $PWD/artisan schedule:run >> /dev/null 2>&1"
|
||||
cronjob="* * * * * $cmd"
|
||||
(
|
||||
crontab -u www -l | grep -v -F "$cmd"
|
||||
echo "$cronjob"
|
||||
) | crontab -u www -
|
||||
}
|
||||
|
||||
cmd="bash $(dirname "$path")/queue.sh"
|
||||
cronjob="*/10 * * * * $cmd"
|
||||
(
|
||||
crontab -l | grep -v -F "$cmd"
|
||||
echo "$cronjob"
|
||||
) | crontab -
|
||||
set_horizon() {
|
||||
if ! command -v supervisorctl &>/dev/null; then
|
||||
if [[ "${release}" == "centos" ]]; then
|
||||
yum install -y supervisor
|
||||
else
|
||||
apt-get install -y supervisor
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/supervisor/conf.d/horizon.conf ]; then
|
||||
echo "
|
||||
[program:horizon]
|
||||
process_name=%(program_name)s
|
||||
command=php $PWD/artisan horizon
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www
|
||||
redirect_stderr=true
|
||||
stdout_logfile=$PWD/storage/logs/horizon.log
|
||||
stopwaitsecs=3600" >>/etc/supervisor/conf.d/horizon.conf
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
supervisorctl start horizon
|
||||
fi
|
||||
}
|
||||
|
||||
clean_files
|
||||
@@ -100,4 +119,5 @@ check_composer
|
||||
composer install
|
||||
php artisan panel:install
|
||||
set_permissions
|
||||
set_crontab
|
||||
set_schedule
|
||||
set_horizon
|
||||
|
||||
2
public/vendor/horizon/app.js
vendored
2
public/vendor/horizon/app.js
vendored
File diff suppressed because one or more lines are too long
2
public/vendor/horizon/mix-manifest.json
vendored
2
public/vendor/horizon/mix-manifest.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"/app.js": "/app.js?id=45904d8bd75c65ee5c136a52a5e8ead6",
|
||||
"/app.js": "/app.js?id=c6d58c1ba0a1e0ad976bd661884a1582",
|
||||
"/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435",
|
||||
"/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
|
||||
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",
|
||||
|
||||
10
queue.sh
10
queue.sh
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
ps -ef | grep queue:work | grep -v grep
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "启动队列监听"
|
||||
nohup php artisan queue:work redis --queue=default --timeout=120 --tries=3 -vvv >> ./queue.log 2>&1 &
|
||||
else
|
||||
echo "队列监听中"
|
||||
fi
|
||||
@@ -433,6 +433,22 @@
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewHorizon')
|
||||
<li class="site-menu-item">
|
||||
<a href="{{route('horizon.index')}}" target="_blank">
|
||||
<span class="site-menu-title"> Horizon </span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@if(config('app.debug') && config('app.env') === 'local')
|
||||
@can('viewTelescope')
|
||||
<li class="site-menu-item">
|
||||
<a href="{{route('telescope')}}" target="_blank">
|
||||
<span class="site-menu-title"> Telescope </span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@endif
|
||||
</ul>
|
||||
</li>
|
||||
@endcanany
|
||||
|
||||
Reference in New Issue
Block a user