Skip to content

Commit

Permalink
Merge pull request #45 from tw4/dev
Browse files Browse the repository at this point in the history
fix: log tab titile trim error on macos
  • Loading branch information
tw4 authored Sep 29, 2024
2 parents e427518 + 40eeb30 commit 1d719b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
import registerHandlers from './handlers'
import { promises } from 'dns'

function createWindow(): void {
// Create the browser window.
Expand Down Expand Up @@ -52,6 +53,10 @@ app.whenReady().then(() => {
optimizer.watchWindowShortcuts(window)
})

if (process.platform === 'darwin') {
app.dock.setIcon(icon)
}

// IPC test
ipcMain.on('ping', () => console.log('pong'))
registerHandlers()
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/Pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default function Home(): JSX.Element {
const pathsArray = JSON.parse(paths)
setTotalPathsCount(pathsArray.length)

window.electron.ipcRenderer.invoke('platform').then(async (res) => {
localStorage.setItem('platform', res)
})

// get paths
const data: Path[] = paths ? JSON.parse(paths) : []
setPaths(data)
Expand Down
11 changes: 2 additions & 9 deletions src/renderer/src/Pages/Log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type TargetKey = React.MouseEvent | React.KeyboardEvent | string
export default function Log(): JSX.Element {
const newTabIndex = useRef(0)
const [selectedFile, setSelectedFile] = useState<string[]>([])
const [platform, setPlatform] = useState<string>('')
const initialItems = [
{
label: <Tooltip title="File List">File List</Tooltip>,
Expand All @@ -20,12 +19,6 @@ export default function Log(): JSX.Element {
const [activeKey, setActiveKey] = useState(initialItems[0].key)
const [items, setItems] = useState(initialItems)

useEffect(() => {
window.electron.ipcRenderer.invoke('platform').then((res) => {
setPlatform(res)
})
}, [])

// initial items
// useState side
const onChange = (newActiveKey: string): void => {
Expand Down Expand Up @@ -62,7 +55,6 @@ export default function Log(): JSX.Element {
): void => {
if (action === 'add') {
selectedFile.forEach((fileName) => {
console.log(fileName)
add(fileName)
})
} else {
Expand All @@ -75,7 +67,8 @@ export default function Log(): JSX.Element {
const newPane = {
label: (
<Tooltip title={fileName}>
{platform === 'linux' || platform === 'darwin'
{localStorage.getItem('platform') === 'linux' ||
localStorage.getItem('platform') === 'darwin'
? fileName.split('/').pop()
: fileName.split('\\').pop()}
</Tooltip>
Expand Down

0 comments on commit 1d719b2

Please sign in to comment.