Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84a5e27c05 | ||
|
|
9dea370a87 | ||
|
|
602372e58d | ||
|
|
574ad0e662 | ||
|
|
78d916ade1 | ||
|
|
6a9e7289b5 | ||
| 6adcd33943 | |||
|
|
165151b9d2 | ||
|
|
1e76275f04 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lanhu-web",
|
||||
"version": "1.9.0",
|
||||
"version": "1.12.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -H 0.0.0.0 --turbopack",
|
||||
|
||||
@@ -9,8 +9,8 @@ if ($confrim -ne "y") {
|
||||
exit 0
|
||||
}
|
||||
|
||||
docker build -t repo.lanhuip.com:8554/lanhu/web:latest .
|
||||
docker build -t repo.lanhuip.com:8554/lanhu/web:$($args[0]) .
|
||||
docker build -t repo.lanhuip.com/lanhu/web:latest .
|
||||
docker build -t repo.lanhuip.com/lanhu/web:$($args[0]) .
|
||||
|
||||
docker push repo.lanhuip.com:8554/lanhu/web:latest
|
||||
docker push repo.lanhuip.com:8554/lanhu/web:$($args[0])
|
||||
docker push repo.lanhuip.com/lanhu/web:latest
|
||||
docker push repo.lanhuip.com/lanhu/web:$($args[0])
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export async function listChannels(props: {
|
||||
}
|
||||
|
||||
type CreateChannelsResp = {
|
||||
ip: string
|
||||
host: string
|
||||
port: string
|
||||
username?: string
|
||||
@@ -31,6 +32,7 @@ export async function createChannels(params: {
|
||||
prov?: string
|
||||
city?: string
|
||||
isp?: number
|
||||
host_format?: number
|
||||
}) {
|
||||
return callByUser<CreateChannelsResp[]>('/api/channel/create', params)
|
||||
return callPublic<CreateChannelsResp[]>('/api/channel/create', params)
|
||||
}
|
||||
|
||||
@@ -103,3 +103,10 @@ export async function getPriceHome(props: CreateResourceReq) {
|
||||
discounted?: string
|
||||
}>('/api/resource/price', props)
|
||||
}
|
||||
|
||||
export async function updateCheckip(props: {
|
||||
id: number
|
||||
checkip: boolean
|
||||
}) {
|
||||
return callByUser('/api/resource/update/checkip', props)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export async function GET(req: NextRequest) {
|
||||
const prov = params.get('a') || undefined
|
||||
const city = params.get('b') || undefined
|
||||
const isp = params.get('s') || undefined
|
||||
const hostFormat = params.get('rh') || 'domain'
|
||||
|
||||
const result = await createChannels({
|
||||
resource_id: Number(resource_id),
|
||||
@@ -32,7 +33,9 @@ export async function GET(req: NextRequest) {
|
||||
prov,
|
||||
city,
|
||||
isp: Number(isp),
|
||||
host_format: hostFormat === 'domain' ? 1 : 2,
|
||||
})
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(result.message)
|
||||
}
|
||||
@@ -46,10 +49,32 @@ export async function GET(req: NextRequest) {
|
||||
|
||||
switch (format) {
|
||||
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':
|
||||
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) {
|
||||
list.push(item.username)
|
||||
list.push(item.password)
|
||||
|
||||
@@ -93,7 +93,7 @@ export default function LoginCard() {
|
||||
<div className="relative w-96 mx-4">
|
||||
<Link
|
||||
href="/"
|
||||
className="absolute -top-8 right-0 inline-flex items-center text-sm transition-colors"
|
||||
className="absolute -top-8 right-0 inline-flex items-center text-sm transition-colors px-10"
|
||||
>
|
||||
<HomeIcon size={18} className="mr-1"/>
|
||||
返回首页
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
| b | string | 否 | 归属地城市。默认全局随机 |
|
||||
| s | string | 否 | 归属地运营商。默认全局随机 |
|
||||
| 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) |
|
||||
| rb | number[] | 否 | 返回时要使用的换行符,值为该字符的 ascii 编码,可以有多个字符,多个字符用半角逗号连接。默认为 124,即垂直线( \| ) |
|
||||
| n | number | 否 | 提取数量。默认为 1 |
|
||||
@@ -33,11 +34,11 @@
|
||||
| password | string | 代理服务器密码(仅在认证类型为密码时返回) |
|
||||
|
||||
|
||||
## 示例
|
||||
## 示例1:
|
||||
|
||||
### 请求示例
|
||||
|
||||
```http
|
||||
```http
|
||||
GET https://lanhuip.com/api/extract?i=1&t=2&a=广东省&b=广州市&s=移动&d=1&rt=2&n=3
|
||||
```
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
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
|
||||
}
|
||||
235
src/app/admin/balance/page.tsx
Normal file
235
src/app/admin/balance/page.tsx
Normal file
@@ -0,0 +1,235 @@
|
||||
'use client'
|
||||
import {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>
|
||||
|
||||
<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'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import {RealnameAuthDialog} from '@/components/composites/dialogs/realname-auth-
|
||||
import UserCenter from '@/components/composites/user-center'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@/components/ui/tooltip'
|
||||
import {Archive, ArchiveRestore, Eye, HardDriveUpload, IdCard, LockKeyhole, MessageCircleMoreIcon, 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 logoAvatar from '@/assets/logo-avatar.svg'
|
||||
import logoText from '@/assets/logo-text.svg'
|
||||
@@ -93,7 +93,8 @@ function ContentResolved() {
|
||||
export function Header() {
|
||||
const navbar = useLayoutStore(store => store.navbar)
|
||||
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
||||
|
||||
const profile = use(useProfileStore(store => store.profile))
|
||||
const showRealnameAuth = profile?.id_type === 0
|
||||
return (
|
||||
<header className={merge(
|
||||
`flex-none h-16 overflow-hidden`,
|
||||
@@ -119,13 +120,23 @@ export function Header() {
|
||||
</Button>
|
||||
<span className="max-md:hidden">欢迎来到,蓝狐代理</span>
|
||||
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
||||
<Link
|
||||
href="/admin/identify"
|
||||
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
||||
>
|
||||
<IdCard size={16}/>
|
||||
<span>实名认证</span>
|
||||
</Link>
|
||||
{showRealnameAuth ? (
|
||||
<Link
|
||||
href="/admin/identify"
|
||||
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
||||
>
|
||||
<IdCard size={16}/>
|
||||
<span>实名认证</span>
|
||||
</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"
|
||||
@@ -200,6 +211,7 @@ export function Navbar() {
|
||||
<NavItem href="/admin/extract" icon={<HardDriveUpload size={20}/>} label="提取 IP" expand={navbar}/>
|
||||
<NavTitle label="个人中心"/>
|
||||
<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}/>
|
||||
<NavTitle label="资源管理"/>
|
||||
<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'
|
||||
|
||||
export default function Template(props: {
|
||||
@@ -13,7 +13,9 @@ export default function Template(props: {
|
||||
</div>
|
||||
|
||||
<div className="col-start-2 row-start-1 bg-card overflow-hidden relative z-20">
|
||||
<Header/>
|
||||
<Suspense>
|
||||
<Header/>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
<svg className="col-start-2 row-start-2 w-full h-full z-20 pointer-events-none" preserveAspectRatio="none">
|
||||
|
||||
@@ -8,7 +8,7 @@ import zod from 'zod'
|
||||
import {toast} from 'sonner'
|
||||
import {useStatus} from '@/lib/states'
|
||||
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 {ColumnDef} from '@tanstack/react-table'
|
||||
import {Resource} from '@/lib/models/resource'
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
isValidResourceType,
|
||||
ResourceTypeBadge,
|
||||
} from './utils'
|
||||
import {Button} from '@/components/ui/button'
|
||||
|
||||
const filterSchema = zod.object({
|
||||
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 resourceKey = isLong ? 'long' : 'short'
|
||||
|
||||
const baseColumns: ColumnDef<Resource<1> | Resource<2>>[] = [
|
||||
const baseColumns = ([
|
||||
{
|
||||
header: '套餐编号',
|
||||
cell: ({row}) => {
|
||||
@@ -218,7 +239,11 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
||||
{
|
||||
header: '开通时间',
|
||||
cell: ({row}) => formatDateTime(row.original.created_at),
|
||||
},
|
||||
}, // 短效资源增加到期时间列
|
||||
!isLong ? {
|
||||
header: '到期时间',
|
||||
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
||||
} : undefined,
|
||||
{
|
||||
header: '状态',
|
||||
cell: ({row}) => {
|
||||
@@ -231,25 +256,21 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
||||
},
|
||||
},
|
||||
{
|
||||
header: 'IP检查状态',
|
||||
header: '操作',
|
||||
cell: ({row}) => {
|
||||
const checkip = row.original.checkip
|
||||
return (
|
||||
<span className={checkip ? 'text-green-500' : 'text-red-500'}>
|
||||
{checkip ? '启用IP检查' : '停用IP检查'}
|
||||
</span>
|
||||
<Button
|
||||
theme={checkip ? 'fail' : 'default'}
|
||||
className="h-7 px-3 text-sm"
|
||||
onClick={() => handleCheckipChange(row.original.id, row.original.checkip)}
|
||||
>
|
||||
{checkip ? '停用IP检查' : '启用IP检查'}
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
// 短效资源增加到期时间列
|
||||
if (!isLong) {
|
||||
baseColumns.push({
|
||||
header: '到期时间',
|
||||
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
||||
})
|
||||
}
|
||||
] satisfies ((ColumnDef<Resource<1> | Resource<2>> | undefined)[])).filter(Boolean) as ColumnDef<Resource<1> | Resource<2>>[]
|
||||
|
||||
return baseColumns
|
||||
}, [isLong])
|
||||
|
||||
@@ -34,7 +34,7 @@ type SchemaType = z.infer<typeof schema>
|
||||
|
||||
export type WhitelistPageProps = {}
|
||||
|
||||
const MAX_WHITELIST_COUNT = 10
|
||||
const MAX_WHITELIST_COUNT = 5
|
||||
|
||||
export default function WhitelistPage(props: WhitelistPageProps) {
|
||||
const [wait, setWait] = useState(false)
|
||||
|
||||
@@ -28,10 +28,11 @@ const schema = z.object({
|
||||
city: z.string().optional(),
|
||||
regionType: z.enum(['unlimited', 'specific']).default('unlimited'),
|
||||
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: '请选择认证方式'}),
|
||||
distinct: z.enum(['1', '0'], {required_error: '请选择去重选项'}),
|
||||
format: z.enum(['text', 'json'], {required_error: '请选择导出格式'}),
|
||||
hostFormat: z.enum(['domain', 'ip'], {required_error: '请选择主机格式'}),
|
||||
separator: z.string({required_error: '请选择分隔符'}),
|
||||
breaker: z.string({required_error: '请选择换行符'}),
|
||||
count: z.number({required_error: '请输入有效的数量'}).min(1),
|
||||
@@ -53,6 +54,7 @@ export default function Extract(props: ExtractProps) {
|
||||
authType: '1',
|
||||
count: 1,
|
||||
distinct: '1',
|
||||
hostFormat: 'domain',
|
||||
format: 'text',
|
||||
breaker: '13,10',
|
||||
separator: '124',
|
||||
@@ -71,7 +73,7 @@ export default function Extract(props: ExtractProps) {
|
||||
)}
|
||||
>
|
||||
<CardSection>
|
||||
<Alert variant="warn" className="flex items-center justify-between">
|
||||
{/* <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>
|
||||
@@ -83,7 +85,7 @@ export default function Extract(props: ExtractProps) {
|
||||
<span>添加白名单</span>
|
||||
<ArrowRight className="size-4"/>
|
||||
</Link>
|
||||
</Alert>
|
||||
</Alert> */}
|
||||
|
||||
<FormFields/>
|
||||
</CardSection>
|
||||
@@ -163,12 +165,12 @@ const FormFields = memo(() => {
|
||||
<RadioGroupItem value="1" id={`${id}-v-http`} className="mr-2"/>
|
||||
<span>HTTP</span>
|
||||
</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"/>
|
||||
<span>HTTPS</span>
|
||||
</FormLabel>
|
||||
</FormLabel> */}
|
||||
<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>
|
||||
</FormLabel>
|
||||
</RadioGroup>
|
||||
@@ -233,6 +235,26 @@ const FormFields = memo(() => {
|
||||
)}
|
||||
</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'}}>
|
||||
{({id, field}) => (
|
||||
@@ -494,6 +516,8 @@ function SelectRegion() {
|
||||
const regionType = useWatch({control, name: 'regionType'})
|
||||
const prov = useWatch({control, name: 'prov'})
|
||||
const city = useWatch({control, name: 'city'})
|
||||
console.log(regionType, 'regionType')
|
||||
console.log(prov, 'prov', city, 'city')
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 md:max-w-[calc(160px*2+1rem)]">
|
||||
@@ -604,25 +628,40 @@ function ApplyLink() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={merge(
|
||||
`flex flex-col gap-4`,
|
||||
`rounded-lg`,
|
||||
)}>
|
||||
<h4>API 链接</h4>
|
||||
<div className="flex flex-col gap-3 rounded-lg">
|
||||
<Alert variant="warn" className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<CircleAlert className="size-4 shrink-0"/>
|
||||
<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>
|
||||
|
||||
{/* 展示链接地址 */}
|
||||
<div className="bg-secondary p-4 rounded-md break-all">
|
||||
<Alert className="flex items-center justify-between">
|
||||
<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())}
|
||||
</div>
|
||||
|
||||
{/* 操作 */}
|
||||
<div className="flex gap-4">
|
||||
<Button type="button" onClick={() => submit('copy')}>
|
||||
<CopyIcon/>
|
||||
<div className="flex gap-3">
|
||||
<Button type="button" onClick={() => submit('copy')} className="gap-1">
|
||||
<CopyIcon className="size-4"/>
|
||||
<span>复制链接</span>
|
||||
</Button>
|
||||
<Button type="button" onClick={() => submit('open')}>
|
||||
<ExternalLinkIcon/>
|
||||
<Button type="button" onClick={() => submit('open')} className="gap-1">
|
||||
<ExternalLinkIcon className="size-4"/>
|
||||
<span>打开链接</span>
|
||||
</Button>
|
||||
</div>
|
||||
@@ -631,7 +670,7 @@ function ApplyLink() {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
const sp = new URLSearchParams()
|
||||
if (resource) sp.set('i', String(resource))
|
||||
@@ -643,6 +682,7 @@ function link(values: Schema) {
|
||||
if (isp != 'all') sp.set('s', isp)
|
||||
sp.set('d', distinct)
|
||||
sp.set('rt', formatType)
|
||||
sp.set('rh', hostFormat)
|
||||
sp.set('rs', separator)
|
||||
sp.set('rb', breaker)
|
||||
sp.set('n', String(count))
|
||||
|
||||
@@ -79,14 +79,45 @@ export default function Center({skuData}: {
|
||||
}, [expire, live, modeList, setValue, skuData, type])
|
||||
|
||||
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}/>
|
||||
{/* 套餐时效 */}
|
||||
{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 时效 */}
|
||||
<FormField<Schema, 'live'>
|
||||
className="space-y-4"
|
||||
name="live"
|
||||
label="IP 时效">
|
||||
label="IP 有效时间"
|
||||
description="提取出的 IP 可用时间"
|
||||
>
|
||||
{({id, field}) => (
|
||||
<RadioGroup
|
||||
id={id}
|
||||
@@ -128,48 +159,20 @@ export default function Center({skuData}: {
|
||||
)}
|
||||
</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' ? (
|
||||
<NumberStepperField
|
||||
name="daily_limit"
|
||||
label="每日提取上限"
|
||||
label="IP 每日提取上限"
|
||||
description="本套餐每日可提取 IP 的最大数量"
|
||||
min={currentCountMin}
|
||||
step={100}
|
||||
/>
|
||||
) : (
|
||||
<NumberStepperField
|
||||
name="quota"
|
||||
label="IP 购买数量"
|
||||
label="IP 总提取上限"
|
||||
description="本套餐总计可提取 IP 的最大数量"
|
||||
min={currentCountMin}
|
||||
step={100}
|
||||
/>
|
||||
|
||||
@@ -20,7 +20,7 @@ export type Schema = z.infer<typeof schema>
|
||||
|
||||
export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||
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 defaultExpire = defaultMode === '1'
|
||||
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
||||
|
||||
@@ -34,15 +34,6 @@ export function BillingMethodField(props: {
|
||||
}}
|
||||
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') && (
|
||||
<FormOption
|
||||
@@ -53,6 +44,15 @@ export function BillingMethodField(props: {
|
||||
compare={field.value}
|
||||
/>
|
||||
)}
|
||||
{props.modeList.includes('2') && (
|
||||
<FormOption
|
||||
id={`${id}-2`}
|
||||
value="2"
|
||||
label="包量套餐"
|
||||
description="适用于短期或不定期高提取业务场景"
|
||||
compare={field.value}
|
||||
/>
|
||||
)}
|
||||
</RadioGroup>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
@@ -12,6 +12,7 @@ type PurchaseStepperFieldName = 'quota' | 'daily_limit'
|
||||
type NumberStepperFieldProps = {
|
||||
name: PurchaseStepperFieldName
|
||||
label: string
|
||||
description?: string
|
||||
min: number
|
||||
step: number
|
||||
}
|
||||
@@ -25,7 +26,7 @@ export function NumberStepperField(props: NumberStepperFieldProps) {
|
||||
|
||||
return (
|
||||
<FormField<PurchaseFormValues, PurchaseStepperFieldName>
|
||||
className="space-y-4"
|
||||
description={props.description}
|
||||
name={props.name}
|
||||
label={props.label}
|
||||
>
|
||||
|
||||
@@ -134,7 +134,7 @@ export function PurchaseSidePanel(props: PurchaseSidePanelProps) {
|
||||
)
|
||||
) : (
|
||||
<Link href="/login" className={buttonVariants()}>
|
||||
登录后支付
|
||||
去支付
|
||||
</Link>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
@@ -80,14 +80,45 @@ export default function Center({
|
||||
}, [expire, live, modeList, setValue, skuData, type])
|
||||
|
||||
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}/>
|
||||
{/* 套餐时效 */}
|
||||
{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 时效 */}
|
||||
<FormField<Schema, 'live'>
|
||||
className="space-y-4"
|
||||
name="live"
|
||||
label="IP 时效">
|
||||
label="IP 有效时间"
|
||||
description="提取出的 IP 可用时间"
|
||||
>
|
||||
{({id, field}) => (
|
||||
<RadioGroup
|
||||
id={id}
|
||||
@@ -132,48 +163,20 @@ export default function Center({
|
||||
)}
|
||||
</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' ? (
|
||||
<NumberStepperField
|
||||
name="daily_limit"
|
||||
label="每日提取上限"
|
||||
label="IP 每日提取上限"
|
||||
description="本套餐每日可提取 IP 的最大数量"
|
||||
min={currentCountMin}
|
||||
step={1000}
|
||||
/>
|
||||
) : (
|
||||
<NumberStepperField
|
||||
name="quota"
|
||||
label="IP 购买数量"
|
||||
label="IP 总提取上限"
|
||||
description="本套餐总计可提取 IP 的最大数量"
|
||||
min={currentCountMin}
|
||||
step={5000}
|
||||
/>
|
||||
|
||||
@@ -20,7 +20,7 @@ export type Schema = z.infer<typeof schema>
|
||||
|
||||
export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
|
||||
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 defaultExpire = defaultMode === '1'
|
||||
? getAvailablePurchaseExpires(skuData, {mode: defaultMode, live: defaultLive})[0] || '0'
|
||||
|
||||
@@ -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 */}
|
||||
{!!props.description && (
|
||||
<FormDescription
|
||||
@@ -105,6 +93,18 @@ function FormField<
|
||||
</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 */}
|
||||
{!fieldState.error ? null : (
|
||||
<FormMessage id={`${id}-message`} error={fieldState.error} className={props.classNames?.message}/>
|
||||
|
||||
@@ -39,6 +39,17 @@ export type Bill = {
|
||||
refund: Refund
|
||||
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 = {
|
||||
id: number
|
||||
|
||||
Reference in New Issue
Block a user