@php $tiers = ['#a78bfa', '#38bdf8', '#34d399', '#fbbf24', '#f97316', '#f43f5e']; $mapData = $countries->where('code', '!=', '??')->values(); $maxV = max(1, (int) $mapData->max('visitors')); $maxDay = max(1, collect($days)->max('views')); $total = max(1, $totals['visitors']); $qs = fn (array $extra = []) => array_merge(request()->except('page'), $extra); @endphp

{{ __('流量統計') }}

{{ $from->format('Y-m-d') }} ~ {{ $to->format('Y-m-d') }} · {{ __('依 IP 判斷國家,不含後台與機器人;「訪客」以不重複 IP 計算。') }}

{{ __('匯出 CSV') }}
{{-- 時間範圍 --}}
@foreach ($ranges as $k => $l) {{ __($l) }} @endforeach | @foreach (request()->only('country', 'q') as $k => $v)@endforeach
@foreach ([['瀏覽次數', $totals['views']], ['訪客數(不重複 IP)', $totals['visitors']], ['來源國家數', $totals['countries']], ['登入會員數', $totals['members']]] as [$label, $n])
{{ __($label) }}
{{ number_format($n) }}
@endforeach
{{-- 世界地圖 --}}

{{ __('各國訪客分布') }}

{{ __('訪客數') }} {{ __('無訪客') }}
@if ($mapData->isEmpty())
{{ __('這段期間還沒有訪客紀錄') }}
@endif

{{ __('點選國家可篩選下方明細。') }}

{{-- 國家排行(顏色與地圖同一色階) --}}

{{ __('國家排行') }}

@forelse ($countries->take(15) as $c) @php $edges = array_values(array_unique(array_map(fn ($r, $i) => $i === 0 ? 1 : max(2, (int) ceil($maxV * $r)), [1, .1, .25, .5, .75, 1], array_keys([1, .1, .25, .5, .75, 1])))); $t = 0; foreach ($edges as $i => $e) if ($c['visitors'] >= $e) $t = $i; $color = $c['code'] === '??' ? '#94a3b8' : $tiers[$t]; @endphp @empty @endforelse
{{ __('國家') }}{{ __('訪客') }}{{ __('瀏覽') }}{{ __('占比') }}
{{ $c['name'] }} {{ $c['code'] !== '??' ? $c['code'] : '' }} {{ number_format($c['visitors']) }} {{ number_format($c['views']) }}
{{ round($c['visitors'] / $total * 100, 1) }}%
{{ __('沒有資料') }}
{{-- 熱門頁面 --}}

{{ __('熱門頁面') }}

@forelse ($pages as $p) @empty @endforelse
{{ __('頁面') }}{{ __('瀏覽') }}{{ __('訪客') }}
{{ $p->path }}{{ number_format($p->views) }}{{ number_format($p->visitors) }}
{{ __('沒有資料') }}
{{-- 每日趨勢 --}}

{{ __('每日趨勢') }} ({{ __('長條 = 瀏覽次數,內層 = 訪客數') }})

@foreach ($days as $d)
@endforeach
{{ $days[0]['d'] ?? '' }}{{ end($days)['d'] ?? '' }}
{{-- 明細 --}}

{{ __('瀏覽明細') }}

@foreach (request()->only('range', 'from', 'to') as $k => $v)@endforeach @if (request()->hasAny(['country', 'q'])){{ __('清除條件') }}@endif
@forelse ($logs as $l) @empty @endforelse
{{ __('日期時間') }}IP{{ __('國家') }}{{ __('頁面') }}{{ __('會員') }}
{{ $l->created_at->format('Y-m-d H:i:s') }} {{ $l->ip }} {{ $l->country ? \App\Support\Countries::name($l->country) . ' (' . $l->country . ')' : '—' }} {{ $l->path }} {{ $l->user_id ? '#' . $l->user_id : '' }}
{{ __('沒有符合的紀錄') }}
{{ $logs->links() }}

{{ __('IP 地理資料來源:') }}IP Geolocation by DB-IP (CC BY 4.0)

@vite('resources/js/traffic-map.js')