function DialogController(url, $scope, $timeout, toaster, localStorageService) { var Config = require('electron-config'); var config = new Config(); $scope.colores = [ 'verde', 'celeste', 'dorado', 'naranja', 'miel', 'red', 'pink', 'purple', 'deep-purple', 'indigo', 'blue', 'light-blue', 'cyan', 'teal', 'green', 'light-green', 'lime', 'yellow', 'amber', 'orange', 'deep-orange', 'brown', 'grey', 'blue-grey' ]; $scope.userPalette = config.get('Color'); $scope.url = url; $scope.printer = config.get('printer'); $scope.confirm = true; $scope.colorOculto = true; $scope.closeDialog = function () { $mdDialog.hide(); }; $scope.updateSettings = function (newUrl, printer, login) { var data = {BaseUrl: newUrl}; localStorageService.set('BaseURL', data); if(!login){ config.set('printer', printer); } if (url) { $mdDialog.hide(); toaster.pop({ type: 'success', title: '¡Exito!', body: "La aplicación se recargara.", showCloseButton: false }); $timeout(function timer() { ses.clearStorageData([], function (data) { console.log("Cookies limpiadas: ", data); }); electron.remote.app.relaunch({args: process.argv.slice(1) + ['--relaunch']}); electron.remote.app.exit(0); }, 3000); } }; $scope.updateColor = function (palette) { settingService.setColor(palette); toaster.pop({ type: 'success', title: '¡Exito!', body: "La aplicación se recargara.", showCloseButton: false }); $timeout(function timer() { window.reload(); }, 2000); }; }
ipcRenderer.on('preview-data', function (ev, data) { output.innerHTML = marked(data) if (config.get('githubStyle')) { output.className += ' markdown-body' } })
install(err => { updating = false; if (err) { console.error(err.stack); if (/not a recognized/.test(err.message) || /command not found/.test(err.message)) { notify( 'Error updating plugins.', 'We could not find the `npm` command. Make sure it\'s in $PATH' ); } else { notify( 'Error updating plugins.', 'Check `~/.hyper_plugins/npm-debug.log` for more information.' ); } } else { // flag successful plugin update cache.set('hyper.plugins', id_); // cache paths paths = getPaths(plugins); // clear require cache clearCache(); // cache modules modules = requirePlugins(); const loaded = modules.length; const total = paths.plugins.length + paths.localPlugins.length; const pluginVersions = JSON.stringify(getPluginVersions()); const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total; cache.set('hyper.plugin-versions', pluginVersions); // notify watchers if (force || changed) { if (changed) { notify( 'Plugins Updated', 'Restart the app or hot-reload with "View" > "Reload" to enjoy the updates!' ); } else { notify( 'Plugins Updated', 'No changes!' ); } watchers.forEach(fn => fn(err, {force})); } } });
install(err => { updating = false; if (err) { //eslint-disable-next-line no-console notify('Error updating plugins.', err, {error: err}); } else { // flag successful plugin update cache.set('hyper.plugins', id_); // cache paths paths = getPaths(); // clear require cache clearCache(); // cache modules modules = requirePlugins(); const loaded = modules.length; const total = paths.plugins.length + paths.localPlugins.length; const pluginVersions = JSON.stringify(getPluginVersions()); const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total; cache.set('hyper.plugin-versions', pluginVersions); // notify watchers watchers.forEach(fn => fn(err, {force})); if (force || changed) { if (changed) { notify('Plugins Updated', 'Restart the app or hot-reload with "View" > "Reload" to enjoy the updates!'); } else { notify('Plugins Updated', 'No changes!'); } checkDeprecatedExtendKeymaps(); } } });
function createMainWindow() { const win = new electron.BrowserWindow({ // This settings needs to be saved in config title: 'Zulip', width: conf.get('width') || 1000, height: conf.get('height') || 600, icon: iconPath(), minWidth: 600, minHeight: 400, webPreferences: { preload: path.join(__dirname, '../renderer/js/preload.js'), plugins: true, allowDisplayingInsecureContent: true, nodeIntegration: false }, show: false }); win.once('ready-to-show', () => { win.show(); }); serverError(targetURL()); win.loadURL(targetURL(), { userAgent: isUserAgent + ' ' + win.webContents.getUserAgent() }); win.on('closed', onClosed); win.setTitle('Zulip'); // Let's save browser window position if (conf.get('x') || conf.get('y')) { win.setPosition(conf.get('x'), conf.get('y')); } if (conf.get('maximize')) { win.maximize(); } // Handle sizing events so we can persist them. win.on('maximize', () => { conf.set('maximize', true); }); win.on('unmaximize', () => { conf.set('maximize', false); }); win.on('resize', function () { const size = this.getSize(); conf.set({ width: size[0], height: size[1] }); }); // On osx it's 'moved' win.on('move', function () { const pos = this.getPosition(); conf.set({ x: pos[0], y: pos[1] }); }); // Stop page to update it's title win.on('page-title-updated', (e, title) => { e.preventDefault(); updateDockBadge(title); }); // To destroy tray icon when navigate to a new URL win.webContents.on('will-navigate', e => { if (e) { win.webContents.send('destroytray'); } }); return win; }
writeFileSync(path, defaultConfig); } catch (err) { throw new Error(`Failed to write config to ${path}`); } } watch(); }; exports.getConfig = function () { return cfg.config; }; exports.getPlugins = function () { return { plugins: cfg.plugins, localPlugins: cfg.localPlugins }; }; exports.window = { get() { const position = winCfg.get('windowPosition'); const size = winCfg.get('windowSize'); return {position, size}; }, recordState(win) { winCfg.set('windowPosition', win.getPosition()); winCfg.set('windowSize', win.getSize()); } };
const electron = require('electron') const app = electron.app const BrowserWindow = electron.BrowserWindow const path = require('path') const Config = require('electron-config') const config = new Config() var showMenu = process.platform !== 'win32' const windowSize = config.get('windowsize') || { width: 1080, height: 720 } const mainWindow = new BrowserWindow({ width: windowSize.width, height: windowSize.height, minWidth: 500, minHeight: 320, autoHideMenuBar: showMenu, webPreferences: { zoomFactor: 1.0, blinkFeatures: 'OverlayScrollbars' } }) const url = path.resolve(__dirname, './main.html') mainWindow.loadURL('file://' + url) mainWindow.webContents.on('new-window', function (e) { e.preventDefault() }) mainWindow.webContents.sendInputEvent({
if (entry.indexOf(path) === 0 || entry.indexOf(localPath) === 0) { delete require.cache[entry]; } } } exports.updatePlugins = updatePlugins; exports.getLoadedPluginVersions = function () { return modules.map(mod => ({name: mod._name, version: mod._version})); }; // we schedule the initial plugins update // a bit after the user launches the terminal // to prevent slowness if (cache.get('hyper.plugins') !== id || process.env.HYPER_FORCE_UPDATE) { // install immediately if the user changed plugins console.log('plugins have changed / not init, scheduling plugins installation'); setTimeout(() => { updatePlugins(); }, 5000); } // otherwise update plugins every 5 hours setInterval(updatePlugins, ms('5h')); function syncPackageJSON() { const dependencies = toDependencies(plugins); const pkg = { name: 'hyper-plugins', description: 'Auto-generated from `~/.hyper.js`!',
}); // clear require cache for (const entry in require.cache) { if (entry.indexOf(path) === 0 || entry.indexOf(localPath) === 0) { delete require.cache[entry]; } } } exports.updatePlugins = updatePlugins; // we schedule the initial plugins update // a bit after the user launches the terminal // to prevent slowness if (cache.get('plugins') !== id || process.env.HYPERTERM_FORCE_UPDATE) { // install immediately if the user changed plugins console.log('plugins have changed / not init, scheduling plugins installation'); setTimeout(() => { updatePlugins(); }, 5000); } // otherwise update plugins every 5 hours setInterval(updatePlugins, ms('5h')); function syncPackageJSON () { const dependencies = toDependencies(plugins); const pkg = { name: 'hyperterm-plugins', description: 'Auto-generated from `~/.hyperterm.js`!',
const electron = require('electron') const app = electron.app const BrowserWindow = electron.BrowserWindow const path = require('path') const Config = require('electron-config') const config = new Config() const _ = require('lodash') const windowSize = config.get('windowsize') || { x: null, y: null, width: 1080, height: 720 } const mainWindow = new BrowserWindow({ x: windowSize.x, y: windowSize.y, width: windowSize.width, height: windowSize.height, useContentSize: true, minWidth: 500, minHeight: 320, webPreferences: { zoomFactor: 1.0, enableBlinkFeatures: 'OverlayScrollbars' }, icon: path.resolve(__dirname, '../resources/app.png') }) const url = path.resolve(__dirname, './main.html')