mirror of
https://github.com/fankes/komari-theme-purcarte.git
synced 2025-10-19 03:49:22 +08:00
refactor: 优化到期信息显示
This commit is contained in:
@@ -35,7 +35,7 @@ export const NodeCard = ({ node }: NodeCardProps) => {
|
|||||||
swapUsage,
|
swapUsage,
|
||||||
diskUsage,
|
diskUsage,
|
||||||
load,
|
load,
|
||||||
daysLeft,
|
expired_at,
|
||||||
} = useNodeCommons(node);
|
} = useNodeCommons(node);
|
||||||
|
|
||||||
const getProgressBarClass = (percentage: number) => {
|
const getProgressBarClass = (percentage: number) => {
|
||||||
@@ -166,13 +166,7 @@ export const NodeCard = ({ node }: NodeCardProps) => {
|
|||||||
<div className="flex justify-between text-xs">
|
<div className="flex justify-between text-xs">
|
||||||
<div className="flex justify-between w-full">
|
<div className="flex justify-between w-full">
|
||||||
<span className="text-secondary-foreground">到期</span>
|
<span className="text-secondary-foreground">到期</span>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">{expired_at}</div>
|
||||||
{daysLeft !== null && daysLeft > 36500
|
|
||||||
? "长期"
|
|
||||||
: node.expired_at
|
|
||||||
? new Date(node.expired_at).toLocaleDateString()
|
|
||||||
: "N/A"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="border-l border-border/60 mx-2"></div>
|
<div className="border-l border-border/60 mx-2"></div>
|
||||||
<div className="flex justify-between w-full">
|
<div className="flex justify-between w-full">
|
||||||
|
@@ -20,7 +20,7 @@ export const NodeListItem = ({ node }: NodeListItemProps) => {
|
|||||||
swapUsage,
|
swapUsage,
|
||||||
diskUsage,
|
diskUsage,
|
||||||
load,
|
load,
|
||||||
daysLeft,
|
expired_at,
|
||||||
} = useNodeCommons(node);
|
} = useNodeCommons(node);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -40,13 +40,7 @@ export const NodeListItem = ({ node }: NodeListItemProps) => {
|
|||||||
<div className="flex text-xs">
|
<div className="flex text-xs">
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<span className="text-secondary-foreground">到期:</span>
|
<span className="text-secondary-foreground">到期:</span>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">{expired_at}</div>
|
||||||
{daysLeft !== null && daysLeft > 36500
|
|
||||||
? "长期"
|
|
||||||
: node.expired_at
|
|
||||||
? new Date(node.expired_at).toLocaleDateString()
|
|
||||||
: "N/A"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="border-l border-border/60 mx-2"></div>
|
<div className="border-l border-border/60 mx-2"></div>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
|
@@ -39,13 +39,27 @@ export const useNodeCommons = (node: NodeWithStatus) => {
|
|||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
let daysLeftTag = null;
|
||||||
|
if (daysLeft !== null) {
|
||||||
|
if (daysLeft < 0) {
|
||||||
|
daysLeftTag = "已过期";
|
||||||
|
} else if (daysLeft < 36500) {
|
||||||
|
daysLeftTag = `余 ${daysLeft} 天`;
|
||||||
|
} else {
|
||||||
|
daysLeftTag = "长期";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const expired_at =
|
||||||
|
daysLeft !== null && daysLeft > 36500
|
||||||
|
? "长期"
|
||||||
|
: node.expired_at
|
||||||
|
? new Date(node.expired_at).toLocaleDateString()
|
||||||
|
: "N/A";
|
||||||
|
|
||||||
const tagList = [
|
const tagList = [
|
||||||
price,
|
price,
|
||||||
`${daysLeft && daysLeft < 0 ? "已过期" : ""}${
|
...(daysLeftTag ? [daysLeftTag] : []),
|
||||||
daysLeft && daysLeft >= 0 && daysLeft < 36500
|
|
||||||
? "余 " + daysLeft + " 天"
|
|
||||||
: ""
|
|
||||||
}`,
|
|
||||||
...(typeof node.tags === "string"
|
...(typeof node.tags === "string"
|
||||||
? node.tags
|
? node.tags
|
||||||
.split(";")
|
.split(";")
|
||||||
@@ -63,6 +77,6 @@ export const useNodeCommons = (node: NodeWithStatus) => {
|
|||||||
swapUsage,
|
swapUsage,
|
||||||
diskUsage,
|
diskUsage,
|
||||||
load,
|
load,
|
||||||
daysLeft,
|
expired_at,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user