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
const path = require('path') | |
const fs = require('fs') | |
/** | |
* Generator function that lists all files in a folder recursively | |
* in a synchronous fashion | |
* | |
* @param {String} folder - folder to start with | |
* @param {Number} recurseLevel - number of times to recurse folders | |
* @returns {IterableIterator<String>} |
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
const exec = require('child_process').exec | |
const fs = require('fs') | |
const path = require('path') | |
function getWindowsDrives (callback) { | |
if (!callback) { | |
throw new Error('getWindowsDrives called with no callback') | |
} | |
if (process.platform !== 'win32') { | |
throw new Error('getWindowsDrives called but process.plaform !== \'win32\'') |
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
expandTree: function (absolutePath) { | |
// get parts for the path | |
let parts = absolutePath.split(path.sep) | |
let path2 = '' | |
let lastNodeKey | |
// iterate through the path parts. | |
// This code will get the node. If the node is not found, | |
// it forces lazy-load by programmatically expanding | |
// the parent node. |
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
<q-tree | |
ref="folders" | |
:nodes="rootDir" | |
label-key="label" | |
node-key="nodeKey" | |
accordion | |
default-expand-all | |
:selected.sync="selected" | |
@lazy-load="lazyLoad" | |
/> |
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
created: function () { | |
this.$root.$on('expand-tree', this.expandTree) | |
}, | |
beforeDestroy: function () { | |
this.$root.$off('expand-tree', this.expandTree) | |
}, |
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] |
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
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
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
else if (type === 'image') { | |
return 'http://localhost:8000/file/' + this.node.label | |
} |