fix styles

This commit is contained in:
pompurin404 2024-08-06 11:00:39 +08:00
parent a93a4151e4
commit 15dd29c0f8
No known key found for this signature in database
10 changed files with 38 additions and 13 deletions

View File

@ -67,6 +67,7 @@ export function registerIpcMainHandlers(): void {
ipcMain.handle('isEncryptionAvailable', isEncryptionAvailable) ipcMain.handle('isEncryptionAvailable', isEncryptionAvailable)
ipcMain.handle('encryptString', (_e, str) => safeStorage.encryptString(str)) ipcMain.handle('encryptString', (_e, str) => safeStorage.encryptString(str))
ipcMain.handle('checkUpdate', () => checkUpdate()) ipcMain.handle('checkUpdate', () => checkUpdate())
ipcMain.handle('getVersion', () => app.getVersion())
ipcMain.handle('platform', () => process.platform) ipcMain.handle('platform', () => process.platform)
ipcMain.handle('quitApp', () => app.quit()) ipcMain.handle('quitApp', () => app.quit())
} }

View File

@ -47,6 +47,7 @@ const ProfileItem: React.FC<Props> = (props) => {
const usage = (extra?.upload ?? 0) + (extra?.download ?? 0) const usage = (extra?.upload ?? 0) + (extra?.download ?? 0)
const total = extra?.total ?? 0 const total = extra?.total ?? 0
const [updating, setUpdating] = useState(false) const [updating, setUpdating] = useState(false)
const [selecting, setSelecting] = useState(false)
const [openInfo, setOpenInfo] = useState(false) const [openInfo, setOpenInfo] = useState(false)
const [openFile, setOpenFile] = useState(false) const [openFile, setOpenFile] = useState(false)
@ -119,7 +120,17 @@ const ProfileItem: React.FC<Props> = (props) => {
updateProfileItem={updateProfileItem} updateProfileItem={updateProfileItem}
/> />
)} )}
<Card fullWidth isPressable onPress={onClick} className={isCurrent ? 'bg-primary' : ''}> <Card
fullWidth
isPressable
onPress={() => {
setSelecting(true)
onClick().finally(() => {
setSelecting(false)
})
}}
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
>
<CardBody className="pb-1"> <CardBody className="pb-1">
<div className="flex justify-between h-[32px]"> <div className="flex justify-between h-[32px]">
<h3 <h3
@ -171,7 +182,7 @@ const ProfileItem: React.FC<Props> = (props) => {
</div> </div>
</div> </div>
<div <div
className={`mt-2 flex justify-between ${isCurrent ? 'text-white' : 'text-foreground'}`} className={`mt-2 flex select-none justify-between ${isCurrent ? 'text-white' : 'text-foreground'}`}
> >
<small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small> <small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small>
<small>{dayjs(info.updated).fromNow()}</small> <small>{dayjs(info.updated).fromNow()}</small>

View File

@ -62,7 +62,7 @@ const ProxyItem: React.FC<Props> = (props) => {
radius="sm" radius="sm"
> >
<CardBody className="p-2"> <CardBody className="p-2">
<div className="flex justify-between items-center"> <div className="flex select-none justify-between items-center">
<div> <div>
<div className="inline text-ellipsis whitespace-nowrap overflow-hidden"> <div className="inline text-ellipsis whitespace-nowrap overflow-hidden">
{proxy.name} {proxy.name}

View File

@ -60,7 +60,9 @@ const ProfileCard: React.FC = () => {
/> />
</Button> </Button>
</div> </div>
<div className={`mt-2 flex justify-between ${match ? 'text-white' : 'text-foreground'} `}> <div
className={`mt-2 flex select-none justify-between ${match ? 'text-white' : 'text-foreground'} `}
>
<small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small> <small>{extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined}</small>
<small>{dayjs(info.updated).fromNow()}</small> <small>{dayjs(info.updated).fromNow()}</small>
</div> </div>

View File

@ -39,11 +39,11 @@ const ProxyCard: React.FC = () => {
match match
? { ? {
base: 'border-white', base: 'border-white',
content: 'text-white' content: 'text-white select-none'
} }
: { : {
base: 'border-primary', base: 'border-primary',
content: 'text-primary' content: 'text-primary select-none'
} }
} }
size="sm" size="sm"

View File

@ -36,11 +36,11 @@ const RuleCard: React.FC = () => {
match match
? { ? {
base: 'border-white', base: 'border-white',
content: 'text-white' content: 'text-white select-none'
} }
: { : {
base: 'border-primary', base: 'border-primary',
content: 'text-primary' content: 'text-primary select-none'
} }
} }
size="sm" size="sm"

View File

@ -158,7 +158,7 @@ const Proxies: React.FC = () => {
src={groups[index].icon} src={groups[index].icon}
/> />
) : null} ) : null}
<div className="h-[32px] text-ellipsis whitespace-nowrap overflow-hidden text-md leading-[32px]"> <div className="h-[32px] select-none text-ellipsis whitespace-nowrap overflow-hidden text-md leading-[32px]">
{groups[index].name} {groups[index].name}
{proxyDisplayMode === 'full' && ( {proxyDisplayMode === 'full' && (
<> <>
@ -174,7 +174,7 @@ const Proxies: React.FC = () => {
</div> </div>
<div className="flex "> <div className="flex ">
{proxyDisplayMode === 'full' && ( {proxyDisplayMode === 'full' && (
<Chip size="sm" className="my-1 mr-2"> <Chip size="sm" className="my-1 mr-2 select-none">
{groups[index].all.length} {groups[index].all.length}
</Chip> </Chip>
)} )}

View File

@ -11,7 +11,7 @@ import {
checkUpdate checkUpdate
} from '@renderer/utils/ipc' } from '@renderer/utils/ipc'
import { IoLogoGithub } from 'react-icons/io5' import { IoLogoGithub } from 'react-icons/io5'
import { version } from '@renderer/utils/init'
import useSWR from 'swr' import useSWR from 'swr'
const Settings: React.FC = () => { const Settings: React.FC = () => {
@ -108,11 +108,16 @@ const Settings: React.FC = () => {
(): void => { (): void => {
open(`https://github.com/pompurin404/mihomo-party/releases/tag/v${v}`) open(`https://github.com/pompurin404/mihomo-party/releases/tag/v${v}`)
} }
} else {
new window.Notification('当前已是最新版本', { body: '无需更新' })
} }
}) })
}} }}
/> />
<SettingItem title="退出应用" onPress={quitApp} /> <SettingItem title="退出应用" onPress={quitApp} divider />
<SettingItem title="应用版本">
<div className="select-none">v{version}</div>
</SettingItem>
</SettingCard> </SettingCard>
</BasePage> </BasePage>
) )

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { getPlatform } from './ipc' import { getPlatform, getVersion } from './ipc'
const originError = console.error const originError = console.error
const originWarn = console.warn const originWarn = console.warn
console.error = function (...args: any[]): void { console.error = function (...args: any[]): void {
@ -17,7 +17,9 @@ console.warn = function (...args): void {
} }
export let platform: NodeJS.Platform export let platform: NodeJS.Platform
export let version: string
export async function init(): Promise<void> { export async function init(): Promise<void> {
platform = await getPlatform() platform = await getPlatform()
version = await getVersion()
} }

View File

@ -131,6 +131,10 @@ export async function checkUpdate(): Promise<string | undefined> {
return await window.electron.ipcRenderer.invoke('checkUpdate') return await window.electron.ipcRenderer.invoke('checkUpdate')
} }
export async function getVersion(): Promise<string> {
return await window.electron.ipcRenderer.invoke('getVersion')
}
export async function getPlatform(): Promise<NodeJS.Platform> { export async function getPlatform(): Promise<NodeJS.Platform> {
return await window.electron.ipcRenderer.invoke('platform') return await window.electron.ipcRenderer.invoke('platform')
} }