Compare commits
20 Commits
a0b0956677
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49725fd38e | ||
|
|
7947fc48a2 | ||
|
|
99039b6622 | ||
|
|
db1acf6f70 | ||
|
|
3a2fbe29fb | ||
|
|
5c236c0b01 | ||
|
|
fde097c601 | ||
|
|
670961c17d | ||
|
|
84a5e27c05 | ||
|
|
9dea370a87 | ||
|
|
602372e58d | ||
|
|
574ad0e662 | ||
|
|
78d916ade1 | ||
|
|
6a9e7289b5 | ||
| 6adcd33943 | |||
|
|
165151b9d2 | ||
|
|
1e76275f04 | ||
|
|
d9cd5eb41b | ||
|
|
7ff42861f1 | ||
|
|
eb4c2d2d5f |
@@ -1,4 +1,4 @@
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
API_BASE_URL=http://192.168.3.42:8080
|
API_BASE_URL=http://192.168.0.15:8080
|
||||||
CLIENT_ID=web
|
CLIENT_ID=web
|
||||||
CLIENT_SECRET=web
|
CLIENT_SECRET=web
|
||||||
|
|||||||
3
bun.lock
3
bun.lock
@@ -35,6 +35,7 @@
|
|||||||
"lucide-react": "^0.479.0",
|
"lucide-react": "^0.479.0",
|
||||||
"next": "^16.0.10",
|
"next": "^16.0.10",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
|
"photoswipe": "^5.4.4",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"react": "^19.2.1",
|
"react": "^19.2.1",
|
||||||
"react-day-picker": "8.10.1",
|
"react-day-picker": "8.10.1",
|
||||||
@@ -1164,6 +1165,8 @@
|
|||||||
|
|
||||||
"path-parse": ["path-parse@1.0.7", "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
"path-parse": ["path-parse@1.0.7", "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
||||||
|
|
||||||
|
"photoswipe": ["photoswipe@5.4.4", "https://registry.npmmirror.com/photoswipe/-/photoswipe-5.4.4.tgz", {}, "sha512-WNFHoKrkZNnvFFhbHL93WDkW3ifwVOXSW3w1UuZZelSmgXpIGiZSNlZJq37rR8YejqME2rHs9EhH9ZvlvFH2NA=="],
|
||||||
|
|
||||||
"picocolors": ["picocolors@1.1.1", "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
"picocolors": ["picocolors@1.1.1", "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||||
|
|
||||||
"picomatch": ["picomatch@4.0.3", "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.3.tgz", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
|
"picomatch": ["picomatch@4.0.3", "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.3.tgz", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lanhu-web",
|
"name": "lanhu-web",
|
||||||
"version": "1.8.0",
|
"version": "1.13.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -H 0.0.0.0 --turbopack",
|
"dev": "next dev -H 0.0.0.0 --turbopack",
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
"lucide-react": "^0.479.0",
|
"lucide-react": "^0.479.0",
|
||||||
"next": "^16.0.10",
|
"next": "^16.0.10",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
|
"photoswipe": "^5.4.4",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"react": "^19.2.1",
|
"react": "^19.2.1",
|
||||||
"react-day-picker": "8.10.1",
|
"react-day-picker": "8.10.1",
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ if ($confrim -ne "y") {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
docker build -t repo.lanhuip.com:8554/lanhu/web:latest .
|
docker build -t repo.lanhuip.com/lanhu/web:latest .
|
||||||
docker build -t repo.lanhuip.com:8554/lanhu/web:$($args[0]) .
|
docker build -t repo.lanhuip.com/lanhu/web:$($args[0]) .
|
||||||
|
|
||||||
docker push repo.lanhuip.com:8554/lanhu/web:latest
|
docker push repo.lanhuip.com/lanhu/web:latest
|
||||||
docker push repo.lanhuip.com:8554/lanhu/web:$($args[0])
|
docker push repo.lanhuip.com/lanhu/web:$($args[0])
|
||||||
|
|||||||
12
src/actions/article.ts
Normal file
12
src/actions/article.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
'use server'
|
||||||
|
|
||||||
|
import {callByDevice} from './base'
|
||||||
|
import {ArticleDetail, ArticleNavGroup} from '@/lib/models/article'
|
||||||
|
|
||||||
|
export async function getArticleNav(params: {}) {
|
||||||
|
return await callByDevice<ArticleNavGroup[]>('/api/article/nav', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getArticleDetail(params: {id: number}) {
|
||||||
|
return await callByDevice<ArticleDetail>('/api/article/get', params)
|
||||||
|
}
|
||||||
14
src/actions/balance.ts
Normal file
14
src/actions/balance.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
'use server'
|
||||||
|
import {Balance} from '@/lib/models'
|
||||||
|
import {callByUser} from '@/actions/base'
|
||||||
|
import {PageRecord} from '@/lib/api'
|
||||||
|
|
||||||
|
export async function listBalances(params: {
|
||||||
|
page?: number
|
||||||
|
size?: number
|
||||||
|
bill_no?: string
|
||||||
|
created_at_start?: Date
|
||||||
|
created_at_end?: Date
|
||||||
|
}) {
|
||||||
|
return await callByUser<PageRecord<Balance>>('/api/balance/page', params)
|
||||||
|
}
|
||||||
@@ -3,6 +3,11 @@ import {PageRecord} from '@/lib/api'
|
|||||||
import {Batch} from '@/lib/models/batch'
|
import {Batch} from '@/lib/models/batch'
|
||||||
import {callByUser} from './base'
|
import {callByUser} from './base'
|
||||||
|
|
||||||
export async function pageBatch(props: {page: number, size: number}) {
|
export async function pageBatch(props: {
|
||||||
|
page: number
|
||||||
|
size: number
|
||||||
|
time_start?: Date
|
||||||
|
time_end?: Date
|
||||||
|
resource_no?: string}) {
|
||||||
return callByUser<PageRecord<Batch>>('/api/batch/page', props)
|
return callByUser<PageRecord<Batch>>('/api/batch/page', props)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export async function listChannels(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CreateChannelsResp = {
|
type CreateChannelsResp = {
|
||||||
|
ip: string
|
||||||
host: string
|
host: string
|
||||||
port: string
|
port: string
|
||||||
username?: string
|
username?: string
|
||||||
@@ -28,9 +29,23 @@ export async function createChannels(params: {
|
|||||||
protocol: number
|
protocol: number
|
||||||
auth_type: number
|
auth_type: number
|
||||||
count: number
|
count: number
|
||||||
prov?: string
|
// prov?: string
|
||||||
city?: string
|
area_id?: number
|
||||||
isp?: number
|
isp?: number
|
||||||
|
host_format?: number
|
||||||
}) {
|
}) {
|
||||||
return callByUser<CreateChannelsResp[]>('/api/channel/create', params)
|
return callPublic<CreateChannelsResp[]>('/api/channel/create', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createChannelsV3(params: {
|
||||||
|
resource_no: string
|
||||||
|
protocol: number
|
||||||
|
auth_type: number
|
||||||
|
count: number
|
||||||
|
// prov?: string
|
||||||
|
area_id?: number
|
||||||
|
isp?: number
|
||||||
|
host_format?: number
|
||||||
|
}) {
|
||||||
|
return callPublic<CreateChannelsResp[]>('/api/channel/create/v3', params)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,3 +103,14 @@ export async function getPriceHome(props: CreateResourceReq) {
|
|||||||
discounted?: string
|
discounted?: string
|
||||||
}>('/api/resource/price', props)
|
}>('/api/resource/price', props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateCheckip(props: {
|
||||||
|
id: number
|
||||||
|
checkip: boolean
|
||||||
|
}) {
|
||||||
|
return callByUser('/api/resource/update/checkip', props)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAreaList(props: {}) {
|
||||||
|
return callByUser('/api/area/list', props)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import {NextRequest, NextResponse} from 'next/server'
|
import {NextRequest, NextResponse} from 'next/server'
|
||||||
import {createChannels} from '@/actions/channel'
|
import {createChannels, createChannelsV3} from '@/actions/channel'
|
||||||
|
|
||||||
export async function GET(req: NextRequest) {
|
export async function GET(req: NextRequest) {
|
||||||
const params = req.nextUrl.searchParams
|
const params = req.nextUrl.searchParams
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resource_id = params.get('i')
|
const resourceParam = params.get('i')
|
||||||
if (!resource_id) {
|
|
||||||
|
if (!resourceParam) {
|
||||||
throw new Error('需要指定资源ID')
|
throw new Error('需要指定资源ID')
|
||||||
}
|
}
|
||||||
let protocol = params.get('x')
|
let protocol = params.get('x')
|
||||||
@@ -20,19 +22,50 @@ export async function GET(req: NextRequest) {
|
|||||||
if (!count) {
|
if (!count) {
|
||||||
throw new Error('需要指定通道创建数量')
|
throw new Error('需要指定通道创建数量')
|
||||||
}
|
}
|
||||||
const prov = params.get('a') || undefined
|
// const prov = params.get('a') || undefined
|
||||||
const city = params.get('b') || undefined
|
const area_id = params.get('b') || undefined
|
||||||
const isp = params.get('s') || undefined
|
const isp = params.get('s') || undefined
|
||||||
|
const hostFormat = params.get('rh') || 'domain'
|
||||||
|
const isNumeric = /^\d+$/.test(resourceParam)
|
||||||
|
|
||||||
const result = await createChannels({
|
let result
|
||||||
resource_id: Number(resource_id),
|
if (!isNumeric) {
|
||||||
|
console.log(area_id, 'area_id', params.get('b'), 'params.get')
|
||||||
|
|
||||||
|
result = await createChannelsV3({
|
||||||
|
resource_no: resourceParam,
|
||||||
auth_type: Number(auth_type),
|
auth_type: Number(auth_type),
|
||||||
protocol: Number(protocol),
|
protocol: Number(protocol),
|
||||||
count: Number(count),
|
count: Number(count),
|
||||||
prov,
|
// prov,
|
||||||
city,
|
area_id: Number(area_id),
|
||||||
isp: Number(isp),
|
isp: Number(isp),
|
||||||
|
host_format: hostFormat === 'domain' ? 1 : 2,
|
||||||
})
|
})
|
||||||
|
console.log({
|
||||||
|
resource_no: resourceParam,
|
||||||
|
auth_type: Number(auth_type),
|
||||||
|
protocol: Number(protocol),
|
||||||
|
count: Number(count),
|
||||||
|
// prov,
|
||||||
|
area_id: Number(area_id),
|
||||||
|
isp: Number(isp),
|
||||||
|
host_format: hostFormat === 'domain' ? 1 : 2,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = await createChannels({
|
||||||
|
resource_id: Number(resourceParam),
|
||||||
|
auth_type: Number(auth_type),
|
||||||
|
protocol: Number(protocol),
|
||||||
|
count: Number(count),
|
||||||
|
// prov,
|
||||||
|
area_id: Number(area_id),
|
||||||
|
isp: Number(isp),
|
||||||
|
host_format: hostFormat === 'domain' ? 1 : 2,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
throw new Error(result.message)
|
throw new Error(result.message)
|
||||||
}
|
}
|
||||||
@@ -46,10 +79,32 @@ export async function GET(req: NextRequest) {
|
|||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 'json':
|
case 'json':
|
||||||
return NextResponse.json(result.data)
|
if (hostFormat === 'domain') {
|
||||||
|
const domainFormatData = result.data.map(item => ({
|
||||||
|
host: item.host,
|
||||||
|
port: item.port,
|
||||||
|
...(item.username && item.password ? {username: item.username, password: item.password} : {}),
|
||||||
|
}))
|
||||||
|
return NextResponse.json(domainFormatData)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const ipFormatData = result.data.map(item => ({
|
||||||
|
ip: item.ip,
|
||||||
|
port: item.port,
|
||||||
|
...(item.username && item.password ? {username: item.username, password: item.password} : {}),
|
||||||
|
}))
|
||||||
|
return NextResponse.json(ipFormatData)
|
||||||
|
}
|
||||||
case 'text':
|
case 'text':
|
||||||
const text = result.data.map((item) => {
|
const text = result.data.map((item) => {
|
||||||
const list = [item.host, item.port]
|
let hostValue: string
|
||||||
|
if (hostFormat === 'domain') {
|
||||||
|
hostValue = item.host
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hostValue = item.ip
|
||||||
|
}
|
||||||
|
const list = [hostValue, String(item.port)]
|
||||||
if (item.username && item.password) {
|
if (item.username && item.password) {
|
||||||
list.push(item.username)
|
list.push(item.username)
|
||||||
list.push(item.password)
|
list.push(item.password)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {Card, CardContent} from '@/components/ui/card'
|
|||||||
import {Form, FormField} from '@/components/ui/form'
|
import {Form, FormField} from '@/components/ui/form'
|
||||||
import {Label} from '@/components/ui/label'
|
import {Label} from '@/components/ui/label'
|
||||||
import {Tabs, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
import {Tabs, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
||||||
import {EyeClosedIcon, EyeIcon} from 'lucide-react'
|
import {EyeClosedIcon, EyeIcon, HomeIcon} from 'lucide-react'
|
||||||
import {useState, ReactNode, useEffect, Suspense} from 'react'
|
import {useState, ReactNode, useEffect, Suspense} from 'react'
|
||||||
import zod from 'zod'
|
import zod from 'zod'
|
||||||
import {useForm, useFormContext, useWatch} from 'react-hook-form'
|
import {useForm, useFormContext, useWatch} from 'react-hook-form'
|
||||||
@@ -16,6 +16,7 @@ import {useRouter} from 'next/navigation'
|
|||||||
import {login, LoginMode} from '@/actions/auth'
|
import {login, LoginMode} from '@/actions/auth'
|
||||||
import {useProfileStore} from '@/components/stores/profile'
|
import {useProfileStore} from '@/components/stores/profile'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
const smsSchema = zod.object({
|
const smsSchema = zod.object({
|
||||||
username: zod.string().length(11, '请输入正确的手机号码'),
|
username: zod.string().length(11, '请输入正确的手机号码'),
|
||||||
@@ -88,6 +89,16 @@ export default function LoginCard() {
|
|||||||
const [showPwd, setShowPwd] = useState(false)
|
const [showPwd, setShowPwd] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="relative flex flex-col items-center">
|
||||||
|
<div className="relative w-96 mx-4">
|
||||||
|
<Link
|
||||||
|
href="/"
|
||||||
|
className="absolute -top-8 right-0 inline-flex items-center text-sm transition-colors px-10"
|
||||||
|
>
|
||||||
|
<HomeIcon size={18} className="mr-1"/>
|
||||||
|
返回首页
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
||||||
<CardContent className="px-8">
|
<CardContent className="px-8">
|
||||||
{/* 登录方式切换 */}
|
{/* 登录方式切换 */}
|
||||||
@@ -193,6 +204,7 @@ export default function LoginCard() {
|
|||||||
</Form>
|
</Form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/app/(auth)/privacyPolicy/layout.tsx
Normal file
17
src/app/(auth)/privacyPolicy/layout.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import {ReactNode} from 'react'
|
||||||
|
import {Metadata} from 'next'
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: '隐私政策',
|
||||||
|
description: '蓝狐代理隐私政策 - 了解我们如何收集、使用和保护您的个人信息',
|
||||||
|
openGraph: {
|
||||||
|
title: '隐私政策',
|
||||||
|
description: '蓝狐代理隐私政策 - 了解我们如何收集、使用和保护您的个人信息',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PrivacyPolicyLayout({children}: {children: ReactNode}) {
|
||||||
|
return children
|
||||||
|
}
|
||||||
17
src/app/(auth)/userAgreement/layout.tsx
Normal file
17
src/app/(auth)/userAgreement/layout.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import {ReactNode} from 'react'
|
||||||
|
import {Metadata} from 'next'
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: '用户协议',
|
||||||
|
description: '蓝狐代理用户服务协议 - 使用服务前请仔细阅读用户协议条款',
|
||||||
|
openGraph: {
|
||||||
|
title: '用户协议',
|
||||||
|
description: '蓝狐代理用户服务协议 - 使用服务前请仔细阅读用户协议条款',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function UserAgreementLayout({children}: {children: ReactNode}) {
|
||||||
|
return children
|
||||||
|
}
|
||||||
@@ -1,9 +1,34 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import {HeroSection} from './hero-section'
|
import {HeroSection} from './hero-section'
|
||||||
import {StatsSection} from './stats-section'
|
import {StatsSection} from './stats-section'
|
||||||
import {ProductTypesSection} from './product-types-section'
|
import {ProductTypesSection} from './product-types-section'
|
||||||
import {AdvantagesSection} from './advantages-section'
|
import {AdvantagesSection} from './advantages-section'
|
||||||
import {ArticlesSection} from './articles-section'
|
import {ArticlesSection} from './articles-section'
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: siteConfig.name,
|
||||||
|
description: siteConfig.description,
|
||||||
|
openGraph: {
|
||||||
|
title: siteConfig.name,
|
||||||
|
description: siteConfig.description,
|
||||||
|
url: siteConfig.url,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: siteConfig.name,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: siteConfig.url,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-16 lg:gap-32 pb-16 lg:pb-32 bg-white">
|
<main className="flex flex-col gap-16 lg:gap-32 pb-16 lg:pb-32 bg-white">
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/account-management`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function AccountManagementPage() {
|
export default function AccountManagementPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/advertising`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function AdvertisingPage() {
|
export default function AdvertisingPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import BreadCrumb from '@/components/bread-crumb'
|
import BreadCrumb from '@/components/bread-crumb'
|
||||||
import Wrap from '@/components/wrap'
|
import Wrap from '@/components/wrap'
|
||||||
import Extract from '@/components/composites/extract'
|
import Extract from '@/components/composites/extract'
|
||||||
@@ -5,6 +7,28 @@ import HomePage from '@/components/home/page'
|
|||||||
|
|
||||||
export type CollectPageProps = {}
|
export type CollectPageProps = {}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: 'IP提取',
|
||||||
|
description: '短效/长效IP提取,高可用性代理IP,支持API调用,即时获取全国各地代理IP,适用于数据采集、网络测试等场景',
|
||||||
|
openGraph: {
|
||||||
|
title: 'IP提取',
|
||||||
|
description: '短效/长效IP提取,高可用性代理IP,支持API调用,即时获取全国各地代理IP',
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: 'IP提取',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/collect`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function CollectPage(props: CollectPageProps) {
|
export default function CollectPage(props: CollectPageProps) {
|
||||||
return (
|
return (
|
||||||
// <main className="mt-20 flex flex-col gap-4">
|
// <main className="mt-20 flex flex-col gap-4">
|
||||||
|
|||||||
264
src/app/(home)/custom/_client.tsx
Normal file
264
src/app/(home)/custom/_client.tsx
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
'use client'
|
||||||
|
import {useState} from 'react'
|
||||||
|
import Image from 'next/image'
|
||||||
|
import {useRouter} from 'next/navigation'
|
||||||
|
import {useForm} from 'react-hook-form'
|
||||||
|
import {zodResolver} from '@hookform/resolvers/zod'
|
||||||
|
import {z} from 'zod'
|
||||||
|
import {toast} from 'sonner'
|
||||||
|
import HomePage from '@/components/home/page'
|
||||||
|
import Wrap from '@/components/wrap'
|
||||||
|
import {Form, FormField} from '@/components/ui/form'
|
||||||
|
import {Input} from '@/components/ui/input'
|
||||||
|
import {Button} from '@/components/ui/button'
|
||||||
|
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/components/ui/select'
|
||||||
|
import {merge} from '@/lib/utils'
|
||||||
|
import {submitInquiry} from '@/actions/inquiry'
|
||||||
|
import group from './_assets/Group.webp'
|
||||||
|
import SelfDesc from '@/components/features/self-desc'
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
company: z.string().min(2, '企业名称至少2个字符'),
|
||||||
|
name: z.string().min(2, '联系人姓名至少2个字符'),
|
||||||
|
phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的11位手机号码'),
|
||||||
|
usage: z.string().min(1, '请选择您需要的用量'),
|
||||||
|
purpose: z.string().min(2, '请输入用途说明').max(200, '用途说明不超过200字符'),
|
||||||
|
})
|
||||||
|
|
||||||
|
type FormValues = z.infer<typeof formSchema>
|
||||||
|
|
||||||
|
export default function CustomPage() {
|
||||||
|
const router = useRouter()
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
|
|
||||||
|
const form = useForm<FormValues>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: {
|
||||||
|
company: '',
|
||||||
|
name: '',
|
||||||
|
phone: '',
|
||||||
|
usage: '',
|
||||||
|
purpose: '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const onSubmit = async (data: FormValues) => {
|
||||||
|
setIsSubmitting(true)
|
||||||
|
try {
|
||||||
|
const result = await submitInquiry(data)
|
||||||
|
if (result.success) {
|
||||||
|
toast.success('提交成功!我们的专属顾问会在24小时内联系您')
|
||||||
|
form.reset()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toast.error(result.message || '提交失败,请稍后重试')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
toast.error('网络错误,请稍后重试')
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
setIsSubmitting(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollToForm = () => {
|
||||||
|
const formElement = document.getElementById('inquiry-form')
|
||||||
|
if (formElement) {
|
||||||
|
formElement.scrollIntoView({behavior: 'smooth', block: 'start'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HomePage
|
||||||
|
path={[
|
||||||
|
{label: '业务定制', href: '/custom'},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Wrap className="flex flex-col gap-16">
|
||||||
|
{/* 1. 顶部介绍区 */}
|
||||||
|
<SelfDesc onInquiry={() => {
|
||||||
|
document.getElementById('inquiry-form')?.scrollIntoView({behavior: 'smooth', block: 'start'})
|
||||||
|
}}/>
|
||||||
|
|
||||||
|
{/* 2. 表单区 */}
|
||||||
|
<section id="inquiry-form" className="bg-white rounded-lg p-6 lg:p-12">
|
||||||
|
<div className="text-center mb-8 lg:mb-12">
|
||||||
|
<h2 className="text-2xl lg:text-3xl font-semibold">业务定制</h2>
|
||||||
|
<p className="text-gray-500 mt-2 text-sm lg:text-base">
|
||||||
|
请填写您的企业信息,我们的专属顾问将在24小时内与您联系
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Form form={form} handler={form.handleSubmit(onSubmit)}>
|
||||||
|
<div className="mx-auto max-w-2xl space-y-6">
|
||||||
|
{/* 企业名称 */}
|
||||||
|
<FormField name="companyName">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
||||||
|
<label
|
||||||
|
htmlFor={id}
|
||||||
|
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
||||||
|
>
|
||||||
|
<span className="text-red-500">*</span>
|
||||||
|
<span>企业名称</span>
|
||||||
|
</label>
|
||||||
|
<div className="flex-1 lg:max-w-md">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
placeholder="请输入企业名称"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
aria-required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
{/* 联系人姓名 */}
|
||||||
|
<FormField name="contactName">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
||||||
|
<label
|
||||||
|
htmlFor={id}
|
||||||
|
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
||||||
|
>
|
||||||
|
<span className="text-red-500">*</span>
|
||||||
|
<span>联系人姓名</span>
|
||||||
|
</label>
|
||||||
|
<div className="flex-1 lg:max-w-md">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
placeholder="请输入联系人姓名"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
aria-required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
{/* 联系人手机号码 */}
|
||||||
|
<FormField name="phone">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
||||||
|
<label
|
||||||
|
htmlFor={id}
|
||||||
|
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
||||||
|
>
|
||||||
|
<span className="text-red-500">*</span>
|
||||||
|
<span>联系人手机号</span>
|
||||||
|
</label>
|
||||||
|
<div className="flex-1 lg:max-w-md">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
type="tel"
|
||||||
|
placeholder="请输入11位手机号码"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
aria-required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
{/* 每月需求用量 */}
|
||||||
|
<FormField name="monthlyUsage">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
||||||
|
<label
|
||||||
|
htmlFor={id}
|
||||||
|
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
||||||
|
>
|
||||||
|
<span className="text-red-500">*</span>
|
||||||
|
<span>每月需求用量</span>
|
||||||
|
</label>
|
||||||
|
<div className="flex-1 lg:max-w-md">
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
value={field.value}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
<SelectTrigger id={id} aria-required="true">
|
||||||
|
<SelectValue placeholder="请选择您需要的用量"/>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="less20">小于20万</SelectItem>
|
||||||
|
<SelectItem value="20-100">20万~100万</SelectItem>
|
||||||
|
<SelectItem value="100-500">100万~500万</SelectItem>
|
||||||
|
<SelectItem value="more500">大于500万</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
{/* 用途 */}
|
||||||
|
<FormField name="purpose">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
||||||
|
<label
|
||||||
|
htmlFor={id}
|
||||||
|
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
||||||
|
>
|
||||||
|
<span className="text-red-500">*</span>
|
||||||
|
<span>用途</span>
|
||||||
|
</label>
|
||||||
|
<div className="flex-1 lg:max-w-md">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
placeholder="请输入用途,例如:数据采集、市场调研等"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
aria-required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<div className="pt-4 flex justify-center">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="bg-blue-600 hover:bg-blue-700 px-12 py-2.5"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? '提交中...' : '提交'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* 3. 底部引导区 */}
|
||||||
|
<section className="relative rounded-lg overflow-hidden h-48 lg:h-56">
|
||||||
|
<Image
|
||||||
|
src={group}
|
||||||
|
alt="立即试用背景"
|
||||||
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
<div className="absolute inset-0 flex items-center justify-center">
|
||||||
|
<div className="w-full max-w-4xl px-6 flex flex-col lg:flex-row items-center gap-4 lg:gap-10 justify-center lg:justify-between">
|
||||||
|
<div className="text-blue-600 font-bold text-xl lg:text-2xl text-center lg:text-left">
|
||||||
|
现在注册,免费领取5000IP
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
className={merge(
|
||||||
|
'bg-blue-600 hover:bg-blue-700 text-white px-8 py-3 rounded-md whitespace-nowrap',
|
||||||
|
)}
|
||||||
|
onClick={() => router.push('/product')}
|
||||||
|
>
|
||||||
|
立即试用
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</Wrap>
|
||||||
|
</HomePage>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,264 +1,27 @@
|
|||||||
'use client'
|
import {Metadata} from 'next'
|
||||||
import {useState} from 'react'
|
import {siteConfig} from '@/config/site'
|
||||||
import Image from 'next/image'
|
import CustomPage from './_client'
|
||||||
import {useRouter} from 'next/navigation'
|
|
||||||
import {useForm} from 'react-hook-form'
|
|
||||||
import {zodResolver} from '@hookform/resolvers/zod'
|
|
||||||
import {z} from 'zod'
|
|
||||||
import {toast} from 'sonner'
|
|
||||||
import HomePage from '@/components/home/page'
|
|
||||||
import Wrap from '@/components/wrap'
|
|
||||||
import {Form, FormField} from '@/components/ui/form'
|
|
||||||
import {Input} from '@/components/ui/input'
|
|
||||||
import {Button} from '@/components/ui/button'
|
|
||||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/components/ui/select'
|
|
||||||
import {merge} from '@/lib/utils'
|
|
||||||
import {submitInquiry} from '@/actions/inquiry'
|
|
||||||
import group from './_assets/Group.webp'
|
|
||||||
import SelfDesc from '@/components/features/self-desc'
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
company: z.string().min(2, '企业名称至少2个字符'),
|
return {
|
||||||
name: z.string().min(2, '联系人姓名至少2个字符'),
|
title: '业务定制',
|
||||||
phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的11位手机号码'),
|
description: '蓝狐代理为您提供企业级代理IP定制服务,专属顾问1对1服务,量身打造代理解决方案,满足企业个性化需求',
|
||||||
usage: z.string().min(1, '请选择您需要的用量'),
|
openGraph: {
|
||||||
purpose: z.string().min(2, '请输入用途说明').max(200, '用途说明不超过200字符'),
|
title: '业务定制',
|
||||||
})
|
description: '蓝狐代理为您提供企业级代理IP定制服务,专属顾问1对1服务,量身打造代理解决方案',
|
||||||
|
images: [
|
||||||
type FormValues = z.infer<typeof formSchema>
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
export default function CustomPage() {
|
width: siteConfig.ogImage.width,
|
||||||
const router = useRouter()
|
height: siteConfig.ogImage.height,
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
alt: '业务定制',
|
||||||
|
},
|
||||||
const form = useForm<FormValues>({
|
],
|
||||||
resolver: zodResolver(formSchema),
|
},
|
||||||
defaultValues: {
|
alternates: {
|
||||||
company: '',
|
canonical: `${siteConfig.url}/custom`,
|
||||||
name: '',
|
|
||||||
phone: '',
|
|
||||||
usage: '',
|
|
||||||
purpose: '',
|
|
||||||
},
|
},
|
||||||
})
|
|
||||||
|
|
||||||
const onSubmit = async (data: FormValues) => {
|
|
||||||
setIsSubmitting(true)
|
|
||||||
try {
|
|
||||||
const result = await submitInquiry(data)
|
|
||||||
if (result.success) {
|
|
||||||
toast.success('提交成功!我们的专属顾问会在24小时内联系您')
|
|
||||||
form.reset()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
toast.error(result.message || '提交失败,请稍后重试')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
toast.error('网络错误,请稍后重试')
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
setIsSubmitting(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToForm = () => {
|
export default CustomPage
|
||||||
const formElement = document.getElementById('inquiry-form')
|
|
||||||
if (formElement) {
|
|
||||||
formElement.scrollIntoView({behavior: 'smooth', block: 'start'})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<HomePage
|
|
||||||
path={[
|
|
||||||
{label: '业务定制', href: '/custom'},
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Wrap className="flex flex-col gap-16">
|
|
||||||
{/* 1. 顶部介绍区 */}
|
|
||||||
<SelfDesc onInquiry={() => {
|
|
||||||
document.getElementById('inquiry-form')?.scrollIntoView({behavior: 'smooth', block: 'start'})
|
|
||||||
}}/>
|
|
||||||
|
|
||||||
{/* 2. 表单区 */}
|
|
||||||
<section id="inquiry-form" className="bg-white rounded-lg p-6 lg:p-12">
|
|
||||||
<div className="text-center mb-8 lg:mb-12">
|
|
||||||
<h2 className="text-2xl lg:text-3xl font-semibold">业务定制</h2>
|
|
||||||
<p className="text-gray-500 mt-2 text-sm lg:text-base">
|
|
||||||
请填写您的企业信息,我们的专属顾问将在24小时内与您联系
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<Form form={form} handler={form.handleSubmit(onSubmit)}>
|
|
||||||
<div className="mx-auto max-w-2xl space-y-6">
|
|
||||||
{/* 企业名称 */}
|
|
||||||
<FormField name="companyName">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
|
||||||
<label
|
|
||||||
htmlFor={id}
|
|
||||||
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
<span>企业名称</span>
|
|
||||||
</label>
|
|
||||||
<div className="flex-1 lg:max-w-md">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
placeholder="请输入企业名称"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
aria-required="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
{/* 联系人姓名 */}
|
|
||||||
<FormField name="contactName">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
|
||||||
<label
|
|
||||||
htmlFor={id}
|
|
||||||
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
<span>联系人姓名</span>
|
|
||||||
</label>
|
|
||||||
<div className="flex-1 lg:max-w-md">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
placeholder="请输入联系人姓名"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
aria-required="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
{/* 联系人手机号码 */}
|
|
||||||
<FormField name="phone">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
|
||||||
<label
|
|
||||||
htmlFor={id}
|
|
||||||
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
<span>联系人手机号</span>
|
|
||||||
</label>
|
|
||||||
<div className="flex-1 lg:max-w-md">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
type="tel"
|
|
||||||
placeholder="请输入11位手机号码"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
aria-required="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
{/* 每月需求用量 */}
|
|
||||||
<FormField name="monthlyUsage">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
|
||||||
<label
|
|
||||||
htmlFor={id}
|
|
||||||
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
<span>每月需求用量</span>
|
|
||||||
</label>
|
|
||||||
<div className="flex-1 lg:max-w-md">
|
|
||||||
<Select
|
|
||||||
onValueChange={field.onChange}
|
|
||||||
value={field.value}
|
|
||||||
disabled={isSubmitting}
|
|
||||||
>
|
|
||||||
<SelectTrigger id={id} aria-required="true">
|
|
||||||
<SelectValue placeholder="请选择您需要的用量"/>
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="less20">小于20万</SelectItem>
|
|
||||||
<SelectItem value="20-100">20万~100万</SelectItem>
|
|
||||||
<SelectItem value="100-500">100万~500万</SelectItem>
|
|
||||||
<SelectItem value="more500">大于500万</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
{/* 用途 */}
|
|
||||||
<FormField name="purpose">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-4">
|
|
||||||
<label
|
|
||||||
htmlFor={id}
|
|
||||||
className="flex items-center gap-1 lg:w-32 lg:text-right lg:pt-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
<span>用途</span>
|
|
||||||
</label>
|
|
||||||
<div className="flex-1 lg:max-w-md">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
placeholder="请输入用途,例如:数据采集、市场调研等"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
aria-required="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
<div className="pt-4 flex justify-center">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue-600 hover:bg-blue-700 px-12 py-2.5"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
>
|
|
||||||
{isSubmitting ? '提交中...' : '提交'}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Form>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{/* 3. 底部引导区 */}
|
|
||||||
<section className="relative rounded-lg overflow-hidden h-48 lg:h-56">
|
|
||||||
<Image
|
|
||||||
src={group}
|
|
||||||
alt="立即试用背景"
|
|
||||||
fill
|
|
||||||
className="object-cover"
|
|
||||||
priority
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 flex items-center justify-center">
|
|
||||||
<div className="w-full max-w-4xl px-6 flex flex-col lg:flex-row items-center gap-4 lg:gap-10 justify-center lg:justify-between">
|
|
||||||
<div className="text-blue-600 font-bold text-xl lg:text-2xl text-center lg:text-left">
|
|
||||||
现在注册,免费领取5000IP
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
className={merge(
|
|
||||||
'bg-blue-600 hover:bg-blue-700 text-white px-8 py-3 rounded-md whitespace-nowrap',
|
|
||||||
)}
|
|
||||||
onClick={() => router.push('/product')}
|
|
||||||
>
|
|
||||||
立即试用
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</Wrap>
|
|
||||||
</HomePage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/data-capture`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function DataCapturePage() {
|
export default function DataCapturePage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
| b | string | 否 | 归属地城市。默认全局随机 |
|
| b | string | 否 | 归属地城市。默认全局随机 |
|
||||||
| s | string | 否 | 归属地运营商。默认全局随机 |
|
| s | string | 否 | 归属地运营商。默认全局随机 |
|
||||||
| d | string | 否 | 是否去重:1 - 是,0 - 否。默认为是 |
|
| d | string | 否 | 是否去重:1 - 是,0 - 否。默认为是 |
|
||||||
| rt | string | 否 | 返回类型:1 - TXT,2 - JSON。默认 TXT |
|
| rt | string | 否 | 返回类型:1 - TXT,2 - JSON。默认 TXT
|
||||||
|
| rh | string | 否 | 返回时主机字段的格式:1 - 域名,2 - IP。默认为域名 |
|
||||||
| rs | number[] | 否 | 返回时要使用的分隔符,值为该字符的 ascii 编码,可以有多个字符,多个字符用半角逗号连接。默认为 13,10,即回车 + 换行(\r\n) |
|
| rs | number[] | 否 | 返回时要使用的分隔符,值为该字符的 ascii 编码,可以有多个字符,多个字符用半角逗号连接。默认为 13,10,即回车 + 换行(\r\n) |
|
||||||
| rb | number[] | 否 | 返回时要使用的换行符,值为该字符的 ascii 编码,可以有多个字符,多个字符用半角逗号连接。默认为 124,即垂直线( \| ) |
|
| rb | number[] | 否 | 返回时要使用的换行符,值为该字符的 ascii 编码,可以有多个字符,多个字符用半角逗号连接。默认为 124,即垂直线( \| ) |
|
||||||
| n | number | 否 | 提取数量。默认为 1 |
|
| n | number | 否 | 提取数量。默认为 1 |
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
| password | string | 代理服务器密码(仅在认证类型为密码时返回) |
|
| password | string | 代理服务器密码(仅在认证类型为密码时返回) |
|
||||||
|
|
||||||
|
|
||||||
## 示例
|
## 示例1:
|
||||||
|
|
||||||
### 请求示例
|
### 请求示例
|
||||||
|
|
||||||
@@ -65,3 +66,36 @@ GET https://lanhuip.com/api/extract?i=1&t=2&a=广东省&b=广州市&s=移动&d=1
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 示例2:
|
||||||
|
|
||||||
|
### 请求示例
|
||||||
|
|
||||||
|
```http
|
||||||
|
GET https://lanhuip.com/api/extract?i=24&t=1&a=广东省&b=广州市&d=1&rt=text&rh=ip&rs=124&rb=13%2C10&n=1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 响应示例
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"port": 20000,
|
||||||
|
"username": "user1",
|
||||||
|
"password": "pass1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"port": 20001,
|
||||||
|
"username": "user2",
|
||||||
|
"password": "pass2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"port": 20002,
|
||||||
|
"username": "user3",
|
||||||
|
"password": "pass3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import {useEffect, useRef} from 'react'
|
||||||
|
import 'photoswipe/style.css'
|
||||||
|
|
||||||
|
export default function ArticleViewer({content}: {content: string}) {
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const container = containerRef.current
|
||||||
|
if (!container) return
|
||||||
|
|
||||||
|
const handleClick = async (e: MouseEvent) => {
|
||||||
|
const target = e.target as HTMLElement
|
||||||
|
if (target.tagName !== 'IMG') return
|
||||||
|
if (!container.contains(target)) return
|
||||||
|
|
||||||
|
const allImages = Array.from(container.querySelectorAll('img'))
|
||||||
|
const slides: Array<{src: string, width: number, height: number}> = []
|
||||||
|
let clickedIndex = 0
|
||||||
|
|
||||||
|
allImages.forEach((img) => {
|
||||||
|
const src = img.getAttribute('src')
|
||||||
|
if (!src) return
|
||||||
|
if (img === target) clickedIndex = slides.length
|
||||||
|
slides.push({
|
||||||
|
src,
|
||||||
|
width: img.naturalWidth || 1600,
|
||||||
|
height: img.naturalHeight || 1200,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (slides.length === 0) return
|
||||||
|
|
||||||
|
const {default: PhotoSwipe} = await import('photoswipe')
|
||||||
|
const pswp = new PhotoSwipe({
|
||||||
|
dataSource: slides,
|
||||||
|
index: clickedIndex,
|
||||||
|
bgOpacity: 0.85,
|
||||||
|
spacing: 0.12,
|
||||||
|
zoom: true,
|
||||||
|
})
|
||||||
|
pswp.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
container.addEventListener('click', handleClick)
|
||||||
|
return () => {
|
||||||
|
container.removeEventListener('click', handleClick)
|
||||||
|
}
|
||||||
|
}, [content])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={containerRef}
|
||||||
|
className="prose prose-slate max-w-none [&_img]:cursor-zoom-in"
|
||||||
|
dangerouslySetInnerHTML={{__html: content}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
60
src/app/(home)/docs/[groupCode]/[articleId]/page.tsx
Normal file
60
src/app/(home)/docs/[groupCode]/[articleId]/page.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import {notFound} from 'next/navigation'
|
||||||
|
import {Suspense} from 'react'
|
||||||
|
import {getArticleDetail} from '@/actions/article'
|
||||||
|
import {formatDate} from '@/lib/utils/date'
|
||||||
|
import ArticleViewer from './article-viewer'
|
||||||
|
|
||||||
|
interface ArticlePageProps {
|
||||||
|
params: Promise<{groupCode: string, articleId: string}>
|
||||||
|
}
|
||||||
|
|
||||||
|
function ArticleLoadingSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="max-w-4xl mx-auto">
|
||||||
|
<div className="mb-6 pb-4 border-b">
|
||||||
|
<div className="h-8 bg-gray-200 rounded animate-pulse mb-4 w-3/4"/>
|
||||||
|
<div className="h-4 bg-gray-100 rounded animate-pulse w-1/3"/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-3">
|
||||||
|
{[1, 2, 3, 4].map(i => (
|
||||||
|
<div key={i} className="h-4 bg-gray-100 rounded animate-pulse"/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ArticleContent(props: ArticlePageProps) {
|
||||||
|
const params = await props.params
|
||||||
|
|
||||||
|
const resp = await getArticleDetail({id: Number(params.articleId)})
|
||||||
|
|
||||||
|
if (!resp.success || !resp.data) {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
const article = resp.data
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="max-w-4xl mx-auto">
|
||||||
|
<div className="mb-6 pb-4 border-b">
|
||||||
|
<h1 className="text-2xl md:text-3xl font-bold text-slate-900 mb-2">
|
||||||
|
{article.title}
|
||||||
|
</h1>
|
||||||
|
<div className="flex items-center gap-4 text-sm text-slate-500">
|
||||||
|
<span>更新日期:{formatDate(article.updated_at, 'YYYY-MM-DD HH:mm:ss')}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ArticleViewer content={article.content || ''}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ArticlePage(props: ArticlePageProps) {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<ArticleLoadingSkeleton/>}>
|
||||||
|
<ArticleContent params={props.params}/>
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -3,13 +3,14 @@ import {Children} from '@/lib/utils'
|
|||||||
import Sidebar from './sidebar'
|
import Sidebar from './sidebar'
|
||||||
import HomePage from '@/components/home/page'
|
import HomePage from '@/components/home/page'
|
||||||
import SidebarDrawer from './sidebar-drawer'
|
import SidebarDrawer from './sidebar-drawer'
|
||||||
|
import {Suspense} from 'react'
|
||||||
|
|
||||||
export default function DocsLayout(props: Children) {
|
export default function DocsLayout(props: Children) {
|
||||||
return (
|
return (
|
||||||
<HomePage path={[{label: '帮助中心', href: '/docs'}]}>
|
<HomePage path={[{label: '帮助中心', href: '/docs'}]}>
|
||||||
<Wrap className="flex gap-3 flex-col md:flex-row">
|
<Wrap className="flex gap-3 flex-col md:flex-row">
|
||||||
<SidebarDrawer/>
|
<SidebarDrawer/>
|
||||||
<Sidebar className="hidden md:block w-68"/>
|
<Suspense> <Sidebar className="hidden md:block w-68"/></Suspense>
|
||||||
<div className="flex-1 bg-white rounded-lg p-4 md:p-6 min-h-[420px]">
|
<div className="flex-1 bg-white rounded-lg p-4 md:p-6 min-h-[420px]">
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: '帮助中心',
|
||||||
|
description: '蓝狐代理帮助中心 - 产品使用教程、常见问题解答、行业资讯、代理IP设置指南',
|
||||||
|
openGraph: {
|
||||||
|
title: '帮助中心',
|
||||||
|
description: '蓝狐代理帮助中心 - 产品使用教程、常见问题解答、行业资讯',
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: '帮助中心',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/docs`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function DocsIndexPage() {
|
export default function DocsIndexPage() {
|
||||||
return (
|
return (
|
||||||
<div className="text-center text-slate-500 py-12">
|
<div className="text-center text-slate-500 py-12">
|
||||||
|
|||||||
@@ -1,59 +1,11 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import {useState, useMemo, useCallback} from 'react'
|
import {useState, useEffect, useMemo} from 'react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import {usePathname} from 'next/navigation'
|
import {usePathname} from 'next/navigation'
|
||||||
import {ChevronRight} from 'lucide-react'
|
import {ChevronRight} from 'lucide-react'
|
||||||
import {merge} from '@/lib/utils'
|
import {merge} from '@/lib/utils'
|
||||||
|
import {getArticleNav} from '@/actions/article'
|
||||||
// 菜单配置
|
import type {ArticleNavGroup} from '@/lib/models/article'
|
||||||
const MENU_ITEMS = [
|
|
||||||
{
|
|
||||||
group: '产品文档',
|
|
||||||
items: [
|
|
||||||
{key: 'product-overview', label: '产品介绍'},
|
|
||||||
{key: 'choose-product', label: '如何选择产品'},
|
|
||||||
{key: 'why-verify', label: '为什么需要实名认证'},
|
|
||||||
{key: 'city-lines', label: '有哪些城市线路'},
|
|
||||||
{key: 'api-docs', label: 'ip提取接口文档'},
|
|
||||||
// 服务条款
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
group: '操作指南',
|
|
||||||
items: [
|
|
||||||
{key: 'profile-settings', label: '修改个人信息和重置密码'},
|
|
||||||
{key: 'whitelist-guide', label: '如何添加白名单'},
|
|
||||||
{key: 'verify-guide', label: '如何进行实名认证'},
|
|
||||||
{key: 'extract-link', label: '如何生成提取链接'},
|
|
||||||
{key: 'payment-records', label: '查看支付和使用记录'},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
group: '客户端教程',
|
|
||||||
items: [
|
|
||||||
{key: 'browser-proxy', label: '浏览器设置代理教程'},
|
|
||||||
{key: 'ios-proxy', label: 'iOS设置代理教程'},
|
|
||||||
{key: 'android-proxy', label: '安卓手机设置代理教程'},
|
|
||||||
{key: 'windows10-proxy', label: 'Windows10设置代理教程'},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
group: '常见问题',
|
|
||||||
items: [
|
|
||||||
{key: 'faq-general', label: '常见问题总览'},
|
|
||||||
{key: 'faq-billing', label: '计费与套餐问题'},
|
|
||||||
// 业务场景集成方案
|
|
||||||
// 故障排查
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
group: '新闻资讯',
|
|
||||||
items: [
|
|
||||||
{key: 'news-latest', label: '了解代理服务器的工作原理'},
|
|
||||||
{key: 'news-announce', label: '网站公告'},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string
|
className?: string
|
||||||
@@ -62,88 +14,126 @@ type Props = {
|
|||||||
|
|
||||||
export default function Sidebar({className, onClose}: Props) {
|
export default function Sidebar({className, onClose}: Props) {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
const [navGroups, setNavGroups] = useState<ArticleNavGroup[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [manualExpanded, setManualExpanded] = useState<Record<string, boolean>>({})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadNav = async () => {
|
||||||
|
const resp = await getArticleNav({})
|
||||||
|
if (resp.success) {
|
||||||
|
setNavGroups(resp.data || [])
|
||||||
|
}
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
loadNav()
|
||||||
|
}, [])
|
||||||
|
|
||||||
// 获取当前文档 key
|
|
||||||
const getCurrentKey = useCallback(() => {
|
|
||||||
const parts = pathname?.split('/') || []
|
const parts = pathname?.split('/') || []
|
||||||
return parts[2] || ''
|
const currentArticleId = parts[3]
|
||||||
}, [pathname])
|
|
||||||
|
|
||||||
const currentKey = getCurrentKey()
|
const autoExpanded = useMemo(() => {
|
||||||
|
|
||||||
// 展开/收起状态
|
|
||||||
const [expandedGroups, setExpandedGroups] = useState<Record<string, boolean>>({})
|
|
||||||
|
|
||||||
// 初始化:自动展开包含当前活跃项的分组
|
|
||||||
const initialExpandedGroups = useMemo(() => {
|
|
||||||
const result: Record<string, boolean> = {}
|
const result: Record<string, boolean> = {}
|
||||||
MENU_ITEMS.forEach((section, index) => {
|
|
||||||
const hasActive = section.items.some(item => item.key === currentKey)
|
if (navGroups.length === 0) return result
|
||||||
if (hasActive || index === 0) {
|
|
||||||
result[section.group] = true
|
let activeGroupCode: string | null = null
|
||||||
|
navGroups.forEach((group) => {
|
||||||
|
const hasActive = group.articles.some(
|
||||||
|
article => String(article.id) === currentArticleId,
|
||||||
|
)
|
||||||
|
if (hasActive) {
|
||||||
|
activeGroupCode = group.code
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
result[navGroups[0].code] = true
|
||||||
|
|
||||||
|
if (activeGroupCode && activeGroupCode !== navGroups[0].code) {
|
||||||
|
result[activeGroupCode] = true
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}, [currentKey])
|
}, [navGroups, currentArticleId])
|
||||||
|
|
||||||
// 合并自动展开和用户手动切换
|
const expandedGroups = useMemo(() => {
|
||||||
const finalExpandedGroups = useMemo(() => {
|
return {...autoExpanded, ...manualExpanded}
|
||||||
return {...initialExpandedGroups, ...expandedGroups}
|
}, [autoExpanded, manualExpanded])
|
||||||
}, [initialExpandedGroups, expandedGroups])
|
|
||||||
|
|
||||||
const toggleGroup = (group: string) => {
|
const toggleGroup = (groupCode: string) => {
|
||||||
setExpandedGroups(prev => ({
|
setManualExpanded(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
[group]: !finalExpandedGroups[group],
|
[groupCode]: !expandedGroups[groupCode],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const getItemHref = (key: string) => `/docs/${key}`
|
const getActiveArticleId = () => {
|
||||||
|
return currentArticleId || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<aside className={merge('bg-white rounded-lg p-3', className)}>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{[1, 2, 3].map(i => (
|
||||||
|
<div key={i} className="h-10 bg-gray-100 rounded animate-pulse"/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navGroups.length === 0) {
|
||||||
|
return (
|
||||||
|
<aside className={merge('bg-white rounded-lg p-3', className)}>
|
||||||
|
<div className="text-center text-slate-400 py-4">
|
||||||
|
暂无文档
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside
|
<aside className={merge('bg-white rounded-lg p-3 transition-all duration-200 shrink-0', className)}>
|
||||||
className={merge(`bg-white rounded-lg p-3 transition-all duration-200 shrink-0`, className)}
|
|
||||||
>
|
|
||||||
<nav className="space-y-2">
|
<nav className="space-y-2">
|
||||||
{MENU_ITEMS.map(section => (
|
{navGroups.map(group => (
|
||||||
<div key={section.group}>
|
<div key={group.code}>
|
||||||
<div
|
<div
|
||||||
onClick={() => toggleGroup(section.group)}
|
onClick={() => toggleGroup(group.code)}
|
||||||
className={`flex items-center gap-2 cursor-pointer px-3 py-2 rounded-sm transition-colors ${
|
className={`flex items-center gap-2 cursor-pointer px-3 py-2 rounded-sm transition-colors ${
|
||||||
finalExpandedGroups[section.group] && 'bg-blue-50'
|
expandedGroups[group.code] && 'bg-blue-50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`w-4 flex items-center justify-center text-sm text-slate-400 transform transition-transform ${
|
className={`w-4 flex items-center justify-center text-sm text-slate-400 transform transition-transform ${
|
||||||
finalExpandedGroups[section.group] ? 'rotate-90' : ''
|
expandedGroups[group.code] ? 'rotate-90' : ''
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<ChevronRight size={16}/>
|
<ChevronRight size={16}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="text-lg font-semibold text-slate-900">
|
<div className="text-lg font-semibold text-slate-900">
|
||||||
{section.group}
|
{group.name}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{finalExpandedGroups[section.group] && (
|
{expandedGroups[group.code] && (
|
||||||
<ul className="mt-1 text-base">
|
<ul className="mt-1 text-base">
|
||||||
{section.items.map((item) => {
|
{group.articles.map((article) => {
|
||||||
const isActive = currentKey === item.key
|
const isActive = getActiveArticleId() === String(article.id)
|
||||||
const href = getItemHref(item.key)
|
const href = `/docs/${group.code}/${article.id}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={item.key}>
|
<li key={article.id}>
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href={href}
|
||||||
onClick={() => onClose?.()}
|
onClick={() => onClose?.()}
|
||||||
className={`block pl-8 py-2 text-base cursor-pointer transition-colors ${
|
className={`block pl-8 py-2 text-base cursor-pointer transition-colors ${
|
||||||
isActive
|
isActive
|
||||||
? 'bg-blue-50 font-semibold'
|
? 'bg-blue-50 font-semibold text-blue-600'
|
||||||
: 'text-slate-700 hover:text-slate-900 hover:bg-slate-50'
|
: 'text-slate-700 hover:text-slate-900 hover:bg-slate-50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{item.label}
|
{article.title}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/e-commerce`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function ECommercePage() {
|
export default function ECommercePage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/market-research`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function MarketResearchPage() {
|
export default function MarketResearchPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/network-testing`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function NetworkTestingPage() {
|
export default function NetworkTestingPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import {Suspense} from 'react'
|
||||||
|
import {Metadata} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import BreadCrumb from '@/components/bread-crumb'
|
import BreadCrumb from '@/components/bread-crumb'
|
||||||
import Wrap from '@/components/wrap'
|
import Wrap from '@/components/wrap'
|
||||||
import Purchase, {TabType} from '@/components/composites/purchase'
|
import Purchase, {TabType} from '@/components/composites/purchase'
|
||||||
import {Suspense} from 'react'
|
|
||||||
import HomePage from '@/components/home/page'
|
import HomePage from '@/components/home/page'
|
||||||
|
|
||||||
export type ProductPageProps = {
|
export type ProductPageProps = {
|
||||||
@@ -10,6 +12,28 @@ export type ProductPageProps = {
|
|||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: '产品中心',
|
||||||
|
description: '为您的业务提供多样化代理产品 - 短效代理、长效代理、固定IP代理、SOCKS5代理,高可用性、低延迟',
|
||||||
|
openGraph: {
|
||||||
|
title: '产品中心',
|
||||||
|
description: '为您的业务提供多样化代理产品 - 短效代理、长效代理、固定IP代理、SOCKS5代理,高可用性、低延迟',
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: '产品中心',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/product`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function ProductPage(props: ProductPageProps) {
|
export default function ProductPage(props: ProductPageProps) {
|
||||||
return (
|
return (
|
||||||
<HomePage path={[
|
<HomePage path={[
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/seo-optimization`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function SeoOptimizationPage() {
|
export default function SeoOptimizationPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import {Metadata} from 'next'
|
||||||
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
import ScenePage, {ScenePageConfig} from '@/components/scene-page'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
import bannerImg from './_assets/banner.webp'
|
import bannerImg from './_assets/banner.webp'
|
||||||
import solutionImg from './_assets/solution-main.webp'
|
import solutionImg from './_assets/solution-main.webp'
|
||||||
import value1Img from './_assets/value-1.webp'
|
import value1Img from './_assets/value-1.webp'
|
||||||
@@ -46,6 +48,28 @@ const config: ScenePageConfig = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
openGraph: {
|
||||||
|
title: config.banner.title,
|
||||||
|
description: config.banner.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: config.banner.title,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: `${siteConfig.url}/social-media`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function SocialMediaPage() {
|
export default function SocialMediaPage() {
|
||||||
return <ScenePage {...config}/>
|
return <ScenePage {...config}/>
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/app/admin/balance/layout.tsx
Normal file
16
src/app/admin/balance/layout.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import {ReactNode} from 'react'
|
||||||
|
import {Metadata} from 'next'
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
return {
|
||||||
|
title: '余额管理 - 蓝狐代理',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PurchaseLayoutProps = {
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function PurchaseLayout(props: PurchaseLayoutProps) {
|
||||||
|
return props.children
|
||||||
|
}
|
||||||
236
src/app/admin/balance/page.tsx
Normal file
236
src/app/admin/balance/page.tsx
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
'use client'
|
||||||
|
import {Suspense, useCallback, useEffect, useState} from 'react'
|
||||||
|
import {PageRecord} from '@/lib/api'
|
||||||
|
import {Balance} from '@/lib/models'
|
||||||
|
import {useStatus} from '@/lib/states'
|
||||||
|
import {Search, Eraser} from 'lucide-react'
|
||||||
|
import {Button} from '@/components/ui/button'
|
||||||
|
import DataTable from '@/components/data-table'
|
||||||
|
import {format} from 'date-fns'
|
||||||
|
import DatePicker from '@/components/date-picker'
|
||||||
|
import {Form, FormField} from '@/components/ui/form'
|
||||||
|
import {useForm} from 'react-hook-form'
|
||||||
|
import zod from 'zod'
|
||||||
|
import {zodResolver} from '@hookform/resolvers/zod'
|
||||||
|
import {Label} from '@/components/ui/label'
|
||||||
|
import Page from '@/components/page'
|
||||||
|
import {CheckCircle, AlertCircle} from 'lucide-react'
|
||||||
|
import {Input} from '@/components/ui/input'
|
||||||
|
import {listBalances} from '@/actions/balance'
|
||||||
|
|
||||||
|
const filterSchema = zod.object({
|
||||||
|
created_at_start: zod.date().optional(),
|
||||||
|
created_at_end: zod.date().optional(),
|
||||||
|
bill_no: zod.string().optional(),
|
||||||
|
})
|
||||||
|
type FilterSchema = zod.infer<typeof filterSchema>
|
||||||
|
|
||||||
|
export type BalancePageProps = {}
|
||||||
|
|
||||||
|
export default function BalancePage(props: BalancePageProps) {
|
||||||
|
const [status, setStatus] = useStatus()
|
||||||
|
const [data, setData] = useState<PageRecord<Balance>>({
|
||||||
|
page: 1,
|
||||||
|
size: 10,
|
||||||
|
total: 0,
|
||||||
|
list: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
const form = useForm<FilterSchema>({
|
||||||
|
resolver: zodResolver(filterSchema),
|
||||||
|
defaultValues: {
|
||||||
|
bill_no: '',
|
||||||
|
created_at_start: undefined,
|
||||||
|
created_at_end: undefined,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const onSubmit = async (value: FilterSchema) => {
|
||||||
|
await refresh(1, data.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
const refresh = useCallback(async (page: number, size: number) => {
|
||||||
|
setStatus('load')
|
||||||
|
try {
|
||||||
|
const created_at_start = form.getValues('created_at_start')
|
||||||
|
const created_at_end = form.getValues('created_at_end')
|
||||||
|
const bill_no = form.getValues('bill_no')
|
||||||
|
|
||||||
|
const res = await listBalances({
|
||||||
|
page, size,
|
||||||
|
created_at_start,
|
||||||
|
created_at_end,
|
||||||
|
bill_no: bill_no || undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.success) {
|
||||||
|
setData(res.data)
|
||||||
|
setStatus('done')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('Failed to load bills')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
setStatus('fail')
|
||||||
|
}
|
||||||
|
}, [form, setStatus])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
refresh(1, 10).then()
|
||||||
|
}, [refresh])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page>
|
||||||
|
<section className="flex justify-between flex-wrap">
|
||||||
|
<Form form={form} handler={form.handleSubmit(onSubmit)} className="flex-auto flex flex-wrap gap-4 items-end">
|
||||||
|
<FormField name="bill_no" label={<span className="text-sm">账单编号</span>}>
|
||||||
|
{({id, field}) => {
|
||||||
|
return <Input {...field} id={id} className="h-9"/>
|
||||||
|
}}
|
||||||
|
</FormField>
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<Label className="text-sm">创建时间</Label>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<FormField name="created_at_start">
|
||||||
|
{({field}) => {
|
||||||
|
const dateValue = typeof field.value === 'string' && field.value ? new Date(field.value) : undefined
|
||||||
|
return (
|
||||||
|
<DatePicker
|
||||||
|
placeholder="选择开始时间"
|
||||||
|
{...field}
|
||||||
|
format="yyyy-MM-dd"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</FormField>
|
||||||
|
<span className="px-1">-</span>
|
||||||
|
<FormField name="created_at_end">
|
||||||
|
{({field}) => (
|
||||||
|
<DatePicker
|
||||||
|
placeholder="选择结束时间"
|
||||||
|
{...field}
|
||||||
|
format="yyyy-MM-dd"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</FormField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button className="h-9" type="submit">
|
||||||
|
<Search/>
|
||||||
|
<span>筛选</span>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
theme="outline"
|
||||||
|
className="h-9"
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
form.reset()
|
||||||
|
refresh(1, data.size)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Eraser/>
|
||||||
|
<span>重置</span>
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
</section>
|
||||||
|
<Suspense>
|
||||||
|
<DataTable
|
||||||
|
data={data.list}
|
||||||
|
status={status}
|
||||||
|
pagination={{
|
||||||
|
total: data.total,
|
||||||
|
page: data.page,
|
||||||
|
size: data.size,
|
||||||
|
onPageChange: async (page: number) => {
|
||||||
|
await refresh(page, data.size)
|
||||||
|
},
|
||||||
|
onSizeChange: async (size: number) => {
|
||||||
|
await refresh(data.page, size)
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
columns={[
|
||||||
|
{accessorKey: 'bill_no', header: `账单编号`,
|
||||||
|
accessorFn: row => row.bill?.bill_no || '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'status',
|
||||||
|
header: `状态`,
|
||||||
|
cell: ({row}) => {
|
||||||
|
const trade = row.original.trade
|
||||||
|
if (![1, 2, 3, 4, 5].includes(trade?.method)) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<CheckCircle size={16} className="text-done"/>
|
||||||
|
<span>已完成</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!trade) return <span>-</span>
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{trade?.status === 1 ? (
|
||||||
|
<CheckCircle size={16} className="text-done"/>
|
||||||
|
) : trade?.status === 2 ? (
|
||||||
|
<AlertCircle size={16} className="text-weak"/>
|
||||||
|
) : trade?.status === 3 ? (
|
||||||
|
<AlertCircle size={16} className="text-fail"/>
|
||||||
|
) : null}
|
||||||
|
<span>
|
||||||
|
{trade?.status === 1 ? '已完成'
|
||||||
|
: trade?.status === 2 ? '已取消'
|
||||||
|
: trade?.status === 3 ? '已退款' : '-'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'amount',
|
||||||
|
header: '变动金额',
|
||||||
|
cell: ({row}) => {
|
||||||
|
const amount = row.original.amount
|
||||||
|
const isPositive = Number(amount) > 0
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<span
|
||||||
|
className={`font-semibold ${
|
||||||
|
isPositive ? 'text-green-600' : 'text-red-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isPositive ? '+' : ''}
|
||||||
|
{Number(amount).toFixed(2)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: '余额变化',
|
||||||
|
accessorKey: 'balance_prev',
|
||||||
|
cell: ({row}) => (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-gray-500 text-sm">¥{Number(row.original.balance_prev).toFixed(2)}</span>
|
||||||
|
<span className="text-muted-foreground">→</span>
|
||||||
|
<span>¥{Number(row.original.balance_curr).toFixed(2)}</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: '备注',
|
||||||
|
accessorKey: 'remark',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: '创建时间',
|
||||||
|
accessorKey: 'created_at',
|
||||||
|
cell: ({row}) =>
|
||||||
|
format(new Date(row.original.created_at), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</Page>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import {useCallback, useEffect, useState} from 'react'
|
import {Suspense, useCallback, useEffect, useState} from 'react'
|
||||||
import {PageRecord} from '@/lib/api'
|
import {PageRecord} from '@/lib/api'
|
||||||
import {Bill} from '@/lib/models'
|
import {Bill} from '@/lib/models'
|
||||||
import {useStatus} from '@/lib/states'
|
import {useStatus} from '@/lib/states'
|
||||||
@@ -88,7 +88,7 @@ export default function BillsPage(props: BillsPageProps) {
|
|||||||
<div>
|
<div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form form={form} handler={form.handleSubmit(onSubmit)} className="flex items-end gap-4 flex-wrap">
|
<Form form={form} handler={form.handleSubmit(onSubmit)} className="flex-auto flex flex-wrap gap-4 items-end">
|
||||||
<FormField name="type" label={<span className="text-sm">账单类型</span>}>
|
<FormField name="type" label={<span className="text-sm">账单类型</span>}>
|
||||||
{({id, field}) => (
|
{({id, field}) => (
|
||||||
<Select value={field.value} onValueChange={field.onChange}>
|
<Select value={field.value} onValueChange={field.onChange}>
|
||||||
@@ -141,6 +141,7 @@ export default function BillsPage(props: BillsPageProps) {
|
|||||||
</Form>
|
</Form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<Suspense>
|
||||||
<DataTable
|
<DataTable
|
||||||
data={data.list}
|
data={data.list}
|
||||||
status={status}
|
status={status}
|
||||||
@@ -273,26 +274,26 @@ export default function BillsPage(props: BillsPageProps) {
|
|||||||
<span>手机网站</span>
|
<span>手机网站</span>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<span>-</span>
|
<></>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'created_at', header: '创建时间', cell: ({row}) => (
|
accessorKey: 'created_at',
|
||||||
format(new Date(row.original.created_at), 'yyyy-MM-dd HH:mm')
|
header: '创建时间',
|
||||||
),
|
cell: ({row}) => {
|
||||||
|
const createdAt = row.original.created_at
|
||||||
|
if (!createdAt) return <span></span>
|
||||||
|
const date = new Date(createdAt)
|
||||||
|
if (isNaN(date.getTime())) return <span></span>
|
||||||
|
return format(date, 'yyyy-MM-dd HH:mm:ss')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// accessorKey: 'action', header: `操作`, cell: item => (
|
|
||||||
// <div className="flex gap-2">
|
|
||||||
// -
|
|
||||||
// </div>
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
</Page>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,11 +214,35 @@ export default function ChannelsPage(props: ChannelsPageProps) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: '提取时间',
|
header: '提取时间',
|
||||||
cell: ({row}) => format(row.original.created_at, 'yyyy-MM-dd HH:mm'),
|
cell: ({row}) => {
|
||||||
|
const timeValue = row.original.created_at
|
||||||
|
if (!timeValue) return <div>-</div>
|
||||||
|
|
||||||
|
try {
|
||||||
|
const date = new Date(timeValue)
|
||||||
|
if (isNaN(date.getTime())) return <div>-</div>
|
||||||
|
return <div>{format(date, 'yyyy-MM-dd HH:mm:ss')}</div>
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return <div>-</div>
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: '过期时间',
|
header: '过期时间',
|
||||||
cell: ({row}) => format(row.original.expired_at, 'yyyy-MM-dd HH:mm:ss'),
|
cell: ({row}) => {
|
||||||
|
const timeValue = row.original.expired_at
|
||||||
|
if (!timeValue) return <div>-</div>
|
||||||
|
|
||||||
|
try {
|
||||||
|
const date = new Date(timeValue)
|
||||||
|
if (isNaN(date.getTime())) return <div>-</div>
|
||||||
|
return <div>{format(date, 'yyyy-MM-dd HH:mm:ss')}</div>
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return <div>-</div>
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {RealnameAuthDialog} from '@/components/composites/dialogs/realname-auth-
|
|||||||
import UserCenter from '@/components/composites/user-center'
|
import UserCenter from '@/components/composites/user-center'
|
||||||
import {Button} from '@/components/ui/button'
|
import {Button} from '@/components/ui/button'
|
||||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@/components/ui/tooltip'
|
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@/components/ui/tooltip'
|
||||||
import {Archive, ArchiveRestore, Eye, HardDriveUpload, IdCard, LockKeyhole, Package, PanelLeftCloseIcon, PanelLeftOpenIcon, ShoppingCart, UserRound, UserRoundPen, Wallet} from 'lucide-react'
|
import {Archive, ArchiveRestore, CircleDollarSign, Eye, HardDriveUpload, IdCard, LockKeyhole, MessageCircleMoreIcon, Package, PanelLeftCloseIcon, PanelLeftOpenIcon, ShoppingCart, UserRound, UserRoundPen, Wallet} from 'lucide-react'
|
||||||
import {merge} from '@/lib/utils'
|
import {merge} from '@/lib/utils'
|
||||||
import logoAvatar from '@/assets/logo-avatar.svg'
|
import logoAvatar from '@/assets/logo-avatar.svg'
|
||||||
import logoText from '@/assets/logo-text.svg'
|
import logoText from '@/assets/logo-text.svg'
|
||||||
@@ -93,7 +93,8 @@ function ContentResolved() {
|
|||||||
export function Header() {
|
export function Header() {
|
||||||
const navbar = useLayoutStore(store => store.navbar)
|
const navbar = useLayoutStore(store => store.navbar)
|
||||||
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
||||||
|
const profile = use(useProfileStore(store => store.profile))
|
||||||
|
const showRealnameAuth = profile?.id_type === 0
|
||||||
return (
|
return (
|
||||||
<header className={merge(
|
<header className={merge(
|
||||||
`flex-none h-16 overflow-hidden`,
|
`flex-none h-16 overflow-hidden`,
|
||||||
@@ -119,6 +120,7 @@ export function Header() {
|
|||||||
</Button>
|
</Button>
|
||||||
<span className="max-md:hidden">欢迎来到,蓝狐代理</span>
|
<span className="max-md:hidden">欢迎来到,蓝狐代理</span>
|
||||||
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
||||||
|
{showRealnameAuth ? (
|
||||||
<Link
|
<Link
|
||||||
href="/admin/identify"
|
href="/admin/identify"
|
||||||
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
||||||
@@ -126,6 +128,25 @@ export function Header() {
|
|||||||
<IdCard size={16}/>
|
<IdCard size={16}/>
|
||||||
<span>实名认证</span>
|
<span>实名认证</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href=""
|
||||||
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-green-400 hover:text-green-400 transition-colors"
|
||||||
|
>
|
||||||
|
<IdCard size={16}/>
|
||||||
|
<span>已实名</span>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
||||||
|
<a
|
||||||
|
href="https://wpa1.qq.com/K0s0cvwf?_type=wpa&qidian=true"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors mr-2"
|
||||||
|
>
|
||||||
|
<MessageCircleMoreIcon size={16}/>
|
||||||
|
<span>联系专属客服</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-none flex items-center justify-end pr-4 max-md:hidden gap-3">
|
<div className="flex-none flex items-center justify-end pr-4 max-md:hidden gap-3">
|
||||||
@@ -190,6 +211,7 @@ export function Navbar() {
|
|||||||
<NavItem href="/admin/extract" icon={<HardDriveUpload size={20}/>} label="提取 IP" expand={navbar}/>
|
<NavItem href="/admin/extract" icon={<HardDriveUpload size={20}/>} label="提取 IP" expand={navbar}/>
|
||||||
<NavTitle label="个人中心"/>
|
<NavTitle label="个人中心"/>
|
||||||
<NavItem href="/admin/profile" icon={<UserRoundPen size={20}/>} label="基本信息" expand={navbar}/>
|
<NavItem href="/admin/profile" icon={<UserRoundPen size={20}/>} label="基本信息" expand={navbar}/>
|
||||||
|
<NavItem href="/admin/balance" icon={<CircleDollarSign size={20}/>} label="余额管理" expand={navbar}/>
|
||||||
<NavItem href="/admin/bills" icon={<Wallet size={20}/>} label="我的账单" expand={navbar}/>
|
<NavItem href="/admin/bills" icon={<Wallet size={20}/>} label="我的账单" expand={navbar}/>
|
||||||
<NavTitle label="资源管理"/>
|
<NavTitle label="资源管理"/>
|
||||||
<NavItem href="/admin/resources" icon={<Package size={20}/>} label="我的套餐" expand={navbar}/>
|
<NavItem href="/admin/resources" icon={<Package size={20}/>} label="我的套餐" expand={navbar}/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {ReactNode} from 'react'
|
import {ReactNode, Suspense} from 'react'
|
||||||
import {Shell, Content, Header, Navbar, Mask} from './clients'
|
import {Shell, Content, Header, Navbar, Mask} from './clients'
|
||||||
|
|
||||||
export default function Template(props: {
|
export default function Template(props: {
|
||||||
@@ -13,7 +13,9 @@ export default function Template(props: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-start-2 row-start-1 bg-card overflow-hidden relative z-20">
|
<div className="col-start-2 row-start-1 bg-card overflow-hidden relative z-20">
|
||||||
|
<Suspense>
|
||||||
<Header/>
|
<Header/>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svg className="col-start-2 row-start-2 w-full h-full z-20 pointer-events-none" preserveAspectRatio="none">
|
<svg className="col-start-2 row-start-2 w-full h-full z-20 pointer-events-none" preserveAspectRatio="none">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import DatePicker from '@/components/date-picker'
|
|||||||
import {Button} from '@/components/ui/button'
|
import {Button} from '@/components/ui/button'
|
||||||
import {EraserIcon, SearchIcon} from 'lucide-react'
|
import {EraserIcon, SearchIcon} from 'lucide-react'
|
||||||
import {pageBatch} from '@/actions/batch'
|
import {pageBatch} from '@/actions/batch'
|
||||||
|
import {Input} from '@/components/ui/input'
|
||||||
|
|
||||||
export type RecordPageProps = {}
|
export type RecordPageProps = {}
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
const filterSchema = z.object({
|
const filterSchema = z.object({
|
||||||
time_start: z.date().optional(),
|
time_start: z.date().optional(),
|
||||||
time_end: z.date().optional(),
|
time_end: z.date().optional(),
|
||||||
|
resource_no: z.string().optional(),
|
||||||
})
|
})
|
||||||
type FilterSchema = z.infer<typeof filterSchema>
|
type FilterSchema = z.infer<typeof filterSchema>
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
time_start: undefined,
|
time_start: undefined,
|
||||||
time_end: undefined,
|
time_end: undefined,
|
||||||
|
resource_no: '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -53,7 +56,9 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
const result = await pageBatch({
|
const result = await pageBatch({
|
||||||
page,
|
page,
|
||||||
size,
|
size,
|
||||||
...filter,
|
time_start: filter.time_start,
|
||||||
|
time_end: filter.time_end,
|
||||||
|
resource_no: filter.resource_no || undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
@@ -88,9 +93,19 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
<section className="flex justify-between">
|
<section className="flex justify-between">
|
||||||
<div></div>
|
<div></div>
|
||||||
<Form form={filterForm} handler={filterHandler} className="flex-auto flex flex-wrap gap-4 items-end">
|
<Form form={filterForm} handler={filterHandler} className="flex-auto flex flex-wrap gap-4 items-end">
|
||||||
|
<FormField name="resource_no" label={<span className="text-sm">套餐编号</span>}>
|
||||||
|
{({id, field}) => (
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
className="h-9"
|
||||||
|
value={field.value ?? ''}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
<fieldset className="flex flex-col gap-2 items-start">
|
<fieldset className="flex flex-col gap-2 items-start">
|
||||||
<div>
|
<div>
|
||||||
<legend className="block text-sm">提取时间</legend>
|
<legend className="block text-sm">过期时间</legend>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1 items-center">
|
<div className="flex gap-1 items-center">
|
||||||
<FormField<FilterSchema, 'time_start'> name="time_start" >
|
<FormField<FilterSchema, 'time_start'> name="time_start" >
|
||||||
@@ -144,6 +159,10 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
onSizeChange: size => fetchRecords(1, size),
|
onSizeChange: size => fetchRecords(1, size),
|
||||||
}}
|
}}
|
||||||
columns={[
|
columns={[
|
||||||
|
{
|
||||||
|
header: '套餐编号',
|
||||||
|
accessorKey: 'resource.resource_no',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
header: '批次号',
|
header: '批次号',
|
||||||
cell: ({row}) => <div>{row.original.batch_no}</div>,
|
cell: ({row}) => <div>{row.original.batch_no}</div>,
|
||||||
@@ -174,11 +193,6 @@ export default function RecordPage(props: RecordPageProps) {
|
|||||||
cell: ({row}) => <div>{row.original.count}</div>,
|
cell: ({row}) => <div>{row.original.count}</div>,
|
||||||
accessorKey: 'count',
|
accessorKey: 'count',
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// header: '资源数量',
|
|
||||||
// cell: ({row}) => <div>{row.original.resource_id}</div>,
|
|
||||||
// accessorKey: 'resource_id',
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
header: '提取时间',
|
header: '提取时间',
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function ResourceFilter({form, onSubmit, onReset}: ResourceFilter
|
|||||||
const handler = form.handleSubmit(onSubmit)
|
const handler = form.handleSubmit(onSubmit)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form form={form} handler={handler} className="flex items-end gap-4 flex-wrap">
|
<Form form={form} handler={handler} className="flex-auto flex flex-wrap gap-4 items-end">
|
||||||
<FormField name="resource_no" label={<span className="text-sm">套餐编号</span>}>
|
<FormField name="resource_no" label={<span className="text-sm">套餐编号</span>}>
|
||||||
{({id, field}) => (
|
{({id, field}) => (
|
||||||
<Input {...field} id={id} className="h-9"/>
|
<Input {...field} id={id} className="h-9"/>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import zod from 'zod'
|
|||||||
import {toast} from 'sonner'
|
import {toast} from 'sonner'
|
||||||
import {useStatus} from '@/lib/states'
|
import {useStatus} from '@/lib/states'
|
||||||
import {ExtraResp} from '@/lib/api'
|
import {ExtraResp} from '@/lib/api'
|
||||||
import {listResourceLong, listResourceShort} from '@/actions/resource'
|
import {listResourceLong, listResourceShort, updateCheckip} from '@/actions/resource'
|
||||||
import DataTable from '@/components/data-table'
|
import DataTable from '@/components/data-table'
|
||||||
import {ColumnDef} from '@tanstack/react-table'
|
import {ColumnDef} from '@tanstack/react-table'
|
||||||
import {Resource} from '@/lib/models/resource'
|
import {Resource} from '@/lib/models/resource'
|
||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
isValidResourceType,
|
isValidResourceType,
|
||||||
ResourceTypeBadge,
|
ResourceTypeBadge,
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
import {Button} from '@/components/ui/button'
|
||||||
|
|
||||||
const filterSchema = zod.object({
|
const filterSchema = zod.object({
|
||||||
resource_no: zod.string().optional().default(''),
|
resource_no: zod.string().optional().default(''),
|
||||||
@@ -130,11 +131,31 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCheckipChange = async (id: number, currentCheckip: boolean) => {
|
||||||
|
try {
|
||||||
|
const result = await updateCheckip({
|
||||||
|
id: id,
|
||||||
|
checkip: !currentCheckip,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
toast.success(`IP检查已${!currentCheckip ? '启用' : '停用'}`)
|
||||||
|
await refresh(data.page, data.size)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(result.message || '操作失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '更新IP检查状态失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 表格列定义
|
// 表格列定义
|
||||||
const columns = useMemo<ColumnDef<Resource<1> | Resource<2>>[]>(() => {
|
const columns = useMemo<ColumnDef<Resource<1> | Resource<2>>[]>(() => {
|
||||||
const resourceKey = isLong ? 'long' : 'short'
|
const resourceKey = isLong ? 'long' : 'short'
|
||||||
|
|
||||||
const baseColumns: ColumnDef<Resource<1> | Resource<2>>[] = [
|
const baseColumns = ([
|
||||||
{
|
{
|
||||||
header: '套餐编号',
|
header: '套餐编号',
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
@@ -165,7 +186,7 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
const live = resourceKey === 'long'
|
const live = resourceKey === 'long'
|
||||||
? (row.original as Resource<2>).long.live
|
? (row.original as Resource<2>).long.live
|
||||||
: (row.original as Resource<1>).short.live
|
: (row.original as Resource<1>).short.live
|
||||||
return <span>{isLong ? `${live}小时` : `${live}分钟`}</span>
|
return <span>{isLong ? `${live}分钟` : `${live}分钟`}</span>
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -218,7 +239,11 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
{
|
{
|
||||||
header: '开通时间',
|
header: '开通时间',
|
||||||
cell: ({row}) => formatDateTime(row.original.created_at),
|
cell: ({row}) => formatDateTime(row.original.created_at),
|
||||||
},
|
}, // 短效资源增加到期时间列
|
||||||
|
!isLong ? {
|
||||||
|
header: '到期时间',
|
||||||
|
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
||||||
|
} : undefined,
|
||||||
{
|
{
|
||||||
header: '状态',
|
header: '状态',
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
@@ -230,15 +255,22 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
{
|
||||||
|
header: '操作',
|
||||||
// 短效资源增加到期时间列
|
cell: ({row}) => {
|
||||||
if (!isLong) {
|
const checkip = row.original.checkip
|
||||||
baseColumns.push({
|
return (
|
||||||
header: '到期时间',
|
<Button
|
||||||
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
theme={checkip ? 'fail' : 'default'}
|
||||||
})
|
className="h-7 px-3 text-sm"
|
||||||
}
|
onClick={() => handleCheckipChange(row.original.id, row.original.checkip)}
|
||||||
|
>
|
||||||
|
{checkip ? '停用IP检查' : '启用IP检查'}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
] satisfies ((ColumnDef<Resource<1> | Resource<2>> | undefined)[])).filter(Boolean) as ColumnDef<Resource<1> | Resource<2>>[]
|
||||||
|
|
||||||
return baseColumns
|
return baseColumns
|
||||||
}, [isLong])
|
}, [isLong])
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export function ExpireBadge({expireAt}: {expireAt: Date}) {
|
|||||||
// 格式化日期
|
// 格式化日期
|
||||||
export function formatDateTime(date: Date | null | undefined) {
|
export function formatDateTime(date: Date | null | undefined) {
|
||||||
if (!date) return '-'
|
if (!date) return '-'
|
||||||
return format(date, 'yyyy-MM-dd HH:mm')
|
return format(date, 'yyyy-MM-dd HH:mm:ss')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算今日使用量
|
// 计算今日使用量
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ export default function WhitelistPage(props: WhitelistPageProps) {
|
|||||||
header: `备注`, accessorKey: 'remark',
|
header: `备注`, accessorKey: 'remark',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: `添加时间`, cell: ({row}) => format(parseISO(row.original.created_at), 'yyyy-MM-dd HH:mm'),
|
header: `添加时间`, cell: ({row}) => format(parseISO(row.original.created_at), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions', header: `操作`, cell: ({row}) => (
|
id: 'actions', header: `操作`, cell: ({row}) => (
|
||||||
|
|||||||
@@ -156,8 +156,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* highlight.js 样式覆盖 */
|
/* highlight.js 样式覆盖 - 确保代码块高亮在前台正常显示 */
|
||||||
pre code.hljs {
|
.prose pre {
|
||||||
|
background: #2b2b2b;
|
||||||
|
color: #abb2bf;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose pre code {
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose pre code.hljs {
|
||||||
background: inherit;
|
background: inherit;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,71 @@
|
|||||||
import './globals.css'
|
import './globals.css'
|
||||||
import {ReactNode} from 'react'
|
import {ReactNode} from 'react'
|
||||||
import {Metadata} from 'next'
|
import {Metadata, Viewport} from 'next'
|
||||||
import {Toaster} from '@/components/ui/sonner'
|
import {Toaster} from '@/components/ui/sonner'
|
||||||
import Effects from '@/app/effects'
|
import Effects from '@/app/effects'
|
||||||
import {ProfileStoreProvider} from '@/components/stores/profile'
|
import {ProfileStoreProvider} from '@/components/stores/profile'
|
||||||
import {LayoutStoreProvider} from '@/components/stores/layout'
|
import {LayoutStoreProvider} from '@/components/stores/layout'
|
||||||
import {ClientStoreProvider} from '@/components/stores/client'
|
import {ClientStoreProvider} from '@/components/stores/client'
|
||||||
import {getProfile} from '@/actions/auth'
|
import {getProfile} from '@/actions/auth'
|
||||||
import Script from 'next/script'
|
|
||||||
import {AppStoreProvider} from '@/components/stores/app'
|
import {AppStoreProvider} from '@/components/stores/app'
|
||||||
import {getApiUrl} from '@/actions/base'
|
import {getApiUrl} from '@/actions/base'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
|
import {JsonLd} from '@/components/seo/json-ld'
|
||||||
|
|
||||||
|
export const viewport: Viewport = {
|
||||||
|
width: 'device-width',
|
||||||
|
initialScale: 1,
|
||||||
|
themeColor: '#3b82f6',
|
||||||
|
}
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
return {
|
return {
|
||||||
title: '蓝狐代理',
|
metadataBase: new URL(siteConfig.url),
|
||||||
|
title: {
|
||||||
|
default: siteConfig.name,
|
||||||
|
template: `%s`,
|
||||||
|
},
|
||||||
|
description: siteConfig.description,
|
||||||
|
keywords: siteConfig.keywords,
|
||||||
|
robots: {
|
||||||
|
index: true,
|
||||||
|
follow: true,
|
||||||
|
googleBot: {
|
||||||
|
'index': true,
|
||||||
|
'follow': true,
|
||||||
|
'max-video-preview': -1,
|
||||||
|
'max-image-preview': 'large',
|
||||||
|
'max-snippet': -1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
openGraph: {
|
||||||
|
type: 'website',
|
||||||
|
locale: siteConfig.locale,
|
||||||
|
url: siteConfig.url,
|
||||||
|
siteName: siteConfig.name,
|
||||||
|
title: siteConfig.name,
|
||||||
|
description: siteConfig.description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: siteConfig.ogImage.url,
|
||||||
|
width: siteConfig.ogImage.width,
|
||||||
|
height: siteConfig.ogImage.height,
|
||||||
|
alt: siteConfig.name,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
twitter: {
|
||||||
|
card: 'summary_large_image',
|
||||||
|
title: siteConfig.name,
|
||||||
|
description: siteConfig.description,
|
||||||
|
images: [siteConfig.ogImage.url],
|
||||||
|
},
|
||||||
|
alternates: {
|
||||||
|
canonical: siteConfig.url,
|
||||||
|
},
|
||||||
|
icons: {
|
||||||
|
icon: '/favicon.ico',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +79,16 @@ export default async function RootLayout(props: Readonly<{
|
|||||||
<Effects>{props.children}</Effects>
|
<Effects>{props.children}</Effects>
|
||||||
</StoreProviders>
|
</StoreProviders>
|
||||||
<Toaster position="top-center" richColors expand/>
|
<Toaster position="top-center" richColors expand/>
|
||||||
|
<JsonLd
|
||||||
|
schema={{
|
||||||
|
'@context': 'https://schema.org',
|
||||||
|
'@type': 'Organization',
|
||||||
|
'@id': `${siteConfig.url}/#organization`,
|
||||||
|
'name': siteConfig.name,
|
||||||
|
'url': siteConfig.url,
|
||||||
|
'description': siteConfig.description,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
|
|||||||
21
src/app/manifest.ts
Normal file
21
src/app/manifest.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import {MetadataRoute} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
|
|
||||||
|
export default function manifest(): MetadataRoute.Manifest {
|
||||||
|
return {
|
||||||
|
name: siteConfig.name,
|
||||||
|
short_name: siteConfig.shortName,
|
||||||
|
description: siteConfig.description,
|
||||||
|
start_url: '/',
|
||||||
|
display: 'standalone',
|
||||||
|
background_color: '#ffffff',
|
||||||
|
theme_color: '#3b82f6',
|
||||||
|
icons: [
|
||||||
|
{
|
||||||
|
src: '/favicon.ico',
|
||||||
|
sizes: '48x48',
|
||||||
|
type: 'image/x-icon',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/app/robots.ts
Normal file
18
src/app/robots.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import {MetadataRoute} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
|
|
||||||
|
export default function robots(): MetadataRoute.Robots {
|
||||||
|
return {
|
||||||
|
rules: {
|
||||||
|
userAgent: '*',
|
||||||
|
allow: '/',
|
||||||
|
disallow: [
|
||||||
|
'/api/',
|
||||||
|
'/admin/',
|
||||||
|
'/profile/',
|
||||||
|
'/settings/',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
sitemap: `${siteConfig.url}/sitemap.xml`,
|
||||||
|
}
|
||||||
|
}
|
||||||
178
src/app/sitemap.ts
Normal file
178
src/app/sitemap.ts
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import {MetadataRoute} from 'next'
|
||||||
|
import {siteConfig} from '@/config/site'
|
||||||
|
|
||||||
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||||
|
const baseUrl = siteConfig.url
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
url: baseUrl,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'daily',
|
||||||
|
priority: 1.0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/product`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.9,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/collect`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.8,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/custom`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/data-capture`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/e-commerce`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/market-research`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/seo-optimization`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/social-media`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/advertising`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/account-management`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/network-testing`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'weekly',
|
||||||
|
priority: 0.6,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/product/city-lines`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/faqs/faq-general`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/faqs/faq-billing`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/client/android-proxy`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/client/browser-proxy`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/client/ios-proxy`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/client/windows10-proxy`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/news/news-announce`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/news/news-latest`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/operation/extract-link`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/operation/payment-records`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/operation/profile-settings`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/operation/verify-guide`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/docs/operation/whitelist-guide`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `${baseUrl}/login`,
|
||||||
|
lastModified: now,
|
||||||
|
changeFrequency: 'monthly',
|
||||||
|
priority: 0.3,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -11,27 +11,27 @@ import {Alert, AlertTitle} from '@/components/ui/alert'
|
|||||||
import {ArrowRight, Box, CircleAlert, CopyIcon, ExternalLinkIcon, LinkIcon, Loader, Plus, Timer} from 'lucide-react'
|
import {ArrowRight, Box, CircleAlert, CopyIcon, ExternalLinkIcon, LinkIcon, Loader, Plus, Timer} from 'lucide-react'
|
||||||
import {memo, ReactNode, Suspense, use, useEffect, useRef, useState} from 'react'
|
import {memo, ReactNode, Suspense, use, useEffect, useRef, useState} from 'react'
|
||||||
import {useStatus} from '@/lib/states'
|
import {useStatus} from '@/lib/states'
|
||||||
import {allResource} from '@/actions/resource'
|
import {allResource, getAreaList} from '@/actions/resource'
|
||||||
import {Resource} from '@/lib/models'
|
import {Resource} from '@/lib/models'
|
||||||
import {format, intlFormatDistance} from 'date-fns'
|
import {format, intlFormatDistance} from 'date-fns'
|
||||||
import {toast} from 'sonner'
|
import {toast} from 'sonner'
|
||||||
import {merge} from '@/lib/utils'
|
import {merge} from '@/lib/utils'
|
||||||
import {Combobox} from '@/components/ui/combobox'
|
import {Combobox} from '@/components/ui/combobox'
|
||||||
import cities from './_assets/cities.json'
|
|
||||||
import ExtractDocs from '@/app/(home)/docs/(product)/api-docs/page.md'
|
import ExtractDocs from '@/app/(home)/docs/(product)/api-docs/page.md'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import {useProfileStore} from '@/components/stores/profile'
|
import {useProfileStore} from '@/components/stores/profile'
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
resource: z.number({required_error: '请选择套餐'}),
|
resource: z.string({required_error: '请选择套餐'}),
|
||||||
prov: z.string().optional(),
|
prov: z.string().optional(),
|
||||||
city: z.string().optional(),
|
city: z.string().optional(),
|
||||||
regionType: z.enum(['unlimited', 'specific']).default('unlimited'),
|
regionType: z.enum(['unlimited', 'specific']).default('unlimited'),
|
||||||
isp: z.enum(['all', '1', '2', '3'], {required_error: '请选择运营商'}),
|
isp: z.enum(['all', '1', '2', '3'], {required_error: '请选择运营商'}),
|
||||||
proto: z.enum(['all', '1', '2', '3'], {required_error: '请选择协议'}),
|
proto: z.enum(['all', '1', '2'], {required_error: '请选择协议'}),
|
||||||
authType: z.enum(['1', '2'], {required_error: '请选择认证方式'}),
|
authType: z.enum(['1', '2'], {required_error: '请选择认证方式'}),
|
||||||
distinct: z.enum(['1', '0'], {required_error: '请选择去重选项'}),
|
distinct: z.enum(['1', '0'], {required_error: '请选择去重选项'}),
|
||||||
format: z.enum(['text', 'json'], {required_error: '请选择导出格式'}),
|
format: z.enum(['text', 'json'], {required_error: '请选择导出格式'}),
|
||||||
|
hostFormat: z.enum(['domain', 'ip'], {required_error: '请选择主机格式'}),
|
||||||
separator: z.string({required_error: '请选择分隔符'}),
|
separator: z.string({required_error: '请选择分隔符'}),
|
||||||
breaker: z.string({required_error: '请选择换行符'}),
|
breaker: z.string({required_error: '请选择换行符'}),
|
||||||
count: z.number({required_error: '请输入有效的数量'}).min(1),
|
count: z.number({required_error: '请输入有效的数量'}).min(1),
|
||||||
@@ -53,6 +53,7 @@ export default function Extract(props: ExtractProps) {
|
|||||||
authType: '1',
|
authType: '1',
|
||||||
count: 1,
|
count: 1,
|
||||||
distinct: '1',
|
distinct: '1',
|
||||||
|
hostFormat: 'domain',
|
||||||
format: 'text',
|
format: 'text',
|
||||||
breaker: '13,10',
|
breaker: '13,10',
|
||||||
separator: '124',
|
separator: '124',
|
||||||
@@ -71,20 +72,6 @@ export default function Extract(props: ExtractProps) {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CardSection>
|
<CardSection>
|
||||||
<Alert variant="warn" className="flex items-center justify-between">
|
|
||||||
<span className="flex items-center gap-2">
|
|
||||||
<CircleAlert/>
|
|
||||||
<AlertTitle className="flex text-gray-900">提取IP前需要将本机IP添加到白名单后才可使用</AlertTitle>
|
|
||||||
</span>
|
|
||||||
<Link
|
|
||||||
href="/admin/whitelist"
|
|
||||||
className="flex-none text-orange-600 font-medium ml-2 flex gap-0.5 items-center"
|
|
||||||
>
|
|
||||||
<span>添加白名单</span>
|
|
||||||
<ArrowRight className="size-4"/>
|
|
||||||
</Link>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<FormFields/>
|
<FormFields/>
|
||||||
</CardSection>
|
</CardSection>
|
||||||
|
|
||||||
@@ -163,12 +150,12 @@ const FormFields = memo(() => {
|
|||||||
<RadioGroupItem value="1" id={`${id}-v-http`} className="mr-2"/>
|
<RadioGroupItem value="1" id={`${id}-v-http`} className="mr-2"/>
|
||||||
<span>HTTP</span>
|
<span>HTTP</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormLabel htmlFor={`${id}-v-https`} className="px-3 h-10 border rounded-md flex items-center text-sm">
|
{/* <FormLabel htmlFor={`${id}-v-https`} className="px-3 h-10 border rounded-md flex items-center text-sm">
|
||||||
<RadioGroupItem value="2" id={`${id}-v-https`} className="mr-2"/>
|
<RadioGroupItem value="2" id={`${id}-v-https`} className="mr-2"/>
|
||||||
<span>HTTPS</span>
|
<span>HTTPS</span>
|
||||||
</FormLabel>
|
</FormLabel> */}
|
||||||
<FormLabel htmlFor={`${id}-v-socks5`} className="px-3 h-10 border rounded-md flex items-center text-sm">
|
<FormLabel htmlFor={`${id}-v-socks5`} className="px-3 h-10 border rounded-md flex items-center text-sm">
|
||||||
<RadioGroupItem value="3" id={`${id}-v-socks5`} className="mr-2"/>
|
<RadioGroupItem value="2" id={`${id}-v-socks5`} className="mr-2"/>
|
||||||
<span>SOCKS5</span>
|
<span>SOCKS5</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
@@ -233,6 +220,26 @@ const FormFields = memo(() => {
|
|||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
{/* 主机格式 */}
|
||||||
|
<FormField name="hostFormat" className="md:max-w-[calc(160px*2+1rem)]" label="主机格式" classNames={{label: 'max-md:text-sm'}}>
|
||||||
|
{({id, field}) => (
|
||||||
|
<RadioGroup
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
defaultValue={field.value}
|
||||||
|
className="flex gap-4"
|
||||||
|
>
|
||||||
|
<FormLabel htmlFor={`${id}-v-domain`} className="px-3 h-10 flex-1 border rounded-md flex items-center text-sm">
|
||||||
|
<RadioGroupItem value="domain" id={`${id}-v-domain`} className="mr-2"/>
|
||||||
|
<span>域名</span>
|
||||||
|
</FormLabel>
|
||||||
|
<FormLabel htmlFor={`${id}-v-ip`} className="px-3 h-10 flex-1 border rounded-md flex items-center text-sm">
|
||||||
|
<RadioGroupItem value="ip" id={`${id}-v-ip`} className="mr-2"/>
|
||||||
|
<span>IP</span>
|
||||||
|
</FormLabel>
|
||||||
|
</RadioGroup>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
{/* 分隔符 */}
|
{/* 分隔符 */}
|
||||||
<FormField name="separator" className="md:max-w-[calc(160px*3+1rem*2)]" label="分隔符" classNames={{label: 'max-md:text-sm'}}>
|
<FormField name="separator" className="md:max-w-[calc(160px*3+1rem*2)]" label="分隔符" classNames={{label: 'max-md:text-sm'}}>
|
||||||
{({id, field}) => (
|
{({id, field}) => (
|
||||||
@@ -366,7 +373,7 @@ function SelectResource() {
|
|||||||
{({field}) => (
|
{({field}) => (
|
||||||
<Select
|
<Select
|
||||||
value={field.value ? String(field.value) : undefined}
|
value={field.value ? String(field.value) : undefined}
|
||||||
onValueChange={value => field.onChange(Number(value))}
|
onValueChange={value => field.onChange(value)}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="min-h-10 h-auto w-full">
|
<SelectTrigger className="min-h-10 h-auto w-full">
|
||||||
<SelectValue placeholder="选择套餐"/>
|
<SelectValue placeholder="选择套餐"/>
|
||||||
@@ -379,12 +386,10 @@ function SelectResource() {
|
|||||||
</div>
|
</div>
|
||||||
) : !profile ? (
|
) : !profile ? (
|
||||||
<div className="p-4 flex gap-1 items-center">
|
<div className="p-4 flex gap-1 items-center">
|
||||||
{/* <Loader className="animate-spin" size={20}/> */}
|
|
||||||
<span className="text-gray-600">请先登录账号,<Link href="/login" className="text-blue-600 hover:text-blue-700 font-medium">去登录</Link></span>
|
<span className="text-gray-600">请先登录账号,<Link href="/login" className="text-blue-600 hover:text-blue-700 font-medium">去登录</Link></span>
|
||||||
</div>
|
</div>
|
||||||
) : resources.length === 0 ? (
|
) : resources.length === 0 ? (
|
||||||
<div className="p-4 flex gap-1 items-center">
|
<div className="p-4 flex gap-1 items-center">
|
||||||
<Loader className="animate-spin" size={20}/>
|
|
||||||
<span>暂无可用套餐</span>
|
<span>暂无可用套餐</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -392,7 +397,7 @@ function SelectResource() {
|
|||||||
{resources.map(resource => (
|
{resources.map(resource => (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={resource.id}
|
key={resource.id}
|
||||||
value={String(resource.id)}
|
value={String(resource.resource_no)}
|
||||||
className="p-3">
|
className="p-3">
|
||||||
<div className="flex flex-col gap-2 w-72">
|
<div className="flex flex-col gap-2 w-72">
|
||||||
{resource.type === 1 && resource.short.type === 1 && (
|
{resource.type === 1 && resource.short.type === 1 && (
|
||||||
@@ -407,7 +412,7 @@ function SelectResource() {
|
|||||||
<div className="flex justify-between gap-2 text-xs text-weak">
|
<div className="flex justify-between gap-2 text-xs text-weak">
|
||||||
<span>
|
<span>
|
||||||
到期时间:
|
到期时间:
|
||||||
{format(resource.short.expire_at, 'yyyy-MM-dd HH:mm')}
|
{format(resource.short.expire_at, 'yyyy-MM-dd HH:mm:ss')}
|
||||||
</span>
|
</span>
|
||||||
<span>{intlFormatDistance(resource.short.expire_at, new Date())}</span>
|
<span>{intlFormatDistance(resource.short.expire_at, new Date())}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -449,7 +454,7 @@ function SelectResource() {
|
|||||||
<div className="flex justify-between gap-2 text-xs text-weak">
|
<div className="flex justify-between gap-2 text-xs text-weak">
|
||||||
<span>
|
<span>
|
||||||
到期时间:
|
到期时间:
|
||||||
{format(resource.long.expire_at, 'yyyy-MM-dd HH:mm')}
|
{format(resource.long.expire_at, 'yyyy-MM-dd HH:mm:ss')}
|
||||||
</span>
|
</span>
|
||||||
<span>{intlFormatDistance(resource.long.expire_at, new Date())}</span>
|
<span>{intlFormatDistance(resource.long.expire_at, new Date())}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -491,11 +496,62 @@ function SelectResource() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AreaItem = {
|
||||||
|
id: number
|
||||||
|
parent_id: number
|
||||||
|
level: number
|
||||||
|
name: string
|
||||||
|
created_at: string
|
||||||
|
updated_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function AreaTree(flatList: AreaItem[]) {
|
||||||
|
const provinces = flatList.filter(item => item.level === 1)
|
||||||
|
const cities = flatList.filter(item => item.level === 2)
|
||||||
|
|
||||||
|
return provinces.map(prov => ({
|
||||||
|
value: String(prov.id),
|
||||||
|
label: prov.name,
|
||||||
|
children: cities
|
||||||
|
.filter(city => city.parent_id === prov.id)
|
||||||
|
.map(city => ({
|
||||||
|
value: String(city.id),
|
||||||
|
label: city.name,
|
||||||
|
})),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
function SelectRegion() {
|
function SelectRegion() {
|
||||||
const {control, setValue} = useFormContext<Schema>()
|
const {control, setValue} = useFormContext<Schema>()
|
||||||
const regionType = useWatch({control, name: 'regionType'})
|
const regionType = useWatch({control, name: 'regionType'})
|
||||||
const prov = useWatch({control, name: 'prov'})
|
const prov = useWatch({control, name: 'prov'})
|
||||||
const city = useWatch({control, name: 'city'})
|
const city = useWatch({control, name: 'city'})
|
||||||
|
const [options, setOptions] = useState<ReturnType<typeof AreaTree>>([])
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (regionType === 'specific') {
|
||||||
|
const fetchData = async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const req = await getAreaList({})
|
||||||
|
console.log(req, 'req')
|
||||||
|
|
||||||
|
if (req.success && req.data) {
|
||||||
|
setOptions(AreaTree(req.data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
toast.error('无法选择区域')
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchData()
|
||||||
|
}
|
||||||
|
}, [regionType])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4 md:max-w-[calc(160px*2+1rem)]">
|
<div className="flex flex-col gap-4 md:max-w-[calc(160px*2+1rem)]">
|
||||||
@@ -525,15 +581,22 @@ function SelectRegion() {
|
|||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
{regionType === 'specific' && (
|
{regionType === 'specific' && (
|
||||||
|
loading ? (
|
||||||
|
<div className="flex gap-2 items-center">
|
||||||
|
<Loader className="animate-spin" size={16}/>
|
||||||
|
<span className="text-sm text-weak">加载地区数据中...</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Combobox
|
<Combobox
|
||||||
placeholder="请选择地区"
|
placeholder="请选择地区"
|
||||||
options={cities.options}
|
options={options}
|
||||||
value={[prov || '', city || '']}
|
value={[prov || '', city || '']}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setValue('prov', value[0])
|
setValue('prov', value[0] || '')
|
||||||
setValue('city', value[1])
|
setValue('city', value[1] || '')
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -606,25 +669,40 @@ function ApplyLink() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={merge(
|
<div className="flex flex-col gap-3 rounded-lg">
|
||||||
`flex flex-col gap-4`,
|
<Alert variant="warn" className="flex items-center justify-between">
|
||||||
`rounded-lg`,
|
<div className="flex items-center gap-2">
|
||||||
)}>
|
<CircleAlert className="size-4 shrink-0"/>
|
||||||
<h4>API 链接</h4>
|
<AlertTitle className="text-orange-600">
|
||||||
|
提取 IP 前需要将本机 IP 添加到白名单后才可使用
|
||||||
|
</AlertTitle>
|
||||||
|
</div>
|
||||||
|
<Link href="/admin/whitelist" className="flex-none text-orange-600 font-medium flex items-center gap-1">
|
||||||
|
<span>添加白名单</span>
|
||||||
|
<ArrowRight className="size-4"/>
|
||||||
|
</Link>
|
||||||
|
</Alert>
|
||||||
|
|
||||||
{/* 展示链接地址 */}
|
<Alert className="flex items-center justify-between">
|
||||||
<div className="bg-secondary p-4 rounded-md break-all">
|
<div className="flex items-center gap-2">
|
||||||
|
<CircleAlert className="size-4 shrink-0"/>
|
||||||
|
<AlertTitle>端口同时支持 socks5 和 http 协议</AlertTitle>
|
||||||
|
</div>
|
||||||
|
<div className="w-[88px]"/>
|
||||||
|
</Alert>
|
||||||
|
<h4 className="text-base font-medium">API 链接</h4>
|
||||||
|
|
||||||
|
<div className="bg-gray-100 rounded-md p-4 break-all font-mono text-sm">
|
||||||
{link(form.getValues())}
|
{link(form.getValues())}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 操作 */}
|
<div className="flex gap-3">
|
||||||
<div className="flex gap-4">
|
<Button type="button" onClick={() => submit('copy')} className="gap-1">
|
||||||
<Button type="button" onClick={() => submit('copy')}>
|
<CopyIcon className="size-4"/>
|
||||||
<CopyIcon/>
|
|
||||||
<span>复制链接</span>
|
<span>复制链接</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="button" onClick={() => submit('open')}>
|
<Button type="button" onClick={() => submit('open')} className="gap-1">
|
||||||
<ExternalLinkIcon/>
|
<ExternalLinkIcon className="size-4"/>
|
||||||
<span>打开链接</span>
|
<span>打开链接</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -633,18 +711,20 @@ function ApplyLink() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function link(values: Schema) {
|
function link(values: Schema) {
|
||||||
const {resource, prov, city, isp, proto, authType, distinct, format: formatType, separator, breaker, count} = values
|
const {resource, prov, city, isp, proto, authType, distinct, format: formatType, hostFormat, separator, breaker, count} = values
|
||||||
|
console.log(values, 'values')
|
||||||
|
|
||||||
const sp = new URLSearchParams()
|
const sp = new URLSearchParams()
|
||||||
if (resource) sp.set('i', String(resource))
|
if (resource) sp.set('i', String(resource))
|
||||||
if (authType) sp.set('t', authType)
|
if (authType) sp.set('t', authType)
|
||||||
if (proto != 'all') sp.set('x', proto)
|
if (proto != 'all') sp.set('x', proto)
|
||||||
if (prov) sp.set('a', prov)
|
if (prov) sp.set('b', prov)
|
||||||
if (city) sp.set('b', city)
|
if (city) sp.set('b', city)
|
||||||
|
|
||||||
if (isp != 'all') sp.set('s', isp)
|
if (isp != 'all') sp.set('s', isp)
|
||||||
sp.set('d', distinct)
|
sp.set('d', distinct)
|
||||||
sp.set('rt', formatType)
|
sp.set('rt', formatType)
|
||||||
|
sp.set('rh', hostFormat)
|
||||||
sp.set('rs', separator)
|
sp.set('rs', separator)
|
||||||
sp.set('rb', breaker)
|
sp.set('rb', breaker)
|
||||||
sp.set('n', String(count))
|
sp.set('n', String(count))
|
||||||
@@ -658,9 +738,9 @@ function name(resource: Resource) {
|
|||||||
// 短效套餐
|
// 短效套餐
|
||||||
switch (resource.short.type) {
|
switch (resource.short.type) {
|
||||||
case 1:
|
case 1:
|
||||||
return `短效包时 ${resource.short.live} 分钟`
|
return `${resource.short?.sku?.name}`
|
||||||
case 2:
|
case 2:
|
||||||
return `短效包量 ${resource.short.live} 分钟`
|
return `${resource.short?.sku?.name}`
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -668,9 +748,9 @@ function name(resource: Resource) {
|
|||||||
// 长效套餐
|
// 长效套餐
|
||||||
switch (resource.long.type) {
|
switch (resource.long.type) {
|
||||||
case 1:
|
case 1:
|
||||||
return `长效包时 ${resource.long.live} 小时`
|
return `${resource.long?.sku?.name}`
|
||||||
case 2:
|
case 2:
|
||||||
return `长效包量 ${resource.long.live} 小时`
|
return `${resource.long?.sku?.name}`
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default function Purchase() {
|
|||||||
const res = profile
|
const res = profile
|
||||||
? await listProduct({})
|
? await listProduct({})
|
||||||
: await listProductHome({})
|
: await listProductHome({})
|
||||||
console.log(res, 'res')
|
|
||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setProductList(res.data)
|
setProductList(res.data)
|
||||||
|
|||||||
@@ -29,36 +29,32 @@ export default function Center({skuData}: {
|
|||||||
const currentCountMin = useMemo(() => {
|
const currentCountMin = useMemo(() => {
|
||||||
if (!type || !live) return 0
|
if (!type || !live) return 0
|
||||||
const expireValue = type === '1' ? expire : '0'
|
const expireValue = type === '1' ? expire : '0'
|
||||||
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
const countMin = getPurchaseSkuCountMin(skuData, {
|
||||||
|
mode: type,
|
||||||
|
live,
|
||||||
|
expire: expireValue,
|
||||||
|
})
|
||||||
|
return countMin
|
||||||
}, [type, live, expire, skuData])
|
}, [type, live, expire, skuData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type === '1') {
|
if (currentCountMin <= 0) return
|
||||||
const current = getValues('daily_limit')
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
if (current < currentCountMin) {
|
const currentValue = getValues(targetField)
|
||||||
setValue('daily_limit', currentCountMin)
|
if (currentValue !== currentCountMin) {
|
||||||
}
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
}
|
|
||||||
else {
|
|
||||||
const current = getValues('quota')
|
|
||||||
if (current < currentCountMin) {
|
|
||||||
setValue('quota', currentCountMin)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const nextType = modeList.includes(type) ? type : modeList[0]
|
const nextType = modeList.includes(type) ? type : modeList[0]
|
||||||
|
|
||||||
if (!nextType) {
|
if (!nextType) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextType !== type) {
|
if (nextType !== type) {
|
||||||
setValue('type', nextType)
|
setValue('type', nextType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextLiveList = nextType === '1'
|
const nextLiveList = nextType === '1'
|
||||||
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
||||||
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
||||||
@@ -83,14 +79,45 @@ export default function Center({skuData}: {
|
|||||||
}, [expire, live, modeList, setValue, skuData, type])
|
}, [expire, live, modeList, setValue, skuData, type])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex-auto p-6 flex flex-col gap-6 relative">
|
<Card className="flex-auto p-6 flex flex-col gap-10 relative">
|
||||||
|
<div className="text-center -mb-10">支持 HTTP、socks5 双协议代理</div>
|
||||||
<BillingMethodField modeList={modeList} timeDailyLimit={100}/>
|
<BillingMethodField modeList={modeList} timeDailyLimit={100}/>
|
||||||
|
{/* 套餐时效 */}
|
||||||
|
{type === '1' && (
|
||||||
|
<FormField name="expire" label="套餐有效时间" description="有效时间内可用于提取 IP">
|
||||||
|
{({id, field}) => (
|
||||||
|
<RadioGroup
|
||||||
|
id={id}
|
||||||
|
value={field.value}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
field.onChange(value)
|
||||||
|
|
||||||
|
const nextLiveList = getAvailablePurchaseLives(skuData, {mode: type, expire: value})
|
||||||
|
if (!nextLiveList.includes(live) && nextLiveList[0]) {
|
||||||
|
setValue('live', nextLiveList[0])
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex gap-4 flex-wrap">
|
||||||
|
{expireList.map(day => (
|
||||||
|
<FormOption
|
||||||
|
key={day}
|
||||||
|
id={`${id}-${day}`}
|
||||||
|
value={day}
|
||||||
|
label={`${day} 天`}
|
||||||
|
compare={field.value}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* IP 时效 */}
|
{/* IP 时效 */}
|
||||||
<FormField<Schema, 'live'>
|
<FormField<Schema, 'live'>
|
||||||
className="space-y-4"
|
|
||||||
name="live"
|
name="live"
|
||||||
label="IP 时效">
|
label="IP 有效时间"
|
||||||
|
description="提取出的 IP 可用时间"
|
||||||
|
>
|
||||||
{({id, field}) => (
|
{({id, field}) => (
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
id={id}
|
id={id}
|
||||||
@@ -132,49 +159,21 @@ export default function Center({skuData}: {
|
|||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
{/* 套餐时效 */}
|
|
||||||
{type === '1' && (
|
|
||||||
<FormField className="space-y-4" name="expire" label="套餐时效">
|
|
||||||
{({id, field}) => (
|
|
||||||
<RadioGroup
|
|
||||||
id={id}
|
|
||||||
value={field.value}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
field.onChange(value)
|
|
||||||
|
|
||||||
const nextLiveList = getAvailablePurchaseLives(skuData, {mode: type, expire: value})
|
|
||||||
if (!nextLiveList.includes(live) && nextLiveList[0]) {
|
|
||||||
setValue('live', nextLiveList[0])
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="flex gap-4 flex-wrap">
|
|
||||||
{expireList.map(day => (
|
|
||||||
<FormOption
|
|
||||||
key={day}
|
|
||||||
id={`${id}-${day}`}
|
|
||||||
value={day}
|
|
||||||
label={`${day} 天`}
|
|
||||||
compare={field.value}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</RadioGroup>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 每日提取上限/购买数量 */}
|
{/* 每日提取上限/购买数量 */}
|
||||||
{type === '1' ? (
|
{type === '1' ? (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="daily_limit"
|
name="daily_limit"
|
||||||
label="每日提取上限"
|
label="IP 每日提取上限"
|
||||||
min={currentCountMin || 100}
|
description="本套餐每日可提取 IP 的最大数量"
|
||||||
|
min={currentCountMin}
|
||||||
step={100}
|
step={100}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="quota"
|
name="quota"
|
||||||
label="IP 购买数量"
|
label="IP 总提取上限"
|
||||||
min={currentCountMin || 500}
|
description="本套餐总计可提取 IP 的最大数量"
|
||||||
|
min={currentCountMin}
|
||||||
step={100}
|
step={100}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ import {PurchaseSidePanel} from '../shared/side-panel'
|
|||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
type: z.enum(['1', '2']).default('2'),
|
type: z.enum(['1', '2']).default('2'),
|
||||||
live: z.string(),
|
live: z.string(),
|
||||||
quota: z.number().min(500, '购买数量不能少于 500 个'),
|
quota: z.number().min(1, '购买数量不能少于 1 个'),
|
||||||
expire: z.string(),
|
expire: z.string(),
|
||||||
daily_limit: z.number().min(100, '每日限额不能少于 100 个'),
|
daily_limit: z.number().min(1, '每日限额不能少于 1 个'),
|
||||||
pay_type: z.enum(['wechat', 'alipay', 'balance']),
|
pay_type: z.enum(['wechat', 'alipay', 'balance']),
|
||||||
})
|
})
|
||||||
export type Schema = z.infer<typeof schema>
|
export type Schema = z.infer<typeof schema>
|
||||||
|
|
||||||
export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||||
const skuData = parsePurchaseSkuList('long', skuList)
|
const skuData = parsePurchaseSkuList('long', skuList)
|
||||||
const defaultMode = skuData.modeList.includes('2') ? '2' : '1'
|
const defaultMode = skuData.modeList.includes('1') ? '1' : '2'
|
||||||
const defaultLive = getAvailablePurchaseLives(skuData, {mode: defaultMode})[0] || ''
|
const defaultLive = getAvailablePurchaseLives(skuData, {mode: defaultMode})[0] || ''
|
||||||
const defaultExpire = defaultMode === '1'
|
const defaultExpire = defaultMode === '1'
|
||||||
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
||||||
@@ -37,8 +37,8 @@ export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
|||||||
type: defaultMode,
|
type: defaultMode,
|
||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
quota: defaultMode === '2' ? Math.max(defaultCountMin, 500) : 500,
|
quota: defaultCountMin,
|
||||||
daily_limit: defaultMode === '1' ? Math.max(defaultCountMin, 100) : 100,
|
daily_limit: defaultCountMin,
|
||||||
pay_type: 'balance', // 余额支付
|
pay_type: 'balance', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function BillingMethodField(props: {
|
|||||||
modeList: PurchaseMode[]
|
modeList: PurchaseMode[]
|
||||||
timeDailyLimit: number
|
timeDailyLimit: number
|
||||||
}) {
|
}) {
|
||||||
const {setValue} = useFormContext<PurchaseFormValues>()
|
const {setValue, getValues} = useFormContext<PurchaseFormValues>()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormField<PurchaseFormValues, 'type'>
|
<FormField<PurchaseFormValues, 'type'>
|
||||||
@@ -30,20 +30,10 @@ export function BillingMethodField(props: {
|
|||||||
setValue('expire', '0')
|
setValue('expire', '0')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setValue('expire', getValues('expire') || '0')
|
||||||
setValue('daily_limit', props.timeDailyLimit)
|
|
||||||
}}
|
}}
|
||||||
className="flex gap-4 max-md:flex-col"
|
className="flex gap-4 max-md:flex-col"
|
||||||
>
|
>
|
||||||
{props.modeList.includes('2') && (
|
|
||||||
<FormOption
|
|
||||||
id={`${id}-2`}
|
|
||||||
value="2"
|
|
||||||
label="包量套餐"
|
|
||||||
description="适用于短期或不定期高提取业务场景"
|
|
||||||
compare={field.value}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{props.modeList.includes('1') && (
|
{props.modeList.includes('1') && (
|
||||||
<FormOption
|
<FormOption
|
||||||
@@ -54,6 +44,15 @@ export function BillingMethodField(props: {
|
|||||||
compare={field.value}
|
compare={field.value}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{props.modeList.includes('2') && (
|
||||||
|
<FormOption
|
||||||
|
id={`${id}-2`}
|
||||||
|
value="2"
|
||||||
|
label="包量套餐"
|
||||||
|
description="适用于短期或不定期高提取业务场景"
|
||||||
|
compare={field.value}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type PurchaseStepperFieldName = 'quota' | 'daily_limit'
|
|||||||
type NumberStepperFieldProps = {
|
type NumberStepperFieldProps = {
|
||||||
name: PurchaseStepperFieldName
|
name: PurchaseStepperFieldName
|
||||||
label: string
|
label: string
|
||||||
|
description?: string
|
||||||
min: number
|
min: number
|
||||||
step: number
|
step: number
|
||||||
}
|
}
|
||||||
@@ -25,7 +26,7 @@ export function NumberStepperField(props: NumberStepperFieldProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FormField<PurchaseFormValues, PurchaseStepperFieldName>
|
<FormField<PurchaseFormValues, PurchaseStepperFieldName>
|
||||||
className="space-y-4"
|
description={props.description}
|
||||||
name={props.name}
|
name={props.name}
|
||||||
label={props.label}
|
label={props.label}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {formatPurchaseLiveLabel} from './sku'
|
|||||||
import {User} from '@/lib/models'
|
import {User} from '@/lib/models'
|
||||||
import {PurchaseFormValues} from './form-values'
|
import {PurchaseFormValues} from './form-values'
|
||||||
import {IdCard} from 'lucide-react'
|
import {IdCard} from 'lucide-react'
|
||||||
|
import {Loader2} from 'lucide-react'
|
||||||
|
|
||||||
const emptyPrice: ExtraResp<typeof getPrice> = {
|
const emptyPrice: ExtraResp<typeof getPrice> = {
|
||||||
price: '0.00',
|
price: '0.00',
|
||||||
@@ -43,7 +44,7 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
expire,
|
expire,
|
||||||
dailyLimit,
|
dailyLimit,
|
||||||
}
|
}
|
||||||
const priceData = usePurchasePrice(profile, selection)
|
const {priceData, isLoading, isError} = usePurchasePrice(profile, selection)
|
||||||
const {price, actual: discountedPrice = '0.00'} = priceData
|
const {price, actual: discountedPrice = '0.00'} = priceData
|
||||||
const totalDiscount = getTotalDiscount(price, discountedPrice)
|
const totalDiscount = getTotalDiscount(price, discountedPrice)
|
||||||
const hasDiscount = Number(totalDiscount) > 0
|
const hasDiscount = Number(totalDiscount) > 0
|
||||||
@@ -70,9 +71,13 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between items-center">
|
<li className="flex justify-between items-center">
|
||||||
<span className="text-sm text-gray-500">原价</span>
|
<span className="text-sm text-gray-500">原价</span>
|
||||||
|
{ isError ? (
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin text-gray-400"/>
|
||||||
|
) : (
|
||||||
<span className="text-sm">¥{price}</span>
|
<span className="text-sm">¥{price}</span>
|
||||||
|
)}
|
||||||
</li>
|
</li>
|
||||||
{hasDiscount && (
|
{hasDiscount && !isError && (
|
||||||
<li className="flex justify-between items-center">
|
<li className="flex justify-between items-center">
|
||||||
<span className="text-sm text-gray-500">总折扣</span>
|
<span className="text-sm text-gray-500">总折扣</span>
|
||||||
<span className="text-sm">-¥{totalDiscount}</span>
|
<span className="text-sm">-¥{totalDiscount}</span>
|
||||||
@@ -91,9 +96,13 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between items-center">
|
<li className="flex justify-between items-center">
|
||||||
<span className="text-sm text-gray-500">原价</span>
|
<span className="text-sm text-gray-500">原价</span>
|
||||||
|
{ isError ? (
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin text-gray-400"/>
|
||||||
|
) : (
|
||||||
<span className="text-sm">¥{price}</span>
|
<span className="text-sm">¥{price}</span>
|
||||||
|
)}
|
||||||
</li>
|
</li>
|
||||||
{hasDiscount && (
|
{hasDiscount && !isError && (
|
||||||
<li className="flex justify-between items-center">
|
<li className="flex justify-between items-center">
|
||||||
<span className="text-sm text-gray-500">总折扣</span>
|
<span className="text-sm text-gray-500">总折扣</span>
|
||||||
<span className="text-sm">-¥{totalDiscount}</span>
|
<span className="text-sm">-¥{totalDiscount}</span>
|
||||||
@@ -105,7 +114,11 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
<div className="border-b border-gray-200"></div>
|
<div className="border-b border-gray-200"></div>
|
||||||
<p className="flex justify-between items-center">
|
<p className="flex justify-between items-center">
|
||||||
<span>实付价格</span>
|
<span>实付价格</span>
|
||||||
|
{ isError ? (
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin text-orange-500"/>
|
||||||
|
) : (
|
||||||
<span className="text-xl text-orange-500">¥{discountedPrice}</span>
|
<span className="text-xl text-orange-500">¥{discountedPrice}</span>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
{profile ? (
|
{profile ? (
|
||||||
profile.id_type !== 0 ? (
|
profile.id_type !== 0 ? (
|
||||||
@@ -134,7 +147,7 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<Link href="/login" className={buttonVariants()}>
|
<Link href="/login" className={buttonVariants()}>
|
||||||
登录后支付
|
去支付
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
@@ -143,6 +156,8 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
|||||||
|
|
||||||
function usePurchasePrice(profile: User | null, selection: PurchaseSelection) {
|
function usePurchasePrice(profile: User | null, selection: PurchaseSelection) {
|
||||||
const [priceData, setPriceData] = useState<ExtraResp<typeof getPrice>>(emptyPrice)
|
const [priceData, setPriceData] = useState<ExtraResp<typeof getPrice>>(emptyPrice)
|
||||||
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
|
const [isError, setIsError] = useState(false)
|
||||||
const requestIdRef = useRef(0)
|
const requestIdRef = useRef(0)
|
||||||
const {kind, mode, live, quota, expire, dailyLimit} = selection
|
const {kind, mode, live, quota, expire, dailyLimit} = selection
|
||||||
|
|
||||||
@@ -150,6 +165,9 @@ function usePurchasePrice(profile: User | null, selection: PurchaseSelection) {
|
|||||||
const requestId = ++requestIdRef.current
|
const requestId = ++requestIdRef.current
|
||||||
|
|
||||||
const loadPrice = async () => {
|
const loadPrice = async () => {
|
||||||
|
setIsLoading(true)
|
||||||
|
setIsError(false)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resource = buildPurchaseResource({
|
const resource = buildPurchaseResource({
|
||||||
kind,
|
kind,
|
||||||
@@ -167,15 +185,14 @@ function usePurchasePrice(profile: User | null, selection: PurchaseSelection) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.success) {
|
if (response.success) {
|
||||||
throw new Error(response.message || '获取价格失败')
|
|
||||||
}
|
|
||||||
|
|
||||||
setPriceData({
|
setPriceData({
|
||||||
price: response.data.price,
|
price: response.data.price,
|
||||||
actual: response.data.actual ?? response.data.price ?? '0.00',
|
actual: response.data.actual ?? response.data.price ?? '0.00',
|
||||||
discounted: response.data.discounted ?? '0.00',
|
discounted: response.data.discounted ?? '0.00',
|
||||||
})
|
})
|
||||||
|
setIsError(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (requestId !== requestIdRef.current) {
|
if (requestId !== requestIdRef.current) {
|
||||||
@@ -184,13 +201,19 @@ function usePurchasePrice(profile: User | null, selection: PurchaseSelection) {
|
|||||||
|
|
||||||
console.error('获取价格失败:', error)
|
console.error('获取价格失败:', error)
|
||||||
setPriceData(emptyPrice)
|
setPriceData(emptyPrice)
|
||||||
|
setIsError(true)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (requestId === requestIdRef.current) {
|
||||||
|
setIsLoading(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPrice()
|
loadPrice()
|
||||||
}, [dailyLimit, expire, kind, live, mode, profile, quota])
|
}, [dailyLimit, expire, kind, live, mode, profile, quota])
|
||||||
|
|
||||||
return priceData
|
return {priceData, isLoading, isError}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalDiscount(price: string, discountedPrice: string) {
|
function getTotalDiscount(price: string, discountedPrice: string) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export default function Center({
|
|||||||
}: {
|
}: {
|
||||||
skuData: PurchaseSkuData
|
skuData: PurchaseSkuData
|
||||||
}) {
|
}) {
|
||||||
// const {setValue} = useFormContext<Schema>()
|
|
||||||
const {setValue, getValues} = useFormContext<Schema>()
|
const {setValue, getValues} = useFormContext<Schema>()
|
||||||
const type = useWatch<Schema>({name: 'type'}) as Schema['type']
|
const type = useWatch<Schema>({name: 'type'}) as Schema['type']
|
||||||
const live = useWatch<Schema>({name: 'live'}) as Schema['live']
|
const live = useWatch<Schema>({name: 'live'}) as Schema['live']
|
||||||
@@ -34,18 +33,15 @@ export default function Center({
|
|||||||
const expireValue = type === '1' ? expire : '0'
|
const expireValue = type === '1' ? expire : '0'
|
||||||
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
||||||
}, [type, live, expire, skuData])
|
}, [type, live, expire, skuData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type === '1') {
|
if (currentCountMin <= 0) return
|
||||||
const current = getValues('daily_limit')
|
|
||||||
if (current < currentCountMin) {
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
setValue('daily_limit', currentCountMin)
|
const currentValue = getValues(targetField)
|
||||||
}
|
|
||||||
}
|
if (currentValue !== currentCountMin) {
|
||||||
else {
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
const current = getValues('quota')
|
|
||||||
if (current < currentCountMin) {
|
|
||||||
setValue('quota', currentCountMin)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -84,14 +80,45 @@ export default function Center({
|
|||||||
}, [expire, live, modeList, setValue, skuData, type])
|
}, [expire, live, modeList, setValue, skuData, type])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex-auto p-6 flex flex-col gap-6 relative">
|
<Card className="flex-auto p-6 flex flex-col gap-10 relative">
|
||||||
|
<div className="text-center -mb-10">支持 HTTP、socks5 双协议代理</div>
|
||||||
<BillingMethodField modeList={modeList} timeDailyLimit={2000}/>
|
<BillingMethodField modeList={modeList} timeDailyLimit={2000}/>
|
||||||
|
{/* 套餐时效 */}
|
||||||
|
{type === '1' && (
|
||||||
|
<FormField name="expire" label="套餐有效时间" description="有效时间内可用于提取 IP">
|
||||||
|
{({id, field}) => (
|
||||||
|
<RadioGroup
|
||||||
|
id={id}
|
||||||
|
value={field.value}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
field.onChange(value)
|
||||||
|
|
||||||
|
const nextLiveList = getAvailablePurchaseLives(skuData, {mode: type, expire: value})
|
||||||
|
if (!nextLiveList.includes(live) && nextLiveList[0]) {
|
||||||
|
setValue('live', nextLiveList[0])
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex gap-4 flex-wrap">
|
||||||
|
{expireList.map(day => (
|
||||||
|
<FormOption
|
||||||
|
key={day}
|
||||||
|
id={`${id}-${day}`}
|
||||||
|
value={day}
|
||||||
|
label={`${day} 天`}
|
||||||
|
compare={field.value}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* IP 时效 */}
|
{/* IP 时效 */}
|
||||||
<FormField<Schema, 'live'>
|
<FormField<Schema, 'live'>
|
||||||
className="space-y-4"
|
|
||||||
name="live"
|
name="live"
|
||||||
label="IP 时效">
|
label="IP 有效时间"
|
||||||
|
description="提取出的 IP 可用时间"
|
||||||
|
>
|
||||||
{({id, field}) => (
|
{({id, field}) => (
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
id={id}
|
id={id}
|
||||||
@@ -136,49 +163,21 @@ export default function Center({
|
|||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
{/* 套餐时效 */}
|
|
||||||
{type === '1' && (
|
|
||||||
<FormField className="space-y-4" name="expire" label="套餐时效">
|
|
||||||
{({id, field}) => (
|
|
||||||
<RadioGroup
|
|
||||||
id={id}
|
|
||||||
value={field.value}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
field.onChange(value)
|
|
||||||
|
|
||||||
const nextLiveList = getAvailablePurchaseLives(skuData, {mode: type, expire: value})
|
|
||||||
if (!nextLiveList.includes(live) && nextLiveList[0]) {
|
|
||||||
setValue('live', nextLiveList[0])
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="flex gap-4 flex-wrap">
|
|
||||||
{expireList.map(day => (
|
|
||||||
<FormOption
|
|
||||||
key={day}
|
|
||||||
id={`${id}-${day}`}
|
|
||||||
value={day}
|
|
||||||
label={`${day} 天`}
|
|
||||||
compare={field.value}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</RadioGroup>
|
|
||||||
)}
|
|
||||||
</FormField>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 每日提取上限/购买数量 */}
|
{/* 每日提取上限/购买数量 */}
|
||||||
{type === '1' ? (
|
{type === '1' ? (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="daily_limit"
|
name="daily_limit"
|
||||||
label="每日提取上限"
|
label="IP 每日提取上限"
|
||||||
min={currentCountMin || 2000}
|
description="本套餐每日可提取 IP 的最大数量"
|
||||||
|
min={currentCountMin}
|
||||||
step={1000}
|
step={1000}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="quota"
|
name="quota"
|
||||||
label="IP 购买数量"
|
label="IP 总提取上限"
|
||||||
min={currentCountMin || 10000}
|
description="本套餐总计可提取 IP 的最大数量"
|
||||||
|
min={currentCountMin}
|
||||||
step={5000}
|
step={5000}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ import {PurchaseSidePanel} from '../shared/side-panel'
|
|||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
type: z.enum(['1', '2']).default('2'),
|
type: z.enum(['1', '2']).default('2'),
|
||||||
live: z.string(),
|
live: z.string(),
|
||||||
quota: z.number().min(10000, '购买数量不能少于 10000 个'),
|
quota: z.number(),
|
||||||
expire: z.string(),
|
expire: z.string(),
|
||||||
daily_limit: z.number().min(2000, '每日限额不能少于 2000 个'),
|
daily_limit: z.number(),
|
||||||
pay_type: z.enum(['wechat', 'alipay', 'balance']).default('balance'),
|
pay_type: z.enum(['wechat', 'alipay', 'balance']).default('balance'),
|
||||||
})
|
})
|
||||||
export type Schema = z.infer<typeof schema>
|
export type Schema = z.infer<typeof schema>
|
||||||
|
|
||||||
export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
|
export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||||
const skuData = parsePurchaseSkuList('short', skuList)
|
const skuData = parsePurchaseSkuList('short', skuList)
|
||||||
const defaultMode = skuData.modeList.includes('2') ? '2' : '1'
|
const defaultMode = skuData.modeList.includes('1') ? '1' : '2'
|
||||||
const defaultLive = getAvailablePurchaseLives(skuData, {mode: defaultMode})[0] || ''
|
const defaultLive = getAvailablePurchaseLives(skuData, {mode: defaultMode})[0] || ''
|
||||||
const defaultExpire = defaultMode === '1'
|
const defaultExpire = defaultMode === '1'
|
||||||
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
||||||
@@ -30,14 +30,15 @@ export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
|
|||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
})
|
})
|
||||||
|
|
||||||
const form = useForm<Schema>({
|
const form = useForm<Schema>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
type: defaultMode,
|
type: defaultMode,
|
||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
quota: defaultMode === '2' ? defaultCountMin || 10000 : 10000,
|
quota: defaultCountMin,
|
||||||
daily_limit: defaultMode === '1' ? defaultCountMin || 2000 : 2000,
|
daily_limit: defaultCountMin,
|
||||||
pay_type: 'balance', // 余额支付
|
pay_type: 'balance', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
8
src/components/seo/json-ld.tsx
Normal file
8
src/components/seo/json-ld.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export function JsonLd({schema}: {schema: Record<string, unknown>}) {
|
||||||
|
return (
|
||||||
|
<script
|
||||||
|
type="application/ld+json"
|
||||||
|
dangerouslySetInnerHTML={{__html: JSON.stringify(schema)}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -80,18 +80,6 @@ function FormField<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* control */}
|
|
||||||
<Slot
|
|
||||||
data-slot="form-control"
|
|
||||||
aria-invalid={!!fieldState.error}
|
|
||||||
aria-describedby={
|
|
||||||
!!fieldState.error
|
|
||||||
? `${id}-description`
|
|
||||||
: `${id}-description ${id}-message`
|
|
||||||
}>
|
|
||||||
{props.children({id, field, fieldState, formState})}
|
|
||||||
</Slot>
|
|
||||||
|
|
||||||
{/* description */}
|
{/* description */}
|
||||||
{!!props.description && (
|
{!!props.description && (
|
||||||
<FormDescription
|
<FormDescription
|
||||||
@@ -105,6 +93,18 @@ function FormField<
|
|||||||
</FormDescription>
|
</FormDescription>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* control */}
|
||||||
|
<Slot
|
||||||
|
data-slot="form-control"
|
||||||
|
aria-invalid={!!fieldState.error}
|
||||||
|
aria-describedby={
|
||||||
|
!!fieldState.error
|
||||||
|
? `${id}-description`
|
||||||
|
: `${id}-description ${id}-message`
|
||||||
|
}>
|
||||||
|
{props.children({id, field, fieldState, formState})}
|
||||||
|
</Slot>
|
||||||
|
|
||||||
{/* message */}
|
{/* message */}
|
||||||
{!fieldState.error ? null : (
|
{!fieldState.error ? null : (
|
||||||
<FormMessage id={`${id}-message`} error={fieldState.error} className={props.classNames?.message}/>
|
<FormMessage id={`${id}-message`} error={fieldState.error} className={props.classNames?.message}/>
|
||||||
|
|||||||
20
src/config/site.ts
Normal file
20
src/config/site.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export const siteConfig = {
|
||||||
|
name: '蓝狐代理',
|
||||||
|
shortName: '蓝狐代理',
|
||||||
|
url: (process.env.API_BASE_URL || 'https://prov.lanhuip.com').replace(/\/$/, ''),
|
||||||
|
description: '蓝狐代理 - 稳定、高速、安全的代理服务,提供HTTP代理、SOCKS5代理、动态IP、静态IP、爬虫代理等产品,保护您的隐私,畅游互联网',
|
||||||
|
keywords: ['代理ip', '国内代理ip', 'http代理', '动态ip', '静态ip', '爬虫代理', '独享代理', 'socks5代理'],
|
||||||
|
author: '蓝狐团队',
|
||||||
|
locale: 'zh_CN',
|
||||||
|
social: {
|
||||||
|
twitter: '@lanhuproxy',
|
||||||
|
github: 'lanhu-proxy',
|
||||||
|
},
|
||||||
|
ogImage: {
|
||||||
|
url: '/og-image.jpg',
|
||||||
|
width: 1200,
|
||||||
|
height: 630,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SiteConfig = typeof siteConfig
|
||||||
26
src/lib/models/article.ts
Normal file
26
src/lib/models/article.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export type ArticleNavGroup = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
code: string
|
||||||
|
articles: ArticleNavItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ArticleNavItem = {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
updated_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ArticleDetail = {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
content: string
|
||||||
|
updated_at: string
|
||||||
|
group: ArticleGroupInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ArticleGroupInfo = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
code: string
|
||||||
|
}
|
||||||
@@ -39,6 +39,17 @@ export type Bill = {
|
|||||||
refund: Refund
|
refund: Refund
|
||||||
resource: Resource
|
resource: Resource
|
||||||
}
|
}
|
||||||
|
export type Balance = {
|
||||||
|
id: number
|
||||||
|
resource_id: number
|
||||||
|
bill_no: string
|
||||||
|
amount: number
|
||||||
|
created_at: Date
|
||||||
|
trade: Trade
|
||||||
|
balance_prev: number
|
||||||
|
balance_curr: number
|
||||||
|
bill: Bill
|
||||||
|
}
|
||||||
|
|
||||||
export type Trade = {
|
export type Trade = {
|
||||||
id: number
|
id: number
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ type ResourceShort = {
|
|||||||
used: number
|
used: number
|
||||||
daily: number
|
daily: number
|
||||||
last_at?: Date
|
last_at?: Date
|
||||||
|
sku?: sku
|
||||||
|
}
|
||||||
|
|
||||||
|
type sku = {
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourceLong = {
|
type ResourceLong = {
|
||||||
@@ -20,6 +25,7 @@ type ResourceLong = {
|
|||||||
used: number
|
used: number
|
||||||
daily: number
|
daily: number
|
||||||
last_at?: Date
|
last_at?: Date
|
||||||
|
sku?: sku
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Resource<T extends 1 | 2 = 1 | 2> = {
|
export type Resource<T extends 1 | 2 = 1 | 2> = {
|
||||||
@@ -29,6 +35,7 @@ export type Resource<T extends 1 | 2 = 1 | 2> = {
|
|||||||
active: boolean
|
active: boolean
|
||||||
created_at: Date
|
created_at: Date
|
||||||
updated_at: Date
|
updated_at: Date
|
||||||
|
checkip: boolean
|
||||||
} & (
|
} & (
|
||||||
T extends 1 ? {
|
T extends 1 ? {
|
||||||
type: 1
|
type: 1
|
||||||
|
|||||||
21
src/lib/utils/date.ts
Normal file
21
src/lib/utils/date.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
export function formatDate(
|
||||||
|
dateStr?: string | null,
|
||||||
|
format: string = 'YYYY-MM-DD',
|
||||||
|
fallback: string = '-',
|
||||||
|
): string {
|
||||||
|
if (!dateStr) return fallback
|
||||||
|
|
||||||
|
const date = new Date(dateStr)
|
||||||
|
if (isNaN(date.getTime())) return fallback
|
||||||
|
|
||||||
|
const map: Record<string, string | number> = {
|
||||||
|
YYYY: date.getFullYear(),
|
||||||
|
MM: String(date.getMonth() + 1).padStart(2, '0'),
|
||||||
|
DD: String(date.getDate()).padStart(2, '0'),
|
||||||
|
HH: String(date.getHours()).padStart(2, '0'),
|
||||||
|
mm: String(date.getMinutes()).padStart(2, '0'),
|
||||||
|
ss: String(date.getSeconds()).padStart(2, '0'),
|
||||||
|
}
|
||||||
|
|
||||||
|
return format.replace(/YYYY|MM|DD|HH|mm|ss/g, matched => String(map[matched]))
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2017",
|
"target": "ES2017",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
@@ -13,13 +17,16 @@
|
|||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
|
"allowArbitraryExtensions": true,
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"name": "next"
|
"name": "next"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
@@ -30,5 +37,7 @@
|
|||||||
".next/dev/types/**/*.ts",
|
".next/dev/types/**/*.ts",
|
||||||
"**/*.mts"
|
"**/*.mts"
|
||||||
],
|
],
|
||||||
"exclude": ["node_modules"]
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user