Library useful links

This commit is contained in:
LittleSheep 2025-01-11 22:34:10 +08:00
parent 1c012f7530
commit 257884145e
3 changed files with 61 additions and 3 deletions

View File

@ -63,6 +63,10 @@ app.whenReady().then(() => {
return result.filePaths[0] return result.filePaths[0]
}) })
ipcMain.handle('beep', () => {
shell.beep()
})
initTasks() initTasks()
initLibrary() initLibrary()
initInstaller() initInstaller()

View File

@ -1,4 +1,4 @@
import { ipcMain, app } from 'electron' import { ipcMain, app, shell } from 'electron'
import { MaProduct, MaRelease } from 'solar-js-sdk' import { MaProduct, MaRelease } from 'solar-js-sdk'
import { join } from 'path' import { join } from 'path'
import * as fs from 'fs' import * as fs from 'fs'
@ -46,6 +46,7 @@ export function initLibrary(): void {
ipcMain.handle('uninstall-app', (_, id: string) => uninstallApp(id)) ipcMain.handle('uninstall-app', (_, id: string) => uninstallApp(id))
ipcMain.handle('launch-app', (_, id: string) => launchApp(id)) ipcMain.handle('launch-app', (_, id: string) => launchApp(id))
ipcMain.handle('open-path-app', (_, id: string) => openPathApp(id))
} }
export function getAppLibrary(): LocalAppRecord[] { export function getAppLibrary(): LocalAppRecord[] {
@ -105,3 +106,10 @@ export function launchApp(id: string): void {
console.error(err) console.error(err)
} }
} }
export function openPathApp(id: string): void {
const app = getAppLibrary().filter((ele) => ele.id === id)[0]
if (!app) return
shell.openPath(app.basePath)
}

View File

@ -1,5 +1,16 @@
import { LocalAppRecord } from '@main/library' import { LocalAppRecord } from '@main/library'
import { Avatar, Box, Button, Container, Divider, Grid2 as Grid, IconButton, Stack, Typography } from '@mui/material' import {
Avatar,
Box,
Button,
Container,
Divider,
Grid2 as Grid,
IconButton,
Link,
Stack,
Typography,
} from '@mui/material'
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import { useNavigate, useParams } from 'react-router' import { useNavigate, useParams } from 'react-router'
import { getAttachmentUrl } from 'solar-js-sdk' import { getAttachmentUrl } from 'solar-js-sdk'
@ -60,6 +71,10 @@ export default function LibraryDetails(): JSX.Element {
setBusy(false) setBusy(false)
} }
async function openInstalledPath() {
await window.electron.ipcRenderer.invoke('open-path-app', app?.id)
}
return ( return (
<> <>
{product?.previews && ( {product?.previews && (
@ -130,7 +145,7 @@ export default function LibraryDetails(): JSX.Element {
</Grid> </Grid>
<Grid size={4}> <Grid size={4}>
<Stack spacing={2} alignItems="end"> <Stack spacing={2} alignItems="end" sx={{ mx: -1.5 }}>
<Box> <Box>
<IconButton disabled={busy} color="error" onClick={uninstallApp}> <IconButton disabled={busy} color="error" onClick={uninstallApp}>
<UninstallIcon /> <UninstallIcon />
@ -140,6 +155,37 @@ export default function LibraryDetails(): JSX.Element {
</IconButton> </IconButton>
</Box> </Box>
</Stack> </Stack>
<Box sx={{ mt: 4, textAlign: 'right' }}>
<Link
variant="caption"
color="textSecondary"
href={`/products/${app?.product.id}`}
underline="none"
display="block"
>
Store page
</Link>
<Link
variant="caption"
color="textSecondary"
underline="none"
display="block"
sx={{ cursor: 'pointer' }}
onClick={() => openInstalledPath()}
>
Open installed path
</Link>
</Box>
<Box sx={{ mt: 2, textAlign: 'right' }}>
<Typography variant="caption" component="p">
Version {app?.release.version}
</Typography>
<Typography variant="caption" component="p" fontFamily="monospace" fontSize={9}>
#{app?.id}
</Typography>
</Box>
</Grid> </Grid>
</Grid> </Grid>
</Container> </Container>