From 929abb3c0485de533fe862f5bf5697f319fff865 Mon Sep 17 00:00:00 2001 From: Tunglies Date: Sun, 1 Jun 2025 19:40:38 +0800 Subject: [PATCH] feat: add "Update via proxy" translation to English and Chinese locales --- src/components/profile/profile-item.tsx | 26 ++++++++++++------------- src/locales/en.json | 1 + src/locales/zh.json | 1 + 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx index 998ac2cf..1c5e0169 100644 --- a/src/components/profile/profile-item.tsx +++ b/src/components/profile/profile-item.tsx @@ -66,7 +66,7 @@ export const ProfileItem = (props: Props) => { const [position, setPosition] = useState({ left: 0, top: 0 }); const loadingCache = useLoadingCache(); const setLoadingCache = useSetLoadingCache(); - + // 新增状态:是否显示下次更新时间 const [showNextUpdate, setShowNextUpdate] = useState(false); const [nextUpdateTime, setNextUpdateTime] = useState(""); @@ -78,27 +78,27 @@ export const ProfileItem = (props: Props) => { if (itemData.option?.update_interval && itemData.option.update_interval > 0) { try { console.log(`尝试获取配置 ${itemData.uid} 的下次更新时间`); - + // 如果需要强制刷新,先触发Timer.refresh() if (forceRefresh) { // 这里可以通过一个新的API来触发刷新,但目前我们依赖patch_profile中的刷新 console.log(`强制刷新定时器任务`); } - + const nextUpdate = await getNextUpdateTime(itemData.uid); console.log(`获取到下次更新时间结果:`, nextUpdate); - + if (nextUpdate) { const nextUpdateDate = dayjs(nextUpdate * 1000); const now = dayjs(); - + // 如果已经过期,显示"更新失败" if (nextUpdateDate.isBefore(now)) { setNextUpdateTime(t("Last Update failed")); } else { // 否则显示剩余时间 const diffMinutes = nextUpdateDate.diff(now, 'minute'); - + if (diffMinutes < 60) { if (diffMinutes <= 0) { setNextUpdateTime(`${t("Next Up")} <1m`); @@ -128,11 +128,11 @@ export const ProfileItem = (props: Props) => { // 切换显示模式的函数 const toggleUpdateTimeDisplay = (e: React.MouseEvent) => { e.stopPropagation(); - + if (!showNextUpdate) { fetchNextUpdateTime(); } - + setShowNextUpdate(!showNextUpdate); }; @@ -148,7 +148,7 @@ export const ProfileItem = (props: Props) => { // 处理定时器更新事件 - 这个事件专门用于通知定时器变更 const handleTimerUpdate = (event: any) => { const updatedUid = event.payload as string; - + // 只有当更新的是当前配置时才刷新显示 if (updatedUid === itemData.uid && showNextUpdate) { console.log(`收到定时器更新事件: uid=${updatedUid}`); @@ -300,7 +300,7 @@ export const ProfileItem = (props: Props) => { try { // 调用后端更新(后端会自动处理回退逻辑) await updateProfile(itemData.uid, option); - + // 更新成功,刷新列表 showNotice('success', t("Update subscription successfully")); mutate("getProfiles"); @@ -345,7 +345,7 @@ export const ProfileItem = (props: Props) => { }, { label: "Open File", handler: onOpenFile, disabled: false }, { label: "Update", handler: () => onUpdate(0), disabled: false }, - { label: "Update(Proxy)", handler: () => onUpdate(2), disabled: false }, + { label: "Update via proxy", handler: () => onUpdate(2), disabled: false }, { label: "Delete", handler: () => { @@ -548,7 +548,7 @@ export const ProfileItem = (props: Props) => { fontSize={14} textAlign="right" title={showNextUpdate ? t("Click to show last update time") : `${t("Update Time")}: ${parseExpire(updated)}\n${t("Click to show next update")}`} - sx={{ + sx={{ cursor: "pointer", display: "inline-block", borderBottom: "1px dashed transparent", @@ -560,7 +560,7 @@ export const ProfileItem = (props: Props) => { }} onClick={toggleUpdateTimeDisplay} > - {showNextUpdate + {showNextUpdate ? nextUpdateTime : (updated > 0 ? dayjs(updated * 1000).fromNow() : "")} diff --git a/src/locales/en.json b/src/locales/en.json index 1958635e..e8ab7f23 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -153,6 +153,7 @@ "Edit File": "Edit File", "Open File": "Open File", "Update": "Update", + "Update via proxy": "Update via proxy", "Confirm deletion": "Confirm deletion", "This operation is not reversible": "This operation is not reversible", "Script Console": "Script Console", diff --git a/src/locales/zh.json b/src/locales/zh.json index f2e6111a..02e1fc22 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -153,6 +153,7 @@ "Edit File": "编辑文件", "Open File": "打开文件", "Update": "更新", + "Update via proxy": "更新(通过代理)", "Confirm deletion": "确认删除", "This operation is not reversible": "此操作不可逆", "Script Console": "脚本控制台输出",