From a69d24b29c24ccb1785c89e1e55c303d9c5ea13a Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Tue, 4 Feb 2025 11:04:15 +0800 Subject: [PATCH] fix: profiles cannot click --- src/renderer/src/App.tsx | 8 +- .../src/components/profiles/profile-item.tsx | 259 +++++++++--------- .../src/components/proxies/proxy-item.tsx | 167 ++++++----- src/renderer/src/pages/profiles.tsx | 2 +- src/renderer/src/pages/proxies.tsx | 215 +++++++-------- 5 files changed, 322 insertions(+), 329 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index de19b56..a2dc6ba 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -80,11 +80,13 @@ const App: React.FC = () => { const location = useLocation() const page = useRoutes(routes) const setTitlebar = (): void => { - if (!useWindowFrame && platform !== 'darwin') { + if (!useWindowFrame) { const options = { height: 48 } as TitleBarOverlayOptions try { - options.color = window.getComputedStyle(document.documentElement).backgroundColor - options.symbolColor = window.getComputedStyle(document.documentElement).color + if (platform !== 'darwin') { + options.color = window.getComputedStyle(document.documentElement).backgroundColor + options.symbolColor = window.getComputedStyle(document.documentElement).color + } setTitleBarOverlay(options) } catch (e) { // ignore diff --git a/src/renderer/src/components/profiles/profile-item.tsx b/src/renderer/src/components/profiles/profile-item.tsx index 73f9f07..f831521 100644 --- a/src/renderer/src/components/profiles/profile-item.tsx +++ b/src/renderer/src/components/profiles/profile-item.tsx @@ -30,7 +30,7 @@ interface Props { updateProfileItem: (item: IProfileItem) => Promise removeProfileItem: (id: string) => Promise mutateProfileConfig: () => void - onClick: () => Promise + onPress: () => Promise } interface MenuItem { @@ -48,7 +48,7 @@ const ProfileItem: React.FC = (props) => { removeProfileItem, mutateProfileConfig, updateProfileItem, - onClick, + onPress, isCurrent } = props const extra = info?.extra @@ -175,149 +175,146 @@ const ProfileItem: React.FC = (props) => { )} { + if (disableSelect) return + setSelecting(true) + onPress().finally(() => { + setSelecting(false) + }) + }} className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`} > -
{ - if (disableSelect) return - setSelecting(true) - onClick().finally(() => { - setSelecting(false) - }) - }} - > -
- -
-

- {info?.name} -

-
- {info.type === 'remote' && ( - - - - )} + className={`${isCurrent ? 'text-primary-foreground' : 'text-foreground'} text-[24px] ${updating ? 'animate-spin' : ''}`} + /> + + + )} - - - - - - {menuItems.map((item) => ( - - {item.label} - - ))} - - -
+ + + + + + {menuItems.map((item) => ( + + {item.label} + + ))} + +
- {info.type === 'remote' && extra && ( -
- {`${calcTraffic(usage)}/${calcTraffic(total)}`} - {profileDisplayDate === 'expire' ? ( - - ) : ( - - )} -
- )} -
- - {info.type === 'remote' && !extra && ( -
- + {info.type === 'remote' && extra && ( +
+ {`${calcTraffic(usage)}/${calcTraffic(total)}`} + {profileDisplayDate === 'expire' ? ( + + ) : ( + + )} +
+ )} + + + {info.type === 'remote' && !extra && ( +
+ {t('profiles.remote')} - - {dayjs(info.updated).fromNow()} -
- )} - {info.type === 'local' && ( -
+ {dayjs(info.updated).fromNow()} +
+ )} + {info.type === 'local' && ( +
+ - {t('profiles.local')} - -
- )} - {extra && ( - +
+ )} + {extra && ( + - )} -
-
+ classNames={{ + indicator: isCurrent ? 'bg-primary-foreground' : 'bg-foreground' + }} + value={calcPercent(extra?.upload, extra?.download, extra?.total)} + /> + )} +
) } -export default ProfileItem +export default ProfileItem \ No newline at end of file diff --git a/src/renderer/src/components/proxies/proxy-item.tsx b/src/renderer/src/components/proxies/proxy-item.tsx index 627a7b5..ac6cd71 100644 --- a/src/renderer/src/components/proxies/proxy-item.tsx +++ b/src/renderer/src/components/proxies/proxy-item.tsx @@ -51,6 +51,8 @@ const ProxyItem: React.FC = (props) => { return ( onSelect(group.name, proxy.name)} + isPressable fullWidth shadow="sm" className={`${ @@ -62,100 +64,95 @@ const ProxyItem: React.FC = (props) => { }`} radius="sm" > -
onSelect(group.name, proxy.name)} - className="cursor-pointer" - > - - {proxyDisplayMode === 'full' ? ( -
-
-
- {proxy.name} -
- {fixed && ( - - )} + + {proxyDisplayMode === 'full' ? ( +
+
+
+ {proxy.name}
-
-
-
- {proxy.type} -
- {['tfo', 'udp', 'xudp', 'mptcp', 'smux'].map(protocol => - proxy[protocol as keyof IMihomoProxy] && ( -
- {protocol} -
- ) - )} -
+ {fixed && ( -
-
- ) : ( -
-
-
- {proxy.name} -
-
-
- {fixed && ( - - )} - -
+ )}
- )} - -
+
+
+
+ {proxy.type} +
+ {['tfo', 'udp', 'xudp', 'mptcp', 'smux'].map(protocol => + proxy[protocol as keyof IMihomoProxy] && ( +
+ {protocol} +
+ ) + )} +
+ +
+
+ ) : ( +
+
+
+ {proxy.name} +
+
+
+ {fixed && ( + + )} + +
+
+ )} + ) } -export default ProxyItem +export default ProxyItem \ No newline at end of file diff --git a/src/renderer/src/pages/profiles.tsx b/src/renderer/src/pages/profiles.tsx index 0e73f93..65a659e 100644 --- a/src/renderer/src/pages/profiles.tsx +++ b/src/renderer/src/pages/profiles.tsx @@ -395,7 +395,7 @@ const Profiles: React.FC = () => { mutateProfileConfig={mutateProfileConfig} updateProfileItem={updateProfileItem} info={item} - onClick={async () => { + onPress={async () => { await changeCurrentProfile(item.id) }} /> diff --git a/src/renderer/src/pages/proxies.tsx b/src/renderer/src/pages/proxies.tsx index ac2a5c2..a9ed965 100644 --- a/src/renderer/src/pages/proxies.tsx +++ b/src/renderer/src/pages/proxies.tsx @@ -329,121 +329,118 @@ const Proxies: React.FC = () => { className={`w-full pt-2 ${index === groupCounts.length - 1 && !isOpen[index] ? 'pb-2' : ''} px-2`} > { + setIsOpen((prev) => { + const newOpen = [...prev] + newOpen[index] = !prev[index] + return newOpen + }) + }} > -
{ - setIsOpen((prev) => { - const newOpen = [...prev] - newOpen[index] = !prev[index] - return newOpen - }) - }} - className="cursor-pointer" - > - -
-
- {groups[index].icon ? ( - - ) : null} -
-
- {groups[index].name} -
- {proxyDisplayMode === 'full' && ( -
- {groups[index].type} -
- )} - {proxyDisplayMode === 'full' && ( -
- {groups[index].now} -
- )} + +
+
+ {groups[index].icon ? ( + + ) : null} +
+
+ {groups[index].name}
-
-
{proxyDisplayMode === 'full' && ( - - {groups[index].all.length} - +
+ {groups[index].type} +
+ )} + {proxyDisplayMode === 'full' && ( +
+ {groups[index].now} +
)} - { - setSearchValue((prev) => { - const newSearchValue = [...prev] - newSearchValue[index] = v - return newSearchValue - }) - }} - /> - - -
- -
+
+ {proxyDisplayMode === 'full' && ( + + {groups[index].all.length} + + )} + { + setSearchValue((prev) => { + const newSearchValue = [...prev] + newSearchValue[index] = v + return newSearchValue + }) + }} + /> + + + +
+
+
) : ( @@ -494,4 +491,4 @@ const Proxies: React.FC = () => { ) } -export default Proxies +export default Proxies \ No newline at end of file