From b1e39ab4b36fb1732c265df2a9e39c6e514f41e6 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Thu, 10 Oct 2024 20:36:23 +0800 Subject: [PATCH] fix select profile #223 --- .../src/components/override/override-item.tsx | 153 ++++++------ .../src/components/profiles/profile-item.tsx | 231 +++++++++--------- .../src/components/sider/profile-card.tsx | 24 +- 3 files changed, 213 insertions(+), 195 deletions(-) diff --git a/src/renderer/src/components/override/override-item.tsx b/src/renderer/src/components/override/override-item.tsx index 8d4622b..b836a51 100644 --- a/src/renderer/src/components/override/override-item.tsx +++ b/src/renderer/src/components/override/override-item.tsx @@ -167,86 +167,85 @@ const OverrideItem: React.FC = (props) => { setOpenFileEditor(true) }} > - -
-

- {info?.name} -

-
- {info.type === 'remote' && ( - - )} - - - - - - - {menuItems.map((item) => ( - - {item.label} - - ))} - - -
-
-
-
- {info.global && ( - - 全局 - - )} - - {info.type === 'local' ? '本地' : '远程'} - - - {info.ext === 'yaml' ? 'YAML' : 'JavaScript'} - -
- {info.type === 'remote' && ( -
- {dayjs(info.updated).fromNow()} + )} + + + + + + + {menuItems.map((item) => ( + + {item.label} + + ))} + +
- )} -
-
+ +
+
+ {info.global && ( + + 全局 + + )} + + {info.type === 'local' ? '本地' : '远程'} + + + {info.ext === 'yaml' ? 'YAML' : 'JavaScript'} + +
+ {info.type === 'remote' && ( +
+ {dayjs(info.updated).fromNow()} +
+ )} +
+ + ) diff --git a/src/renderer/src/components/profiles/profile-item.tsx b/src/renderer/src/components/profiles/profile-item.tsx index 36c66a7..1b69dcf 100644 --- a/src/renderer/src/components/profiles/profile-item.tsx +++ b/src/renderer/src/components/profiles/profile-item.tsx @@ -174,7 +174,7 @@ const ProfileItem: React.FC = (props) => { { + onPress={() => { if (disableSelect) return setSelecting(true) onClick().finally(() => { @@ -183,129 +183,132 @@ const ProfileItem: React.FC = (props) => { }} className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`} > - -
-

- {info?.name} -

-
- {info.type === 'remote' && ( - +
+ +
+

+ {info?.name} +

+
+ {info.type === 'remote' && ( + + + + )} + + + + + + + {menuItems.map((item) => ( + + {item.label} + + ))} + + +
+
+ {info.type === 'remote' && extra && ( +
+ {`${calcTraffic(usage)}/${calcTraffic(total)}`} + {profileDisplayDate === 'expire' ? ( - - )} - - - - - - - {menuItems.map((item) => ( - - {item.label} - - ))} - - -
-
- {info.type === 'remote' && extra && ( -
- {`${calcTraffic(usage)}/${calcTraffic(total)}`} - {profileDisplayDate === 'expire' ? ( - { - e.stopPropagation() - patchAppConfig({ profileDisplayDate: 'update' }) - }} - > - {extra.expire ? dayjs.unix(extra.expire).format('YYYY-MM-DD') : '长期有效'} - - ) : ( - { - e.stopPropagation() - patchAppConfig({ profileDisplayDate: 'expire' }) - }} - > - {dayjs(info.updated).fromNow()} - - )} -
- )} - - - {info.type === 'remote' && !extra && ( -
- + )} + + + {info.type === 'remote' && !extra && ( +
- 远程 - - {dayjs(info.updated).fromNow()} -
- )} - {info.type === 'local' && ( -
- + 远程 + + {dayjs(info.updated).fromNow()} +
+ )} + {info.type === 'local' && ( +
- 本地 - -
- )} - {extra && ( - - )} -
+ + 本地 + +
+ )} + {extra && ( + + )} +
+
) diff --git a/src/renderer/src/components/sider/profile-card.tsx b/src/renderer/src/components/sider/profile-card.tsx index b3369f4..94f3da9 100644 --- a/src/renderer/src/components/sider/profile-card.tsx +++ b/src/renderer/src/components/sider/profile-card.tsx @@ -18,7 +18,7 @@ dayjs.extend(relativeTime) dayjs.locale('zh-cn') const ProfileCard: React.FC = () => { - const { appConfig } = useAppConfig() + const { appConfig, patchAppConfig } = useAppConfig() const { profileCardStatus = 'col-span-2', profileDisplayDate = 'expire' } = appConfig || {} const location = useLocation() const match = location.pathname.includes('/profiles') @@ -122,11 +122,27 @@ const ProfileCard: React.FC = () => { > {`${calcTraffic(usage)}/${calcTraffic(total)}`} {profileDisplayDate === 'expire' ? ( - + ) : ( - {dayjs(info.updated).fromNow()} + )} )}