fix(frontend): ship pending card-view animation and interaction refinements

This commit is contained in:
sagitchu
2026-02-22 15:52:48 +08:00
parent 79c28103d5
commit d483258eef
16 changed files with 640 additions and 503 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ export function SearchBar({
return ( return (
// Fixed h-8 so the container never changes height — eliminates the vertical jitter // Fixed h-8 so the container never changes height — eliminates the vertical jitter
<div className="flex items-center gap-2 h-8 overflow-hidden"> <div className="flex items-center gap-2 h-8 overflow-hidden">
<AnimatePresence mode="wait" initial={false}> <AnimatePresence initial={false} mode="wait">
{!isVisible ? ( {!isVisible ? (
<motion.div <motion.div
key="search-btn" key="search-btn"
@@ -58,9 +58,9 @@ export function SearchBar({
autoFocus autoFocus
classNames={{ classNames={{
base: "bg-default-100", base: "bg-default-100",
input: "bg-transparent text-sm focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none", input:
inputWrapper: "bg-transparent text-sm focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",
"bg-default-100 border-0 shadow-none h-8 min-h-8", inputWrapper: "bg-default-100 border-0 shadow-none h-8 min-h-8",
}} }}
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
+13 -4
View File
@@ -340,7 +340,8 @@ export default function AdminLayout({
className={` className={`
w-full flex items-center gap-3 px-4 py-3 rounded-lg text-left w-full flex items-center gap-3 px-4 py-3 rounded-lg text-left
relative min-h-[44px] relative min-h-[44px]
${isActive ${
isActive
? "text-primary-600 dark:text-primary-300" ? "text-primary-600 dark:text-primary-300"
: "text-gray-700 dark:text-gray-200" : "text-gray-700 dark:text-gray-200"
} }
@@ -352,7 +353,11 @@ export default function AdminLayout({
<motion.div <motion.div
className="absolute inset-0 rounded-lg bg-primary-100 dark:bg-primary-600/20" className="absolute inset-0 rounded-lg bg-primary-100 dark:bg-primary-600/20"
layoutId="sidebar-active" layoutId="sidebar-active"
transition={{ type: "spring", stiffness: 380, damping: 30 }} transition={{
type: "spring",
stiffness: 380,
damping: 30,
}}
/> />
)} )}
{!isActive && ( {!isActive && (
@@ -362,8 +367,12 @@ export default function AdminLayout({
whileHover={{ opacity: 1 }} whileHover={{ opacity: 1 }}
/> />
)} )}
<div className="flex-shrink-0 relative z-10">{item.icon}</div> <div className="flex-shrink-0 relative z-10">
<span className="font-medium text-sm relative z-10">{item.label}</span> {item.icon}
</div>
<span className="font-medium text-sm relative z-10">
{item.label}
</span>
</motion.button> </motion.button>
</li> </li>
); );
+7 -5
View File
@@ -1,5 +1,7 @@
import { useState, useEffect, useRef } from "react"; import { useState, useEffect, useRef } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import toast from "react-hot-toast";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Input } from "@/shadcn-bridge/heroui/input"; import { Input } from "@/shadcn-bridge/heroui/input";
@@ -16,8 +18,6 @@ import {
ModalFooter, ModalFooter,
ModalHeader, ModalHeader,
} from "@/shadcn-bridge/heroui/modal"; } from "@/shadcn-bridge/heroui/modal";
import toast from "react-hot-toast";
import { import {
updateConfigs, updateConfigs,
exportBackup, exportBackup,
@@ -149,7 +149,7 @@ const getInitialConfigs = (): Record<string, string> => {
initialConfigs[key] = cachedValue; initialConfigs[key] = cachedValue;
} }
}); });
} catch { } } catch {}
return initialConfigs; return initialConfigs;
}; };
@@ -528,7 +528,8 @@ export default function ConfigPage() {
<button <button
key={option.value} key={option.value}
aria-pressed={isSelected} aria-pressed={isSelected}
className={`w-full px-4 py-3 rounded-lg border transition-all duration-200 cursor-pointer text-left ${isSelected className={`w-full px-4 py-3 rounded-lg border transition-all duration-200 cursor-pointer text-left ${
isSelected
? "bg-primary-50 dark:bg-primary-900/20 border-primary-300 dark:border-primary-500/50 shadow-sm" ? "bg-primary-50 dark:bg-primary-900/20 border-primary-300 dark:border-primary-500/50 shadow-sm"
: "bg-white dark:bg-default-50 border-default-200 dark:border-default-100/30 hover:border-primary-200 dark:hover:border-primary-500/30 hover:shadow-sm" : "bg-white dark:bg-default-50 border-default-200 dark:border-default-100/30 hover:border-primary-200 dark:hover:border-primary-500/30 hover:shadow-sm"
}`} }`}
@@ -545,7 +546,8 @@ export default function ConfigPage() {
size="md" size="md"
/> />
<span <span
className={`font-medium ${isSelected className={`font-medium ${
isSelected
? "text-default-900 dark:text-default-100" ? "text-default-900 dark:text-default-100"
: "text-default-700 dark:text-default-500" : "text-default-700 dark:text-default-500"
}`} }`}
+1 -1
View File
@@ -1,7 +1,7 @@
import { useState } from "react"; import { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { AnimatedPage } from "@/components/animated-page";
import { AnimatedPage } from "@/components/animated-page";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { import {
@@ -1,4 +1,5 @@
import type { AnnouncementData } from "@/api"; import type { AnnouncementData } from "@/api";
import ReactMarkdown from "react-markdown"; import ReactMarkdown from "react-markdown";
import rehypeSanitize from "rehype-sanitize"; import rehypeSanitize from "rehype-sanitize";
import remarkGfm from "remark-gfm"; import remarkGfm from "remark-gfm";
@@ -40,10 +41,10 @@ export const AnnouncementBanner = ({
</h3> </h3>
<div className="text-sm text-blue-800/90 dark:text-blue-100/90 break-words leading-relaxed"> <div className="text-sm text-blue-800/90 dark:text-blue-100/90 break-words leading-relaxed">
<ReactMarkdown <ReactMarkdown
rehypePlugins={[rehypeSanitize]}
remarkPlugins={[remarkGfm]}
components={{ components={{
p: ({ children }) => <p className="mb-2 last:mb-0">{children}</p>, p: ({ children }) => (
<p className="mb-2 last:mb-0">{children}</p>
),
a: ({ children, href }) => ( a: ({ children, href }) => (
<a <a
className="underline decoration-blue-500/70 underline-offset-2 hover:text-blue-700 dark:hover:text-blue-100" className="underline decoration-blue-500/70 underline-offset-2 hover:text-blue-700 dark:hover:text-blue-100"
@@ -55,10 +56,14 @@ export const AnnouncementBanner = ({
</a> </a>
), ),
ul: ({ children }) => ( ul: ({ children }) => (
<ul className="list-disc pl-5 space-y-1 mb-2 last:mb-0">{children}</ul> <ul className="list-disc pl-5 space-y-1 mb-2 last:mb-0">
{children}
</ul>
), ),
ol: ({ children }) => ( ol: ({ children }) => (
<ol className="list-decimal pl-5 space-y-1 mb-2 last:mb-0">{children}</ol> <ol className="list-decimal pl-5 space-y-1 mb-2 last:mb-0">
{children}
</ol>
), ),
code: ({ children }) => ( code: ({ children }) => (
<code className="rounded bg-blue-100/80 dark:bg-blue-900/40 px-1 py-0.5 text-[0.92em]"> <code className="rounded bg-blue-100/80 dark:bg-blue-900/40 px-1 py-0.5 text-[0.92em]">
@@ -76,6 +81,8 @@ export const AnnouncementBanner = ({
</blockquote> </blockquote>
), ),
}} }}
rehypePlugins={[rehypeSanitize]}
remarkPlugins={[remarkGfm]}
> >
{announcement.content} {announcement.content}
</ReactMarkdown> </ReactMarkdown>
+171 -65
View File
@@ -1,7 +1,5 @@
import { useState, useEffect, useMemo } from "react"; import { useState, useEffect, useMemo } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { AnimatedPage } from "@/components/animated-page";
import { SearchBar } from "@/components/search-bar";
import { import {
DndContext, DndContext,
closestCenter, closestCenter,
@@ -22,6 +20,8 @@ import {
import { useSortable } from "@dnd-kit/sortable"; import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { SearchBar } from "@/components/search-bar";
import { AnimatedPage } from "@/components/animated-page";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Input } from "@/shadcn-bridge/heroui/input"; import { Input } from "@/shadcn-bridge/heroui/input";
@@ -121,8 +121,6 @@ interface ForwardForm {
strategy: string; strategy: string;
} }
export default function ForwardPage() { export default function ForwardPage() {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [forwards, setForwards] = useState<Forward[]>([]); const [forwards, setForwards] = useState<Forward[]>([]);
@@ -226,7 +224,7 @@ export default function ForwardPage() {
setViewMode(newMode); setViewMode(newMode);
try { try {
localStorage.setItem("forward-view-mode", newMode); localStorage.setItem("forward-view-mode", newMode);
} catch { } } catch {}
}; };
// 加载所有数据 // 加载所有数据
@@ -274,8 +272,6 @@ export default function ForwardPage() {
} }
}; };
// 表单验证 // 表单验证
const validateForm = (): boolean => { const validateForm = (): boolean => {
const newErrors: { [key: string]: string } = {}; const newErrors: { [key: string]: string } = {};
@@ -1100,19 +1096,27 @@ export default function ForwardPage() {
if (filterUserId !== "all") { if (filterUserId !== "all") {
const targetUserId = parseInt(filterUserId); const targetUserId = parseInt(filterUserId);
filteredForwards = filteredForwards.filter(f => f.userId === targetUserId || (targetUserId === 0 && !f.userId));
filteredForwards = filteredForwards.filter(
(f) => f.userId === targetUserId || (targetUserId === 0 && !f.userId),
);
} }
if (filterTunnelId !== "all") { if (filterTunnelId !== "all") {
const targetTunnelId = parseInt(filterTunnelId); const targetTunnelId = parseInt(filterTunnelId);
filteredForwards = filteredForwards.filter(f => f.tunnelId === targetTunnelId);
filteredForwards = filteredForwards.filter(
(f) => f.tunnelId === targetTunnelId,
);
} }
if (searchKeyword.trim()) { if (searchKeyword.trim()) {
const lowerKeyword = searchKeyword.toLowerCase(); const lowerKeyword = searchKeyword.toLowerCase();
filteredForwards = filteredForwards.filter(f =>
filteredForwards = filteredForwards.filter(
(f) =>
(f.name && f.name.toLowerCase().includes(lowerKeyword)) || (f.name && f.name.toLowerCase().includes(lowerKeyword)) ||
(f.remoteAddr && f.remoteAddr.toLowerCase().includes(lowerKeyword)) || (f.remoteAddr && f.remoteAddr.toLowerCase().includes(lowerKeyword)) ||
(f.userName && f.userName.toLowerCase().includes(lowerKeyword)) (f.userName && f.userName.toLowerCase().includes(lowerKeyword)),
); );
} }
@@ -1157,7 +1161,15 @@ export default function ForwardPage() {
} }
return sortedByDb; return sortedByDb;
}, [forwards, forwardOrder, viewMode, tokenUserId, filterUserId, filterTunnelId, searchKeyword]); }, [
forwards,
forwardOrder,
viewMode,
tokenUserId,
filterUserId,
filterTunnelId,
searchKeyword,
]);
const sortableForwardIds = useMemo( const sortableForwardIds = useMemo(
() => sortedForwards.map((f) => f.id).filter((id) => id > 0), () => sortedForwards.map((f) => f.id).filter((id) => id > 0),
@@ -1195,8 +1207,10 @@ export default function ForwardPage() {
// 生成用作筛选项的用户和隧道列表 // 生成用作筛选项的用户和隧道列表
const uniqueUsers = useMemo(() => { const uniqueUsers = useMemo(() => {
const userMap = new Map<number, { id: number; name: string }>(); const userMap = new Map<number, { id: number; name: string }>();
forwards.forEach((f) => { forwards.forEach((f) => {
const uId = f.userId || 0; const uId = f.userId || 0;
if (!userMap.has(uId)) { if (!userMap.has(uId)) {
userMap.set(uId, { id: uId, name: f.userName || "未知用户" }); userMap.set(uId, { id: uId, name: f.userName || "未知用户" });
} }
@@ -1206,7 +1220,22 @@ export default function ForwardPage() {
}, [forwards]); }, [forwards]);
// 可拖拽的表格行组件 // 可拖拽的表格行组件
const SortableTableRow = ({ forward, selectMode, selectedIds, toggleSelect, getStrategyDisplay, formatInAddress, formatRemoteAddress, handleServiceToggle, handleEdit, handleDelete, handleDiagnose, showAddressModal, hasMultipleAddresses, formatFlow }: any) => { const SortableTableRow = ({
forward,
selectMode,
selectedIds,
toggleSelect,
getStrategyDisplay,
formatInAddress,
formatRemoteAddress,
handleServiceToggle,
handleEdit,
handleDelete,
handleDiagnose,
showAddressModal,
hasMultipleAddresses,
formatFlow,
}: any) => {
const { const {
attributes, attributes,
listeners, listeners,
@@ -1226,7 +1255,7 @@ export default function ForwardPage() {
const strategyDisplay = getStrategyDisplay(forward.strategy); const strategyDisplay = getStrategyDisplay(forward.strategy);
return ( return (
<TableRow ref={setNodeRef} style={style} key={forward.id}> <TableRow key={forward.id} ref={setNodeRef} style={style}>
{selectMode && ( {selectMode && (
<TableCell> <TableCell>
<Checkbox <Checkbox
@@ -1242,7 +1271,12 @@ export default function ForwardPage() {
{...listeners} {...listeners}
title="拖拽排序" title="拖拽排序"
> >
<svg aria-hidden="true" className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"> <svg
aria-hidden="true"
className="w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
>
<path d="M7 2a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 2zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 8zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 14zm6-8a2 2 0 1 1-.001-4.001A2 2 0 0 1 13 6zm0 2a2 2 0 1 1 .001 4.001A2 2 0 0 1 13 8zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 13 14z" /> <path d="M7 2a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 2zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 8zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 7 14zm6-8a2 2 0 1 1-.001-4.001A2 2 0 0 1 13 6zm0 2a2 2 0 1 1 .001 4.001A2 2 0 0 1 13 8zm0 6a2 2 0 1 1 .001 4.001A2 2 0 0 1 13 14z" />
</svg> </svg>
</div> </div>
@@ -1254,11 +1288,13 @@ export default function ForwardPage() {
</TableCell> </TableCell>
<TableCell className="whitespace-nowrap"> <TableCell className="whitespace-nowrap">
<Chip <Chip
size="sm"
color="secondary"
className="border-none bg-secondary/10 px-2" className="border-none bg-secondary/10 px-2"
color="secondary"
size="sm"
> >
<span className="font-medium text-secondary-700">{forward.tunnelName}</span> <span className="font-medium text-secondary-700">
{forward.tunnelName}
</span>
</Chip> </Chip>
</TableCell> </TableCell>
<TableCell className="whitespace-nowrap font-semibold text-foreground"> <TableCell className="whitespace-nowrap font-semibold text-foreground">
@@ -1266,7 +1302,8 @@ export default function ForwardPage() {
</TableCell> </TableCell>
<TableCell className="max-w-[220px]"> <TableCell className="max-w-[220px]">
<button <button
className={`w-full truncate rounded-md bg-default-100/50 px-2.5 py-1.5 text-left font-mono text-xs font-medium text-default-700 transition-all ${hasMultipleAddresses(forward.inIp) className={`w-full truncate rounded-md bg-default-100/50 px-2.5 py-1.5 text-left font-mono text-xs font-medium text-default-700 transition-all ${
hasMultipleAddresses(forward.inIp)
? "hover:bg-default-200 hover:shadow-sm" ? "hover:bg-default-200 hover:shadow-sm"
: "" : ""
}`} }`}
@@ -1281,7 +1318,8 @@ export default function ForwardPage() {
</TableCell> </TableCell>
<TableCell className="max-w-[240px]"> <TableCell className="max-w-[240px]">
<button <button
className={`w-full truncate rounded-md bg-default-100/50 px-2.5 py-1.5 text-left font-mono text-xs font-medium text-default-700 transition-all ${hasMultipleAddresses(forward.remoteAddr) className={`w-full truncate rounded-md bg-default-100/50 px-2.5 py-1.5 text-left font-mono text-xs font-medium text-default-700 transition-all ${
hasMultipleAddresses(forward.remoteAddr)
? "hover:bg-default-200 hover:shadow-sm" ? "hover:bg-default-200 hover:shadow-sm"
: "" : ""
}`} }`}
@@ -1312,10 +1350,10 @@ export default function ForwardPage() {
<TableCell> <TableCell>
<div className="flex items-center gap-2.5 whitespace-nowrap"> <div className="flex items-center gap-2.5 whitespace-nowrap">
<Switch <Switch
color="success"
isDisabled={forward.status !== 1 && forward.status !== 0} isDisabled={forward.status !== 1 && forward.status !== 0}
isSelected={forward.serviceRunning} isSelected={forward.serviceRunning}
size="sm" size="sm"
color="success"
onValueChange={() => handleServiceToggle(forward)} onValueChange={() => handleServiceToggle(forward)}
/> />
</div> </div>
@@ -1329,8 +1367,18 @@ export default function ForwardPage() {
title="编辑" title="编辑"
onPress={() => handleEdit(forward)} onPress={() => handleEdit(forward)}
> >
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /> className="h-4 w-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
/>
</svg> </svg>
</Button> </Button>
<Button <Button
@@ -1340,8 +1388,18 @@ export default function ForwardPage() {
title="诊断" title="诊断"
onPress={() => handleDiagnose(forward)} onPress={() => handleDiagnose(forward)}
> >
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" /> className="h-4 w-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
/>
</svg> </svg>
</Button> </Button>
<Button <Button
@@ -1351,8 +1409,18 @@ export default function ForwardPage() {
title="删除" title="删除"
onPress={() => handleDelete(forward)} onPress={() => handleDelete(forward)}
> >
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /> className="h-4 w-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
/>
</svg> </svg>
</Button> </Button>
</div> </div>
@@ -1391,7 +1459,8 @@ export default function ForwardPage() {
<div className="flex items-center gap-1.5 ml-2"> <div className="flex items-center gap-1.5 ml-2">
{viewMode === "direct" && ( {viewMode === "direct" && (
<div <div
className={`cursor-grab active:cursor-grabbing p-2 text-default-400 hover:text-default-600 transition-colors touch-manipulation ${isMobile className={`cursor-grab active:cursor-grabbing p-2 text-default-400 hover:text-default-600 transition-colors touch-manipulation ${
isMobile
? "opacity-100" // 移动端始终显示 ? "opacity-100" // 移动端始终显示
: "opacity-0 group-hover:opacity-100 sm:opacity-0 sm:group-hover:opacity-100" : "opacity-0 group-hover:opacity-100 sm:opacity-0 sm:group-hover:opacity-100"
}`} }`}
@@ -1432,7 +1501,8 @@ export default function ForwardPage() {
{/* 地址信息 */} {/* 地址信息 */}
<div className="space-y-1"> <div className="space-y-1">
<button <button
className={`cursor-pointer px-2 py-1 bg-default-50 dark:bg-default-100/50 rounded border border-default-200 dark:border-default-300 transition-colors duration-200 ${hasMultipleAddresses(forward.inIp) className={`cursor-pointer px-2 py-1 bg-default-50 dark:bg-default-100/50 rounded border border-default-200 dark:border-default-300 transition-colors duration-200 ${
hasMultipleAddresses(forward.inIp)
? "hover:bg-default-100 dark:hover:bg-default-200/50" ? "hover:bg-default-100 dark:hover:bg-default-200/50"
: "" : ""
}`} }`}
@@ -1471,7 +1541,8 @@ export default function ForwardPage() {
</button> </button>
<button <button
className={`cursor-pointer px-2 py-1 bg-default-50 dark:bg-default-100/50 rounded border border-default-200 dark:border-default-300 transition-colors duration-200 ${hasMultipleAddresses(forward.remoteAddr) className={`cursor-pointer px-2 py-1 bg-default-50 dark:bg-default-100/50 rounded border border-default-200 dark:border-default-300 transition-colors duration-200 ${
hasMultipleAddresses(forward.remoteAddr)
? "hover:bg-default-100 dark:hover:bg-default-200/50" ? "hover:bg-default-100 dark:hover:bg-default-200/50"
: "" : ""
}`} }`}
@@ -1641,8 +1712,16 @@ export default function ForwardPage() {
<Button <Button
isIconOnly isIconOnly
aria-label="筛选条件" aria-label="筛选条件"
className={filterUserId !== "all" || filterTunnelId !== "all" ? "bg-primary/20 text-primary relative" : "text-default-600 relative"} className={
color={filterUserId !== "all" || filterTunnelId !== "all" ? "primary" : "default"} filterUserId !== "all" || filterTunnelId !== "all"
? "bg-primary/20 text-primary relative"
: "text-default-600 relative"
}
color={
filterUserId !== "all" || filterTunnelId !== "all"
? "primary"
: "default"
}
size="sm" size="sm"
title="筛选条件" title="筛选条件"
variant="flat" variant="flat"
@@ -1656,10 +1735,10 @@ export default function ForwardPage() {
viewBox="0 0 24 24" viewBox="0 0 24 24"
> >
<path <path
d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"
strokeLinecap="round" strokeLinecap="round"
strokeLinejoin="round" strokeLinejoin="round"
strokeWidth={2} strokeWidth={2}
d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"
/> />
</svg> </svg>
{(filterUserId !== "all" || filterTunnelId !== "all") && ( {(filterUserId !== "all" || filterTunnelId !== "all") && (
@@ -1827,8 +1906,10 @@ export default function ForwardPage() {
}} }}
> >
<TableHeader> <TableHeader>
{selectMode && <TableColumn className="w-14">选择</TableColumn>} {selectMode && (
<TableColumn className="w-10 pl-4"></TableColumn> <TableColumn className="w-14">选择</TableColumn>
)}
<TableColumn className="w-10 pl-4" />
<TableColumn>用户</TableColumn> <TableColumn>用户</TableColumn>
<TableColumn>隧道</TableColumn> <TableColumn>隧道</TableColumn>
<TableColumn>名称</TableColumn> <TableColumn>名称</TableColumn>
@@ -1841,22 +1922,26 @@ export default function ForwardPage() {
</TableHeader> </TableHeader>
<TableBody emptyContent="暂无转发配置" items={sortedForwards}> <TableBody emptyContent="暂无转发配置" items={sortedForwards}>
{(forward) => ( {(forward) => (
<SortableContext items={sortableForwardIds} strategy={verticalListSortingStrategy} key={forward.id}> <SortableContext
key={forward.id}
items={sortableForwardIds}
strategy={verticalListSortingStrategy}
>
<SortableTableRow <SortableTableRow
forward={forward} formatFlow={formatFlow}
selectMode={selectMode}
selectedIds={selectedIds}
toggleSelect={toggleSelect}
getStrategyDisplay={getStrategyDisplay}
formatInAddress={formatInAddress} formatInAddress={formatInAddress}
formatRemoteAddress={formatRemoteAddress} formatRemoteAddress={formatRemoteAddress}
handleServiceToggle={handleServiceToggle} forward={forward}
handleEdit={handleEdit} getStrategyDisplay={getStrategyDisplay}
handleDelete={handleDelete} handleDelete={handleDelete}
handleDiagnose={handleDiagnose} handleDiagnose={handleDiagnose}
showAddressModal={showAddressModal} handleEdit={handleEdit}
handleServiceToggle={handleServiceToggle}
hasMultipleAddresses={hasMultipleAddresses} hasMultipleAddresses={hasMultipleAddresses}
formatFlow={formatFlow} selectMode={selectMode}
selectedIds={selectedIds}
showAddressModal={showAddressModal}
toggleSelect={toggleSelect}
/> />
</SortableContext> </SortableContext>
)} )}
@@ -1883,7 +1968,7 @@ export default function ForwardPage() {
collisionDetection={closestCenter} collisionDetection={closestCenter}
sensors={sensors} sensors={sensors}
onDragEnd={handleDragEnd} onDragEnd={handleDragEnd}
onDragStart={() => { }} // 添加空的 onDragStart 处理器 onDragStart={() => {}} // 添加空的 onDragStart 处理器
> >
<SortableContext <SortableContext
items={sortableForwardIds} items={sortableForwardIds}
@@ -2379,7 +2464,8 @@ export default function ForwardPage() {
{importResults.map((result, index) => ( {importResults.map((result, index) => (
<div <div
key={index} key={index}
className={`p-2 rounded border ${result.success className={`p-2 rounded border ${
result.success
? "bg-success-50 dark:bg-success-100/10 border-success-200 dark:border-success-300/20" ? "bg-success-50 dark:bg-success-100/10 border-success-200 dark:border-success-300/20"
: "bg-danger-50 dark:bg-danger-100/10 border-danger-200 dark:border-danger-300/20" : "bg-danger-50 dark:bg-danger-100/10 border-danger-200 dark:border-danger-300/20"
}`} }`}
@@ -2415,7 +2501,8 @@ export default function ForwardPage() {
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-0.5"> <div className="flex items-center gap-2 mb-0.5">
<span <span
className={`text-xs font-medium ${result.success className={`text-xs font-medium ${
result.success
? "text-success-700 dark:text-success-300" ? "text-success-700 dark:text-success-300"
: "text-danger-700 dark:text-danger-300" : "text-danger-700 dark:text-danger-300"
}`} }`}
@@ -2430,7 +2517,8 @@ export default function ForwardPage() {
</code> </code>
</div> </div>
<div <div
className={`text-xs ${result.success className={`text-xs ${
result.success
? "text-success-600 dark:text-success-400" ? "text-success-600 dark:text-success-400"
: "text-danger-600 dark:text-danger-400" : "text-danger-600 dark:text-danger-400"
}`} }`}
@@ -2616,7 +2704,8 @@ export default function ForwardPage() {
return ( return (
<tr <tr
key={index} key={index}
className={`hover:bg-default-50 dark:hover:bg-gray-700/50 ${result.success className={`hover:bg-default-50 dark:hover:bg-gray-700/50 ${
result.success
? "bg-white dark:bg-gray-800" ? "bg-white dark:bg-gray-800"
: "bg-danger-50 dark:bg-danger-900/30" : "bg-danger-50 dark:bg-danger-900/30"
}`} }`}
@@ -2624,7 +2713,8 @@ export default function ForwardPage() {
<td className="px-3 py-2"> <td className="px-3 py-2">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span <span
className={`w-5 h-5 rounded-full flex items-center justify-center text-xs ${result.success className={`w-5 h-5 rounded-full flex items-center justify-center text-xs ${
result.success
? "bg-success text-white" ? "bg-success text-white"
: "bg-danger text-white" : "bg-danger text-white"
}`} }`}
@@ -2669,7 +2759,8 @@ export default function ForwardPage() {
<td className="px-3 py-2 text-center"> <td className="px-3 py-2 text-center">
{result.success ? ( {result.success ? (
<span <span
className={`font-semibold ${(result.packetLoss || 0) > 0 className={`font-semibold ${
(result.packetLoss || 0) > 0
? "text-warning" ? "text-warning"
: "text-success" : "text-success"
}`} }`}
@@ -2786,14 +2877,16 @@ export default function ForwardPage() {
return ( return (
<div <div
key={index} key={index}
className={`border rounded-lg p-3 ${result.success className={`border rounded-lg p-3 ${
result.success
? "border-divider bg-white dark:bg-gray-800" ? "border-divider bg-white dark:bg-gray-800"
: "border-danger-200 dark:border-danger-300/30 bg-danger-50 dark:bg-danger-900/30" : "border-danger-200 dark:border-danger-300/30 bg-danger-50 dark:bg-danger-900/30"
}`} }`}
> >
<div className="flex items-start gap-2 mb-2"> <div className="flex items-start gap-2 mb-2">
<span <span
className={`w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0 ${result.success className={`w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0 ${
result.success
? "bg-success text-white" ? "bg-success text-white"
: "bg-danger text-white" : "bg-danger text-white"
}`} }`}
@@ -2832,7 +2925,8 @@ export default function ForwardPage() {
</div> </div>
<div className="text-center"> <div className="text-center">
<div <div
className={`text-lg font-bold ${(result.packetLoss || 0) > 0 className={`text-lg font-bold ${
(result.packetLoss || 0) > 0
? "text-warning" ? "text-warning"
: "text-success" : "text-success"
}`} }`}
@@ -3054,14 +3148,16 @@ export default function ForwardPage() {
{/* 筛选模态框 */} {/* 筛选模态框 */}
<Modal <Modal
isOpen={isFilterModalOpen} isOpen={isFilterModalOpen}
onOpenChange={setIsFilterModalOpen}
placement="center" placement="center"
size="md" size="md"
onOpenChange={setIsFilterModalOpen}
> >
<ModalContent> <ModalContent>
{(onClose) => ( {(onClose) => (
<> <>
<ModalHeader className="flex flex-col gap-1">筛选条件</ModalHeader> <ModalHeader className="flex flex-col gap-1">
筛选条件
</ModalHeader>
<ModalBody> <ModalBody>
<div className="flex flex-col gap-4 py-2"> <div className="flex flex-col gap-4 py-2">
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
@@ -3069,16 +3165,19 @@ export default function ForwardPage() {
<Select <Select
aria-label="筛选用户" aria-label="筛选用户"
className="w-full" className="w-full"
variant="bordered"
selectedKeys={[filterUserId]} selectedKeys={[filterUserId]}
variant="bordered"
onSelectionChange={(keys) => { onSelectionChange={(keys) => {
const key = Array.from(keys)[0] as string; const key = Array.from(keys)[0] as string;
setFilterUserId(key || "all"); setFilterUserId(key || "all");
}} }}
> >
<SelectItem key="all">全部用户</SelectItem> <SelectItem key="all">全部用户</SelectItem>
{uniqueUsers.map(user => ( {uniqueUsers.map((user) => (
<SelectItem key={user.id.toString()}>{user.name}</SelectItem> <SelectItem key={user.id.toString()}>
{user.name}
</SelectItem>
))} ))}
</Select> </Select>
</div> </div>
@@ -3087,26 +3186,33 @@ export default function ForwardPage() {
<Select <Select
aria-label="筛选隧道" aria-label="筛选隧道"
className="w-full" className="w-full"
variant="bordered"
selectedKeys={[filterTunnelId]} selectedKeys={[filterTunnelId]}
variant="bordered"
onSelectionChange={(keys) => { onSelectionChange={(keys) => {
const key = Array.from(keys)[0] as string; const key = Array.from(keys)[0] as string;
setFilterTunnelId(key || "all"); setFilterTunnelId(key || "all");
}} }}
> >
<SelectItem key="all">全部隧道</SelectItem> <SelectItem key="all">全部隧道</SelectItem>
{tunnels.map(tunnel => ( {tunnels.map((tunnel) => (
<SelectItem key={tunnel.id.toString()}>{tunnel.name}</SelectItem> <SelectItem key={tunnel.id.toString()}>
{tunnel.name}
</SelectItem>
))} ))}
</Select> </Select>
</div> </div>
</div> </div>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="default" variant="flat" onPress={() => { <Button
color="default"
variant="flat"
onPress={() => {
setFilterUserId("all"); setFilterUserId("all");
setFilterTunnelId("all"); setFilterTunnelId("all");
}}> }}
>
重置 重置
</Button> </Button>
<Button color="primary" onPress={onClose}> <Button color="primary" onPress={onClose}>
+9 -4
View File
@@ -1,8 +1,12 @@
import { useState, useEffect, useMemo } from "react"; import { useState, useEffect, useMemo } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { AnimatedPage, StaggerList, StaggerItem } from "@/components/animated-page";
import { SearchBar } from "@/components/search-bar";
import {
AnimatedPage,
StaggerList,
StaggerItem,
} from "@/components/animated-page";
import { SearchBar } from "@/components/search-bar";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Input } from "@/shadcn-bridge/heroui/input"; import { Input } from "@/shadcn-bridge/heroui/input";
@@ -60,9 +64,10 @@ export default function LimitPage() {
if (!searchKeyword.trim()) return rules; if (!searchKeyword.trim()) return rules;
const lowerKeyword = searchKeyword.toLowerCase(); const lowerKeyword = searchKeyword.toLowerCase();
return rules.filter(r => return rules.filter(
(r) =>
(r.name && r.name.toLowerCase().includes(lowerKeyword)) || (r.name && r.name.toLowerCase().includes(lowerKeyword)) ||
(r.tunnelName && r.tunnelName.toLowerCase().includes(lowerKeyword)) (r.tunnelName && r.tunnelName.toLowerCase().includes(lowerKeyword)),
); );
}, [rules, searchKeyword]); }, [rules, searchKeyword]);
+6 -4
View File
@@ -1,7 +1,5 @@
import { useState, useEffect, useMemo, useCallback } from "react"; import { useState, useEffect, useMemo, useCallback } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { AnimatedPage } from "@/components/animated-page";
import { SearchBar } from "@/components/search-bar";
import { import {
DndContext, DndContext,
KeyboardSensor, KeyboardSensor,
@@ -20,6 +18,8 @@ import {
} from "@dnd-kit/sortable"; } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { SearchBar } from "@/components/search-bar";
import { AnimatedPage } from "@/components/animated-page";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Input } from "@/shadcn-bridge/heroui/input"; import { Input } from "@/shadcn-bridge/heroui/input";
@@ -1005,11 +1005,13 @@ export default function NodePage() {
if (searchKeyword.trim()) { if (searchKeyword.trim()) {
const lowerKeyword = searchKeyword.toLowerCase(); const lowerKeyword = searchKeyword.toLowerCase();
filteredNodes = filteredNodes.filter(n =>
filteredNodes = filteredNodes.filter(
(n) =>
(n.name && n.name.toLowerCase().includes(lowerKeyword)) || (n.name && n.name.toLowerCase().includes(lowerKeyword)) ||
(n.serverIp && n.serverIp.toLowerCase().includes(lowerKeyword)) || (n.serverIp && n.serverIp.toLowerCase().includes(lowerKeyword)) ||
(n.serverIpV4 && n.serverIpV4.toLowerCase().includes(lowerKeyword)) || (n.serverIpV4 && n.serverIpV4.toLowerCase().includes(lowerKeyword)) ||
(n.serverIpV6 && n.serverIpV6.toLowerCase().includes(lowerKeyword)) (n.serverIpV6 && n.serverIpV6.toLowerCase().includes(lowerKeyword)),
); );
} }
+8 -3
View File
@@ -416,7 +416,8 @@ export default function PanelSharingPage() {
Provider 共享 Provider 共享
</h2> </h2>
<p className="text-sm text-default-500"> <p className="text-sm text-default-500">
将本地节点分享给其他面板,统一管理 Token、端口范围和到期策略。 将本地节点分享给其他面板,统一管理
Token、端口范围和到期策略。
</p> </p>
</div> </div>
<Button <Button
@@ -429,7 +430,9 @@ export default function PanelSharingPage() {
</div> </div>
{loading ? ( {loading ? (
<div className="text-center py-12 text-default-500">加载中...</div> <div className="text-center py-12 text-default-500">
加载中...
</div>
) : shares.length === 0 ? ( ) : shares.length === 0 ? (
<div className="rounded-lg border border-dashed border-divider bg-default-50/60 dark:bg-default-100/20 px-6 py-10 text-center"> <div className="rounded-lg border border-dashed border-divider bg-default-50/60 dark:bg-default-100/20 px-6 py-10 text-center">
<p className="text-base font-semibold text-foreground"> <p className="text-base font-semibold text-foreground">
@@ -574,7 +577,9 @@ export default function PanelSharingPage() {
</div> </div>
{remoteUsageLoading ? ( {remoteUsageLoading ? (
<div className="text-center py-12 text-default-500">加载中...</div> <div className="text-center py-12 text-default-500">
加载中...
</div>
) : remoteUsageNodes.length === 0 ? ( ) : remoteUsageNodes.length === 0 ? (
<div className="rounded-lg border border-dashed border-divider bg-default-50/60 dark:bg-default-100/20 px-6 py-10 text-center"> <div className="rounded-lg border border-dashed border-divider bg-default-50/60 dark:bg-default-100/20 px-6 py-10 text-center">
<p className="text-base font-semibold text-foreground"> <p className="text-base font-semibold text-foreground">
+22 -14
View File
@@ -19,7 +19,6 @@ import {
useSortable, useSortable,
} from "@dnd-kit/sortable"; } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Input, Textarea } from "@/shadcn-bridge/heroui/input"; import { Input, Textarea } from "@/shadcn-bridge/heroui/input";
@@ -667,13 +666,16 @@ export default function TunnelPage() {
} = useSortable({ id }); } = useSortable({ id });
const style: React.CSSProperties = { const style: React.CSSProperties = {
transform: transform ? CSS.Transform.toString(transform) : undefined, transform: transform
? CSS.Transform.toString({
...transform,
x: Math.round(transform.x),
y: Math.round(transform.y),
})
: undefined,
transition: isDragging ? undefined : transition || undefined, transition: isDragging ? undefined : transition || undefined,
opacity: isDragging ? 0.5 : 1, opacity: isDragging ? 0.5 : 1,
willChange: "transform", willChange: isDragging ? "transform" : undefined,
backfaceVisibility: "hidden",
WebkitFontSmoothing: "antialiased",
MozOsxFontSmoothing: "grayscale",
}; };
return ( return (
@@ -1384,9 +1386,9 @@ export default function TunnelPage() {
.filter((id) => id !== -1) .filter((id) => id !== -1)
.map((id) => id.toString()), .map((id) => id.toString()),
]} ]}
dropdownPlacement="top"
label="节点" label="节点"
placeholder="选择节点(可多选)" placeholder="选择节点(可多选)"
dropdownPlacement="top"
selectedKeys={groupNodes selectedKeys={groupNodes
.filter((ct) => ct.nodeId !== -1) .filter((ct) => ct.nodeId !== -1)
.map((ct) => ct.nodeId.toString())} .map((ct) => ct.nodeId.toString())}
@@ -1600,11 +1602,11 @@ export default function TunnelPage() {
id.toString(), id.toString(),
), ),
]} ]}
dropdownPlacement="top"
errorMessage={errors.outNodeId} errorMessage={errors.outNodeId}
isInvalid={!!errors.outNodeId} isInvalid={!!errors.outNodeId}
label="节点" label="节点"
placeholder="请选择出口节点(可多选)" placeholder="请选择出口节点(可多选)"
dropdownPlacement="top"
selectedKeys={ selectedKeys={
form.outNodeId form.outNodeId
? form.outNodeId ? form.outNodeId
@@ -2057,7 +2059,8 @@ export default function TunnelPage() {
return ( return (
<tr <tr
key={index} key={index}
className={`hover:bg-default-50 dark:hover:bg-gray-700/50 ${result.success className={`hover:bg-default-50 dark:hover:bg-gray-700/50 ${
result.success
? "bg-white dark:bg-gray-800" ? "bg-white dark:bg-gray-800"
: "bg-danger-50 dark:bg-danger-900/30" : "bg-danger-50 dark:bg-danger-900/30"
}`} }`}
@@ -2065,7 +2068,8 @@ export default function TunnelPage() {
<td className="px-3 py-2"> <td className="px-3 py-2">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span <span
className={`w-5 h-5 rounded-full flex items-center justify-center text-xs ${result.success className={`w-5 h-5 rounded-full flex items-center justify-center text-xs ${
result.success
? "bg-success text-white" ? "bg-success text-white"
: "bg-danger text-white" : "bg-danger text-white"
}`} }`}
@@ -2110,7 +2114,8 @@ export default function TunnelPage() {
<td className="px-3 py-2 text-center"> <td className="px-3 py-2 text-center">
{result.success ? ( {result.success ? (
<span <span
className={`font-semibold ${(result.packetLoss || 0) > 0 className={`font-semibold ${
(result.packetLoss || 0) > 0
? "text-warning" ? "text-warning"
: "text-success" : "text-success"
}`} }`}
@@ -2226,14 +2231,16 @@ export default function TunnelPage() {
return ( return (
<div <div
key={index} key={index}
className={`border rounded-lg p-3 ${result.success className={`border rounded-lg p-3 ${
result.success
? "border-divider bg-white dark:bg-gray-800" ? "border-divider bg-white dark:bg-gray-800"
: "border-danger-200 dark:border-danger-300/30 bg-danger-50 dark:bg-danger-900/30" : "border-danger-200 dark:border-danger-300/30 bg-danger-50 dark:bg-danger-900/30"
}`} }`}
> >
<div className="flex items-start gap-2 mb-2"> <div className="flex items-start gap-2 mb-2">
<span <span
className={`w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0 ${result.success className={`w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0 ${
result.success
? "bg-success text-white" ? "bg-success text-white"
: "bg-danger text-white" : "bg-danger text-white"
}`} }`}
@@ -2272,7 +2279,8 @@ export default function TunnelPage() {
</div> </div>
<div className="text-center"> <div className="text-center">
<div <div
className={`text-lg font-bold ${(result.packetLoss || 0) > 0 className={`text-lg font-bold ${
(result.packetLoss || 0) > 0
? "text-warning" ? "text-warning"
: "text-success" : "text-success"
}`} }`}
+16 -11
View File
@@ -1,8 +1,12 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { AnimatedPage, StaggerList, StaggerItem } from "@/components/animated-page";
import { parseDate } from "@internationalized/date"; import { parseDate } from "@internationalized/date";
import {
AnimatedPage,
StaggerList,
StaggerItem,
} from "@/components/animated-page";
import { Button } from "@/shadcn-bridge/heroui/button"; import { Button } from "@/shadcn-bridge/heroui/button";
import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card";
import { Input } from "@/shadcn-bridge/heroui/input"; import { Input } from "@/shadcn-bridge/heroui/input";
@@ -248,7 +252,7 @@ export default function UserPage() {
if (response.code === 0) { if (response.code === 0) {
setTunnels(Array.isArray(response.data) ? response.data : []); setTunnels(Array.isArray(response.data) ? response.data : []);
} }
} catch { } } catch {}
}; };
const loadSpeedLimits = async () => { const loadSpeedLimits = async () => {
@@ -266,7 +270,7 @@ export default function UserPage() {
setSpeedLimits(speedLimitList); setSpeedLimits(speedLimitList);
} }
} catch { } } catch {}
}; };
const loadUserGroups = async () => { const loadUserGroups = async () => {
@@ -276,7 +280,7 @@ export default function UserPage() {
if (response.code === 0) { if (response.code === 0) {
setUserGroups(Array.isArray(response.data) ? response.data : []); setUserGroups(Array.isArray(response.data) ? response.data : []);
} }
} catch { } } catch {}
}; };
const loadUserTunnels = async (userId: number) => { const loadUserTunnels = async (userId: number) => {
@@ -327,7 +331,7 @@ export default function UserPage() {
if (groupRes.code === 0) { if (groupRes.code === 0) {
currentGroupIds = groupRes.data || []; currentGroupIds = groupRes.data || [];
} }
} catch { } } catch {}
setUserForm({ setUserForm({
id: user.id, id: user.id,
@@ -710,9 +714,7 @@ export default function UserPage() {
return ( return (
<StaggerItem key={user.id}> <StaggerItem key={user.id}>
<Card <Card className="shadow-sm border border-divider hover:shadow-md transition-shadow duration-200 overflow-hidden h-full">
className="shadow-sm border border-divider hover:shadow-md transition-shadow duration-200 overflow-hidden h-full"
>
<CardHeader className="pb-2 md:pb-2"> <CardHeader className="pb-2 md:pb-2">
<div className="flex justify-between items-start w-full"> <div className="flex justify-between items-start w-full">
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
@@ -771,7 +773,9 @@ export default function UserPage() {
<div className="space-y-1.5 pt-2 border-t border-divider"> <div className="space-y-1.5 pt-2 border-t border-divider">
<div className="flex justify-between text-sm"> <div className="flex justify-between text-sm">
<span className="text-default-600">转发数量</span> <span className="text-default-600">转发数量</span>
<span className="font-medium text-xs">{user.num}</span> <span className="font-medium text-xs">
{user.num}
</span>
</div> </div>
<div className="flex justify-between text-sm"> <div className="flex justify-between text-sm">
<span className="text-default-600">重置日期</span> <span className="text-default-600">重置日期</span>
@@ -876,7 +880,7 @@ export default function UserPage() {
)} )}
{/* 用户表单模态框 */} {/* 用户表单模态框 */}
< Modal <Modal
backdrop="blur" backdrop="blur"
isOpen={isUserModalOpen} isOpen={isUserModalOpen}
placement="center" placement="center"
@@ -1078,7 +1082,8 @@ export default function UserPage() {
aria-disabled={isAssigned} aria-disabled={isAssigned}
className={` className={`
px-4 py-3 rounded-lg border transition-all duration-200 cursor-pointer px-4 py-3 rounded-lg border transition-all duration-200 cursor-pointer
${isAssigned ${
isAssigned
? "bg-default-100/50 dark:bg-default-50/50 border-default-200/50 dark:border-default-100/20 opacity-60 cursor-not-allowed" ? "bg-default-100/50 dark:bg-default-50/50 border-default-200/50 dark:border-default-100/20 opacity-60 cursor-not-allowed"
: isSelected : isSelected
? "bg-primary-50 dark:bg-primary-900/20 border-primary-300 dark:border-primary-500/50 shadow-sm" ? "bg-primary-50 dark:bg-primary-900/20 border-primary-300 dark:border-primary-500/50 shadow-sm"
@@ -177,6 +177,7 @@ export function DatePicker({
required={isRequired} required={isRequired}
type={shouldUseTextInput ? "text" : "date"} type={shouldUseTextInput ? "text" : "date"}
value={shouldUseTextInput ? textValue : formattedValue} value={shouldUseTextInput ? textValue : formattedValue}
onBlur={shouldUseTextInput ? commitTextInput : undefined}
onChange={(event) => { onChange={(event) => {
const nextValue = event.target.value; const nextValue = event.target.value;
@@ -189,7 +190,6 @@ export function DatePicker({
notifyNativeDateChange(nextValue); notifyNativeDateChange(nextValue);
}} }}
onBlur={shouldUseTextInput ? commitTextInput : undefined}
onKeyDown={ onKeyDown={
shouldUseTextInput shouldUseTextInput
? (event) => { ? (event) => {
@@ -286,26 +286,22 @@ export function Select<T>({
return null; return null;
} }
const placementClasses = dropdownPlacement === "top" const placementClasses =
? "bottom-full mb-1" dropdownPlacement === "top" ? "bottom-full mb-1" : "top-full mt-1";
: "top-full mt-1";
return ( return (
<div <div
ref={listboxRef}
className={cn( className={cn(
"absolute left-0 z-50 w-full space-y-1 overflow-y-auto rounded-md border border-divider bg-background p-2 shadow-md max-h-56", "absolute left-0 z-50 w-full space-y-1 overflow-y-auto rounded-md border border-divider bg-background p-2 shadow-md max-h-56",
placementClasses placementClasses,
)} )}
id={`${generatedId}-listbox`} id={`${generatedId}-listbox`}
ref={listboxRef}
role="listbox" role="listbox"
> >
{options.length === 0 ? ( {options.length === 0 ? (
<div <div
className={cn( className={cn("px-2 py-1 text-default-500", textSizeClass(size))}
"px-2 py-1 text-default-500",
textSizeClass(size),
)}
> >
暂无可选项 暂无可选项
</div> </div>
@@ -334,9 +330,7 @@ export function Select<T>({
className={cn( className={cn(
"min-w-0 flex-1 truncate text-left text-foreground", "min-w-0 flex-1 truncate text-left text-foreground",
textSizeClass(size), textSizeClass(size),
optionDisabled optionDisabled ? "cursor-not-allowed" : "cursor-pointer",
? "cursor-not-allowed"
: "cursor-pointer",
)} )}
disabled={optionDisabled} disabled={optionDisabled}
type="button" type="button"
@@ -363,13 +357,7 @@ export function Select<T>({
label={label} label={label}
> >
{selectionMode === "multiple" ? ( {selectionMode === "multiple" ? (
<div <div ref={containerRef} className={cn("relative w-full", className)}>
ref={containerRef}
className={cn(
"relative w-full",
className,
)}
>
<button <button
aria-controls={`${generatedId}-listbox`} aria-controls={`${generatedId}-listbox`}
aria-expanded={isExpanded} aria-expanded={isExpanded}