补充个人中心下的页面

This commit is contained in:
Eamon
2026-08-31 14:49:28 +08:00
parent b1f99b51e2
commit 3072b97bcf
59 changed files with 4122 additions and 970 deletions

View File

@@ -10,6 +10,9 @@ import { Button } from "@/components/ui/button"
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import type { ChannelRecord } from "@/lib/models/channel"
import { INITIAL_CHANNELS } from "./mock"
// TODO: 后端就绪后替换为 fetchChannelPage(见 src/api/channel.ts)
const filterSchema = z.object({
expired_at_end: z.string().optional(),
@@ -21,61 +24,8 @@ const filterSchema = z.object({
type FormValues = z.infer<typeof filterSchema>
const initialData: ChannelRecord[] = [
{
id: "1",
startAt: "2025.04.09",
product: "极光IP",
plan: "测试卡(带宽)",
account: "ft8765",
password: "765修改",
ip: "甘肃-兰州125.75.111.127",
server: "p3.125.74.129.38.sdip.cc",
connections: 1,
expiredAt: "2025.04.09",
remaining: "已过期",
online: "查看",
download: "下载",
status: "",
},
{
id: "2",
startAt: "2025.04.09",
product: "极光IP",
plan: "测试卡(带宽)",
account: "ft8765",
password: "765修改",
ip: "辽宁-辽阳123.190.161.192",
server: "p16.cqdwx4.sdip.cc",
connections: 1,
expiredAt: "2025.04.09",
remaining: "0天00时37分",
online: "查看",
download: "下载",
status: "",
},
{
id: "3",
startAt: "2025.04.09",
product: "极光IP",
plan: "静态-项目-20M-月卡",
account: "ft8765",
password: "765修改",
ip: "黑龙江-鸡西100.100.4.249",
server: "p37.sdlw2.sdip.cc",
connections: 1,
expiredAt: "2025.04.09",
remaining: "0天00时37分",
online: "查看",
download: "下载",
status: "",
},
]
export default function ChannelsPage() {
const [filterValues, setFilterValues] = useState<FormValues>({})
const [status, setStatus] = useState<"load" | "done">("done")
// 行选择状态
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({})
const { control, handleSubmit, reset } = useForm<FormValues>({
@@ -91,10 +41,10 @@ export default function ChannelsPage() {
const filteredData = useMemo(() => {
if (!filterValues || Object.values(filterValues).every(value => !value)) {
return initialData
return INITIAL_CHANNELS
}
return initialData.filter(record => {
return INITIAL_CHANNELS.filter(record => {
if (filterValues.expired_at_end) {
return record.expiredAt <= filterValues.expired_at_end
}
@@ -126,12 +76,8 @@ export default function ChannelsPage() {
}, [filterValues])
const onSubmit = (values: FormValues) => {
setStatus("load")
setTimeout(() => {
setFilterValues(values)
setRowSelection({})
setStatus("done")
}, 200)
setFilterValues(values)
setRowSelection({})
}
const onReset = () => {
@@ -149,7 +95,8 @@ export default function ChannelsPage() {
// 批量续费
const handleRenew = () => {
const rows = getSelectedRows()
console.log("续费选中数据:", rows)
// TODO: 后端续费接口就绪后接入(见 src/api/http.ts rebuyOrder)
toast.info(`已选择 ${rows.length} 条数据进行续费`)
}
// 单个退货
@@ -159,7 +106,8 @@ export default function ChannelsPage() {
toast.error("请选择一条数据进行退货")
return
}
console.log("退货数据:", rows[0])
// TODO: 后端退货接口就绪后接入
toast.info(`退货账号:${rows[0].account}`)
}
return (
@@ -257,7 +205,7 @@ export default function ChannelsPage() {
</div>
<DataTable<ChannelRecord>
data={filteredData}
status={status}
status="done"
columns={[
{ accessorKey: "startAt", header: "开通时间" },
{ accessorKey: "product", header: "产品" },