This commit is contained in:
pompurin404 2024-08-25 20:01:31 +08:00
parent 334f718f72
commit de057e5175
No known key found for this signature in database
3 changed files with 19 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "mihomo-party", "name": "mihomo-party",
"version": "1.0.4", "version": "1.0.5",
"description": "Mihomo Party", "description": "Mihomo Party",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "mihomo-party", "author": "mihomo-party",

View File

@ -16,7 +16,7 @@ import { createElevateTask } from './sys/misc'
export let mainWindow: BrowserWindow | null = null export let mainWindow: BrowserWindow | null = null
if (process.platform === 'win32') { if (process.platform === 'win32' && !is.dev) {
try { try {
createElevateTask() createElevateTask()
} catch (e) { } catch (e) {

View File

@ -61,7 +61,7 @@ const Proxies: React.FC = () => {
}) })
return { groupCounts, allProxies } return { groupCounts, allProxies }
}, [groups, isOpen, proxyDisplayOrder]) }, [groups, isOpen, proxyDisplayOrder, cols])
const onChangeProxy = async (group: string, proxy: string): Promise<void> => { const onChangeProxy = async (group: string, proxy: string): Promise<void> => {
await mihomoChangeProxy(group, proxy) await mihomoChangeProxy(group, proxy)
@ -80,18 +80,15 @@ const Proxies: React.FC = () => {
await mihomoGroupDelay(group, url) await mihomoGroupDelay(group, url)
} }
const calcCols = (): void => { const calcCols = (): number => {
if (window.innerWidth >= 1280) { if (window.matchMedia('(min-width: 1536px)').matches) {
setCols(4) return 5
return } else if (window.matchMedia('(min-width: 1280px)').matches) {
} return 4
if (window.innerWidth >= 1024) { } else if (window.matchMedia('(min-width: 1024px)').matches) {
setCols(3) return 3
return } else {
} return 2
if (window.innerWidth >= 768) {
setCols(2)
return
} }
} }
@ -100,8 +97,10 @@ const Proxies: React.FC = () => {
setCols(parseInt(proxyCols)) setCols(parseInt(proxyCols))
return return
} }
calcCols() setCols(calcCols())
window.onresize = calcCols window.onresize = (): void => {
setCols(calcCols())
}
return (): void => { return (): void => {
window.onresize = null window.onresize = null
} }
@ -259,7 +258,9 @@ const Proxies: React.FC = () => {
innerIndex -= count innerIndex -= count
}) })
return allProxies[groupIndex] ? ( return allProxies[groupIndex] ? (
<div className={`grid grid-cols-${cols} gap-2 pt-2 mx-2`}> <div
className={`grid ${proxyCols === 'auto' ? 'sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5' : `grid-cols-${cols}`} gap-2 pt-2 mx-2`}
>
{Array.from({ length: cols }).map((_, i) => { {Array.from({ length: cols }).map((_, i) => {
if (!allProxies[groupIndex][innerIndex * cols + i]) return null if (!allProxies[groupIndex][innerIndex * cols + i]) return null
return ( return (