Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readLocalUserSetting (key, optional = false) {
const storage = require('electron-json-storage')
const remote = require('electron').remote
const app = remote.app
const path = require('path')
writeLog('info', 'readLocalUserSetting ::: Trying to read value of key: ' + key)
const defaultDataPath = storage.getDefaultDataPath() // get default storage path
const userSettingsPath = path.join(app.getPath('userData'), 'ttthUserSettings') // change path for userSettings
storage.setDataPath(userSettingsPath)
// read the json file
storage.get(key, function (error, data) {
if (error) {
writeLog('error', 'readLocalUserSetting ::: Got error while reading a json file with the name: _' + key + '_. Error: ' + error)
throw error
}
var value = data.setting // store the read value in a variable
writeLog('info', 'readLocalUserSetting ::: key: _' + key + '_ - got value: _' + value + '_')
storage.setDataPath(defaultDataPath) // revert storage path
// setting DefaultView
function writeLocalUserSetting (key, value) {
const storage = require('electron-json-storage')
const remote = require('electron').remote
const app = remote.app
const path = require('path')
const defaultDataPath = storage.getDefaultDataPath() // get default storage path
const userSettingsPath = path.join(app.getPath('userData'), 'ttthUserSettings') // set new path for userUsettings
storage.setDataPath(userSettingsPath)
// write the user setting
storage.set(key, { setting: value }, function (error) {
if (error) {
writeLog('error', 'writeLocalUserSetting ::: Got an error while trying to write a user setting with key: _' + key + '_ and value: _' + value + '_. Error: ' + error)
throw error
}
writeLog('info', 'writeLocalUserSetting ::: key: _' + key + '_ - new value: _' + value + '_')
storage.setDataPath(defaultDataPath) // revert to default path
})
}
handleCopy = async (ref: ?HTMLCanvasElement, fileName: string) => {
this.handleCopyIcon()
function writeFile(fileName, data, type) {
return new Promise((resolve, reject) => {
fs.writeFile(fileName, data, type, err => {
if (err) reject(err)
else resolve(data)
})
})
}
// $FlowFixMe
const url = ref.toDataURL('image/jpg', 0.8)
const base64Data = url.replace(/^data:image\/png;base64,/, '')
const storagePath = storage.getDefaultDataPath()
await writeFile(`${storagePath}/${fileName}.jpg`, base64Data, 'base64')
clipboard.writeImage(`${storagePath}/${fileName}.jpg`)
}
click() {
shell.showItemInFolder(storage.getDefaultDataPath());
}
},
import {EventConstants} from "../common/constants/event.constants";
import {IFileSave} from "../common/interface/IFileSave";
import {git} from "./features/git";
import {pandoc} from "./features/pandoc";
import {buildMenu} from "./i18n/menu/menu";
import {dockMenu} from "./i18n/menu/menu.dock";
import {createHelpPage} from "./pages/help.page";
import {openHtmlPage} from "./pages/html.page";
import {createSlidePage} from "./pages/silde.page";
const tmp = require("tmp");
const chokidar = require("chokidar");
const windowStateKeeper = require("electron-window-state");
const storage = require("electron-json-storage");
const defaultDataPath = storage.getDefaultDataPath();
const blogpostData = require("../../assets/data/output.json");
const lunr = require("lunr");
const dataWithIndex: any[] = [];
let lunrIdx: any;
let currentFile: string;
let mainWindow: Electron.BrowserWindow;
let dir;
function dirTree(filename: string) {
const stats = fs.lstatSync(filename);
const info: any = {
filename,
module: path.basename(filename),
};