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