|
|
@ -1,4 +1,22 @@ |
|
|
|
import { BrowserWindow, MenuItemConstructorOptions } from 'electron'; |
|
|
|
import { BrowserWindow, MenuItemConstructorOptions, app, ipcMain } from 'electron'; |
|
|
|
|
|
|
|
import fs from 'fs' |
|
|
|
|
|
|
|
import os from 'os' |
|
|
|
|
|
|
|
import path from 'path' |
|
|
|
|
|
|
|
import { cacheDir } from '../utils/config'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let recentFolders: string[] = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(cacheDir + '/remixdesktop.json')) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// read the cache file
|
|
|
|
|
|
|
|
const cache = fs.readFileSync(cacheDir + '/remixdesktop.json') |
|
|
|
|
|
|
|
const data = JSON.parse(cache.toString()) |
|
|
|
|
|
|
|
recentFolders = data && data.recentFolders || [] |
|
|
|
|
|
|
|
console.log('recentFolders', recentFolders) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default ( |
|
|
|
export default ( |
|
|
|
commandKeys: Record<string, string>, |
|
|
|
commandKeys: Record<string, string>, |
|
|
@ -31,11 +49,16 @@ export default ( |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
role: 'recentDocuments', |
|
|
|
role: 'recentDocuments', |
|
|
|
submenu: [ |
|
|
|
submenu: recentFolders.map((folder) => { |
|
|
|
{ |
|
|
|
return { |
|
|
|
role: 'clearRecentDocuments' |
|
|
|
label: folder, |
|
|
|
|
|
|
|
click(item, focusedWindow) { |
|
|
|
|
|
|
|
if(focusedWindow) { |
|
|
|
|
|
|
|
ipcMain.emit('fs:openFolder', focusedWindow.webContents.id, folder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
role: 'close', |
|
|
|
role: 'close', |
|
|
|