Skip to content

Commit 18ef4a9

Browse files
author
Pompurin404
committed
fix styles
1 parent 32c0c84 commit 18ef4a9

File tree

10 files changed

+38
-13
lines changed

10 files changed

+38
-13
lines changed

src/main/utils/ipc.ts

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export function registerIpcMainHandlers(): void {
6767
ipcMain.handle('isEncryptionAvailable', isEncryptionAvailable)
6868
ipcMain.handle('encryptString', (_e, str) => safeStorage.encryptString(str))
6969
ipcMain.handle('checkUpdate', () => checkUpdate())
70+
ipcMain.handle('getVersion', () => app.getVersion())
7071
ipcMain.handle('platform', () => process.platform)
7172
ipcMain.handle('quitApp', () => app.quit())
7273
}

src/renderer/src/components/profiles/profile-item.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const ProfileItem: React.FC<Props> = (props) => {
4747
const usage = (extra?.upload ?? 0) + (extra?.download ?? 0)
4848
const total = extra?.total ?? 0
4949
const [updating, setUpdating] = useState(false)
50+
const [selecting, setSelecting] = useState(false)
5051
const [openInfo, setOpenInfo] = useState(false)
5152
const [openFile, setOpenFile] = useState(false)
5253

@@ -119,7 +120,17 @@ const ProfileItem: React.FC<Props> = (props) => {
119120
updateProfileItem={updateProfileItem}
120121
/>
121122
)}
122-
<Card fullWidth isPressable onPress={onClick} className={isCurrent ? 'bg-primary' : ''}>
123+
<Card
124+
fullWidth
125+
isPressable
126+
onPress={() => {
127+
setSelecting(true)
128+
onClick().finally(() => {
129+
setSelecting(false)
130+
})
131+
}}
132+
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
133+
>
123134
<CardBody className="pb-1">
124135
<div className="flex justify-between h-[32px]">
125136
<h3
@@ -171,7 +182,7 @@ const ProfileItem: React.FC<Props> = (props) => {
171182
</div>
172183
</div>
173184
<div
174-
className={`mt-2 flex justify-between ${isCurrent ? 'text-white' : 'text-foreground'}`}
185+
className={`mt-2 flex select-none justify-between ${isCurrent ? 'text-white' : 'text-foreground'}`}
175186
>
176187
<small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small>
177188
<small>{dayjs(info.updated).fromNow()}</small>

src/renderer/src/components/proxies/proxy-item.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const ProxyItem: React.FC<Props> = (props) => {
6262
radius="sm"
6363
>
6464
<CardBody className="p-2">
65-
<div className="flex justify-between items-center">
65+
<div className="flex select-none justify-between items-center">
6666
<div>
6767
<div className="inline text-ellipsis whitespace-nowrap overflow-hidden">
6868
{proxy.name}

src/renderer/src/components/sider/profile-card.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ const ProfileCard: React.FC = () => {
6060
/>
6161
</Button>
6262
</div>
63-
<div className={`mt-2 flex justify-between ${match ? 'text-white' : 'text-foreground'} `}>
63+
<div
64+
className={`mt-2 flex select-none justify-between ${match ? 'text-white' : 'text-foreground'} `}
65+
>
6466
<small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small>
6567
<small>{dayjs(info.updated).fromNow()}</small>
6668
</div>

src/renderer/src/components/sider/proxy-card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ const ProxyCard: React.FC = () => {
3939
match
4040
? {
4141
base: 'border-white',
42-
content: 'text-white'
42+
content: 'text-white select-none'
4343
}
4444
: {
4545
base: 'border-primary',
46-
content: 'text-primary'
46+
content: 'text-primary select-none'
4747
}
4848
}
4949
size="sm"

src/renderer/src/components/sider/rule-card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ const RuleCard: React.FC = () => {
3636
match
3737
? {
3838
base: 'border-white',
39-
content: 'text-white'
39+
content: 'text-white select-none'
4040
}
4141
: {
4242
base: 'border-primary',
43-
content: 'text-primary'
43+
content: 'text-primary select-none'
4444
}
4545
}
4646
size="sm"

src/renderer/src/pages/proxies.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const Proxies: React.FC = () => {
158158
src={groups[index].icon}
159159
/>
160160
) : null}
161-
<div className="h-[32px] text-ellipsis whitespace-nowrap overflow-hidden text-md leading-[32px]">
161+
<div className="h-[32px] select-none text-ellipsis whitespace-nowrap overflow-hidden text-md leading-[32px]">
162162
{groups[index].name}
163163
{proxyDisplayMode === 'full' && (
164164
<>
@@ -174,7 +174,7 @@ const Proxies: React.FC = () => {
174174
</div>
175175
<div className="flex ">
176176
{proxyDisplayMode === 'full' && (
177-
<Chip size="sm" className="my-1 mr-2">
177+
<Chip size="sm" className="my-1 mr-2 select-none">
178178
{groups[index].all.length}
179179
</Chip>
180180
)}

src/renderer/src/pages/settings.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
checkUpdate
1212
} from '@renderer/utils/ipc'
1313
import { IoLogoGithub } from 'react-icons/io5'
14-
14+
import { version } from '@renderer/utils/init'
1515
import useSWR from 'swr'
1616

1717
const Settings: React.FC = () => {
@@ -108,11 +108,16 @@ const Settings: React.FC = () => {
108108
(): void => {
109109
open(`https://github.com/pompurin404/mihomo-party/releases/tag/v${v}`)
110110
}
111+
} else {
112+
new window.Notification('当前已是最新版本', { body: '无需更新' })
111113
}
112114
})
113115
}}
114116
/>
115-
<SettingItem title="退出应用" onPress={quitApp} />
117+
<SettingItem title="退出应用" onPress={quitApp} divider />
118+
<SettingItem title="应用版本">
119+
<div className="select-none">v{version}</div>
120+
</SettingItem>
116121
</SettingCard>
117122
</BasePage>
118123
)

src/renderer/src/utils/init.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

3-
import { getPlatform } from './ipc'
3+
import { getPlatform, getVersion } from './ipc'
44
const originError = console.error
55
const originWarn = console.warn
66
console.error = function (...args: any[]): void {
@@ -17,7 +17,9 @@ console.warn = function (...args): void {
1717
}
1818

1919
export let platform: NodeJS.Platform
20+
export let version: string
2021

2122
export async function init(): Promise<void> {
2223
platform = await getPlatform()
24+
version = await getVersion()
2325
}

src/renderer/src/utils/ipc.ts

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export async function checkUpdate(): Promise<string | undefined> {
131131
return await window.electron.ipcRenderer.invoke('checkUpdate')
132132
}
133133

134+
export async function getVersion(): Promise<string> {
135+
return await window.electron.ipcRenderer.invoke('getVersion')
136+
}
137+
134138
export async function getPlatform(): Promise<NodeJS.Platform> {
135139
return await window.electron.ipcRenderer.invoke('platform')
136140
}

0 commit comments

Comments
 (0)