feat: add geolocation to download logs (country, city via ip-api.com)

This commit is contained in:
mini
2026-02-18 23:28:39 +08:00
parent 4ac8cf2f66
commit 97c58ce3f8
6 changed files with 59 additions and 4 deletions

View File

@@ -66,6 +66,7 @@
<tr>
<th>Time</th>
<th>IP</th>
<th>Location</th>
<th>Browser</th>
<th>Device</th>
<th>Video</th>
@@ -75,6 +76,10 @@
<tr v-for="l in filteredLogs" :key="l.id">
<td class="td-time">{{ fmtTime(l.downloaded_at) }}</td>
<td class="td-ip">{{ l.ip }}</td>
<td class="td-location">
<span v-if="l.country_code" class="flag">{{ countryFlag(l.country_code) }}</span>
<span class="location-text">{{ [l.city, l.country].filter(Boolean).join(', ') || '—' }}</span>
</td>
<td class="td-browser">{{ browserIcon(l.browser) }} {{ l.browser }}</td>
<td class="td-device">{{ deviceIcon(l.device) }} {{ l.device }}</td>
<td class="td-video">
@@ -166,6 +171,12 @@ function deviceIcon(d) {
return { mobile: '📱', tablet: '📟', desktop: '💻', bot: '🤖' }[d] || '💻'
}
function countryFlag(code) {
if (!code || code.length !== 2) return ''
// Convert country code to regional indicator emoji
return [...code.toUpperCase()].map(c => String.fromCodePoint(0x1F1E6 + c.charCodeAt(0) - 65)).join('')
}
// ── Video methods ──
let debounceTimer
function debouncedFetch() {
@@ -295,8 +306,11 @@ onMounted(() => { fetchVideos(); fetchStats() })
.log-table td { padding: 0.6rem 1rem; border-bottom: 1px solid #222; vertical-align: middle; }
.log-table tr:hover td { background: rgba(255,255,255,0.03); }
.td-time { color: #888; white-space: nowrap; font-size: 0.82rem; }
.td-ip { font-family: monospace; color: #7fdbff; }
.td-browser, .td-device { color: #ddd; }
.td-ip { font-family: monospace; color: #7fdbff; white-space: nowrap; }
.td-location { white-space: nowrap; }
.flag { margin-right: 0.3rem; }
.location-text { color: #ccc; font-size: 0.88rem; }
.td-browser, .td-device { color: #ddd; white-space: nowrap; }
.td-video { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platform-badge {
display: inline-block; font-size: 0.7rem; padding: 0.1rem 0.4rem;