This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requestFullscreen: function (el) { | |
if (el) { | |
if (el.requestFullscreen) { | |
el.requestFullscreen() | |
return true | |
} else if (el.mozRequestFullScreen) { /* Firefox */ | |
el.mozRequestFullScreen() | |
return true | |
} else if (el.webkitRequestFullscreen) { /* Chrome, Safari and Opera */ | |
el.webkitRequestFullscreen() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rescanCurrentFolder: function () { | |
this.clearAllContentItems() | |
this.contents.push(...this.getFolderContents(this.selectedFolder)) | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
folderWatcherHandler: function (newFolder, oldFolder) { | |
if (oldFolder && this.watcher) { | |
this.watcher.close() | |
} | |
if (newFolder) { | |
// let backend know to statically serve files from this folder | |
ipcRenderer.send('folder', newFolder) | |
this.watcher = chokidar.watch(newFolder, { | |
depth: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createNode: function (fileInfo) { | |
let nodeKey = fileInfo.rootDir | |
if (nodeKey.charAt(nodeKey.length - 1) !== path.sep) { | |
nodeKey += path.sep | |
} | |
if (fileInfo.fileName === path.sep) { | |
fileInfo.fileName = nodeKey | |
} | |
else { | |
nodeKey += fileInfo.fileName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getFolders: function (absolutePath) { | |
let folders = [] | |
// check incoming arg | |
if (!absolutePath || typeof absolutePath !== 'string') { | |
return folders | |
} | |
for (const fileInfo of walkFolders(absolutePath, false)) { | |
// all files and folders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
else if (type === 'image') { | |
return 'http://localhost:8000/file/' + this.node.label | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ipcMain.on('folder', (event, folder) => { | |
fileFolder = folder | |
}) | |
expressApp.use(cors()) | |
router.get('/file/:name', function (req, res) { | |
let filename = fileFolder + path.sep + req.params.name | |
console.log('Serving file:', filename) | |
res.sendFile(filename) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { app, BrowserWindow, ipcMain } from 'electron' | |
const nativeImage = require('electron').nativeImage | |
const path = require('path') | |
const http = require('http') | |
const express = require('express') | |
const expressApp = express() | |
const cors = require('cors') | |
const router = express.Router() | |
let fileFolder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webPreferences: { | |
webSecurity: true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.platform === 'win32') { | |
getWindowsDrives((error, drives) => { | |
if (!error) { | |
this.drives = drives | |
// work through the drives backwards | |
for (let index = this.drives.length - 1; index >= 0; --index) { | |
try { | |
const stat = fs.statSync(this.drives[index] + path.sep) | |
let fileInfo = {} | |
fileInfo.rootDir = this.drives[index] |