fix: remove nested button element in NextUI Card component

This commit is contained in:
pompurin404 2025-02-03 07:30:33 +08:00
parent e746ab4241
commit 77b67849ed
7 changed files with 1477 additions and 952 deletions

View File

@ -26,6 +26,7 @@
"@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0", "@electron-toolkit/utils": "^3.0.0",
"@mihomo-party/sysproxy": "^2.0.7", "@mihomo-party/sysproxy": "^2.0.7",
"@mihomo-party/sysproxy-darwin-arm64": "^2.0.7",
"@nextui-org/react": "2.6.10", "@nextui-org/react": "2.6.10",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"adm-zip": "^0.5.16", "adm-zip": "^0.5.16",
@ -57,7 +58,7 @@
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"cron-validator": "^1.3.1", "cron-validator": "^1.3.1",
"driver.js": "^1.3.1", "driver.js": "^1.3.1",
"electron": "^33.1.0", "electron": "^33.3.2",
"electron-builder": "25.0.4", "electron-builder": "25.0.4",
"electron-vite": "^2.3.0", "electron-vite": "^2.3.0",
"electron-window-state": "^5.0.3", "electron-window-state": "^5.0.3",
@ -90,5 +91,6 @@
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vite": "^6.0.7", "vite": "^6.0.7",
"vite-plugin-monaco-editor": "^1.1.0" "vite-plugin-monaco-editor": "^1.1.0"
} },
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
} }

1777
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -221,7 +221,8 @@ export async function createWindow(): Promise<void> {
webPreferences: { webPreferences: {
preload: join(__dirname, '../preload/index.js'), preload: join(__dirname, '../preload/index.js'),
spellcheck: false, spellcheck: false,
sandbox: false sandbox: false,
devTools: true
} }
}) })
mainWindowState.manage(mainWindow) mainWindowState.manage(mainWindow)
@ -282,6 +283,12 @@ export async function createWindow(): Promise<void> {
shell.openExternal(details.url) shell.openExternal(details.url)
return { action: 'deny' } return { action: 'deny' }
}) })
// 在开发模式下自动打开 DevTools
if (is.dev) {
mainWindow.webContents.openDevTools()
}
// HMR for renderer base on electron-vite cli. // HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production. // Load the remote URL for development or the local html file for production.
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { if (is.dev && process.env['ELECTRON_RENDERER_URL']) {

View File

@ -73,13 +73,11 @@ const App: React.FC = () => {
const location = useLocation() const location = useLocation()
const page = useRoutes(routes) const page = useRoutes(routes)
const setTitlebar = (): void => { const setTitlebar = (): void => {
if (!useWindowFrame) { if (!useWindowFrame && platform !== 'darwin') {
const options = { height: 48 } as TitleBarOverlayOptions const options = { height: 48 } as TitleBarOverlayOptions
try { try {
if (platform !== 'darwin') {
options.color = window.getComputedStyle(document.documentElement).backgroundColor options.color = window.getComputedStyle(document.documentElement).backgroundColor
options.symbolColor = window.getComputedStyle(document.documentElement).color options.symbolColor = window.getComputedStyle(document.documentElement).color
}
setTitleBarOverlay(options) setTitleBarOverlay(options)
} catch (e) { } catch (e) {
// ignore // ignore

View File

@ -173,15 +173,17 @@ const ProfileItem: React.FC<Props> = (props) => {
)} )}
<Card <Card
fullWidth fullWidth
isPressable className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
onPress={() => { >
<div
className="w-full h-full cursor-pointer"
onClick={() => {
if (disableSelect) return if (disableSelect) return
setSelecting(true) setSelecting(true)
onClick().finally(() => { onClick().finally(() => {
setSelecting(false) setSelecting(false)
}) })
}} }}
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
> >
<div ref={setNodeRef} {...attributes} {...listeners} className="w-full h-full"> <div ref={setNodeRef} {...attributes} {...listeners} className="w-full h-full">
<CardBody className="pb-1"> <CardBody className="pb-1">
@ -309,6 +311,7 @@ const ProfileItem: React.FC<Props> = (props) => {
)} )}
</CardFooter> </CardFooter>
</div> </div>
</div>
</Card> </Card>
</div> </div>
) )

View File

@ -49,8 +49,6 @@ const ProxyItem: React.FC<Props> = (props) => {
return ( return (
<Card <Card
onPress={() => onSelect(group.name, proxy.name)}
isPressable
fullWidth fullWidth
shadow="sm" shadow="sm"
className={`${ className={`${
@ -61,6 +59,10 @@ const ProxyItem: React.FC<Props> = (props) => {
: 'bg-content2' : 'bg-content2'
}`} }`}
radius="sm" radius="sm"
>
<div
onClick={() => onSelect(group.name, proxy.name)}
className="cursor-pointer"
> >
<CardBody className="p-1"> <CardBody className="p-1">
{proxyDisplayMode === 'full' ? ( {proxyDisplayMode === 'full' ? (
@ -149,6 +151,7 @@ const ProxyItem: React.FC<Props> = (props) => {
</div> </div>
)} )}
</CardBody> </CardBody>
</div>
</Card> </Card>
) )
} }

View File

@ -327,15 +327,17 @@ const Proxies: React.FC = () => {
className={`w-full pt-2 ${index === groupCounts.length - 1 && !isOpen[index] ? 'pb-2' : ''} px-2`} className={`w-full pt-2 ${index === groupCounts.length - 1 && !isOpen[index] ? 'pb-2' : ''} px-2`}
> >
<Card <Card
isPressable
fullWidth fullWidth
onClick={() => { >
<div
onClick={(): void => {
setIsOpen((prev) => { setIsOpen((prev) => {
const newOpen = [...prev] const newOpen = [...prev]
newOpen[index] = !prev[index] newOpen[index] = !prev[index]
return newOpen return newOpen
}) })
}} }}
className="cursor-pointer"
> >
<CardBody className="w-full"> <CardBody className="w-full">
<div className="flex justify-between"> <div className="flex justify-between">
@ -439,6 +441,7 @@ const Proxies: React.FC = () => {
</div> </div>
</div> </div>
</CardBody> </CardBody>
</div>
</Card> </Card>
</div> </div>
) : ( ) : (