feat: add IP address display

This commit is contained in:
thehrz 2024-08-18 23:39:01 +08:00
parent a23b9289c4
commit 4f75ec3b07
Signed by: thehrz
GPG Key ID: C84CBCE7D5F88855
5 changed files with 56 additions and 7 deletions

View File

@ -1,6 +1,14 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:8080/:path*' // Proxy to Backend
}
]
}
}
export default nextConfig;

View File

@ -12,6 +12,7 @@
"next": "14.2.5",
"react": "^18",
"react-dom": "^18",
"swr": "^2.2.5",
"theme-change": "^2.5.0"
},
"devDependencies": {

View File

@ -17,6 +17,9 @@ importers:
react-dom:
specifier: ^18
version: 18.3.1(react@18.3.1)
swr:
specifier: ^2.2.5
version: 2.2.5(react@18.3.1)
theme-change:
specifier: ^2.5.0
version: 2.5.0
@ -1412,6 +1415,11 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
swr@2.2.5:
resolution: {integrity: sha512-QtxqyclFeAsxEUeZIYmsaQ0UjimSq1RZ9Un7I68/0ClKK/U3LoyQunwkQfJZr2fc22DfIXLNDc2wFyTEikCUpg==}
peerDependencies:
react: ^16.11.0 || ^17.0.0 || ^18.0.0
tailwindcss@3.4.9:
resolution: {integrity: sha512-1SEOvRr6sSdV5IDf9iC+NU4dhwdqzF4zKKq3sAbasUWHEM6lsMhX+eNN5gkPx1BvLFEnZQEUFbXnGj8Qlp83Pg==}
engines: {node: '>=14.0.0'}
@ -1491,6 +1499,11 @@ packages:
uri-js@4.4.1:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
use-sync-external-store@1.2.2:
resolution: {integrity: sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
@ -2130,7 +2143,7 @@ snapshots:
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
eslint-plugin-jsx-a11y: 6.9.0(eslint@8.57.0)
eslint-plugin-react: 7.35.0(eslint@8.57.0)
eslint-plugin-react-hooks: 4.6.2(eslint@8.57.0)
@ -2154,7 +2167,7 @@ snapshots:
enhanced-resolve: 5.17.1
eslint: 8.57.0
eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
fast-glob: 3.3.2
get-tsconfig: 4.7.6
is-core-module: 2.15.0
@ -2176,7 +2189,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0):
eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0):
dependencies:
array-includes: 3.1.8
array.prototype.findlastindex: 1.2.5
@ -3118,6 +3131,12 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
swr@2.2.5(react@18.3.1):
dependencies:
client-only: 0.0.1
react: 18.3.1
use-sync-external-store: 1.2.2(react@18.3.1)
tailwindcss@3.4.9:
dependencies:
'@alloc/quick-lru': 5.2.0
@ -3231,6 +3250,10 @@ snapshots:
dependencies:
punycode: 2.3.1
use-sync-external-store@1.2.2(react@18.3.1):
dependencies:
react: 18.3.1
util-deprecate@1.0.2: {}
which-boxed-primitive@1.0.2:

View File

@ -19,7 +19,7 @@ export default function RootLayout({
return (
<html lang='zh'>
<body className={inter.className}>
<main className='min-h-screen flex flex-col'>
<main className='h-screen flex flex-col'>
<Nav />
{children}
<Footer />

View File

@ -1,13 +1,30 @@
"use client"
import useSWR from "swr"
const fetcher = (url: string | URL | Request) =>
fetch(url).then((r) => r.json())
interface Myip {
address: string
version: string
}
export default function Home() {
const { data } = useSWR<Myip>("/api/ip/myip", fetcher)
return (
<div className='max-w-full flex justify-center m-auto'>
<div className='max-w-full flex justify-center h-full'>
<div className='hero-content text-center'>
<div className='max-w-md'>
<h1 className='text-5xl font-bold'>IPv6测试</h1>
<p className='py-6'>IPv6测试服务</p>
<button className='btn btn-primary'></button>
<div className='card bg-base-100 w-96 shadow-xl'>
<div className='card-body'>
<p>IPv4 {data?.address}</p>
<p>IPv6 {data?.address}</p>
</div>
</div>
{/* <button className='btn btn-primary'>探索更多</button> */}
</div>
</div>
</div>