Skip to content

Commit

Permalink
Merge pull request #116 from jasperapp/feat-always-dev-menu
Browse files Browse the repository at this point in the history
Feat always dev menu
  • Loading branch information
h13i32maru committed Sep 14, 2019
2 parents b3d0f9f + 308dd13 commit 25e92bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 135 deletions.
16 changes: 0 additions & 16 deletions src/Electron/html/about.html
Expand Up @@ -60,22 +60,6 @@ <h1>Jasper</h1>
window.close();
}
});

// show devtool
let clickCount = 0;
document.querySelector('#icon').addEventListener('click', ()=>{
clickCount++;
if (clickCount === 5) {
const fs = require('fs');
const path = require('path');
const app = require('electron').remote.app;
const remote = require('electron').remote;
const AppPath = remote.require('./AppPath').AppPath;
const dataPath = AppPath.getUserData();
fs.writeFileSync(path.resolve(dataPath, '.debug'), '');
alert('Welcome to Developer Mode. Please Relaunch Now.');
}
});
</script>
</body>

Expand Down
54 changes: 0 additions & 54 deletions src/Electron/html/logs/logs.html

This file was deleted.

25 changes: 0 additions & 25 deletions src/Electron/html/logs/logs.ts

This file was deleted.

51 changes: 11 additions & 40 deletions src/index.ts
Expand Up @@ -2,7 +2,6 @@ import Logger from 'color-logger';
import fs from 'fs-extra';
import electron from 'electron';
import Config from './Config';
import File from './Util/File';
import Platform from './Util/Platform';
import BrowserViewProxy from './BrowserViewProxy';
import {AppPath} from './AppPath';
Expand Down Expand Up @@ -260,6 +259,13 @@ electron.app.on('ready', function() {
{label: 'FAQ', click: ()=>{electron.shell.openExternal('https://jasperapp.io/faq.html')}},
{label: 'Feedback', click: ()=>{electron.shell.openExternal('https://github.com/jasperapp/jasper')}}
]
},
{
label: 'Dev',
submenu: [
{label: 'DevTools(Main)', click: ()=>{ mainWindow.webContents.openDevTools({mode: 'detach'}); }},
{label: 'DevTools(BrowserView)', click: ()=>{ BrowserViewProxy.openDevTools({mode: 'detach'}); }},
]
}
];

Expand Down Expand Up @@ -304,27 +310,14 @@ electron.app.on('ready', function() {
{label: 'FAQ', click: ()=>{electron.shell.openExternal('https://jasperapp.io/faq.html')}},
{label: 'Feedback', click: ()=>{electron.shell.openExternal('https://github.com/jasperapp/jasper')}}
]
}
];

if (File.isExist(`${userDataPath}/.debug`)) {
template.push({
label: 'Dev',
submenu: [
{label: 'DevTools(Main)', click: ()=>{ mainWindow.webContents.openDevTools({mode: 'detach'}); }},
{label: 'DevTools(BrowserView)', click: ()=>{ BrowserViewProxy.openDevTools({mode: 'detach'}); }},
{label: 'Logs', click: showLogs}
]
});

minimumTemplate.push({
},
{
label: 'Dev',
submenu: [
{label: 'DevTools', click: ()=>{ mainWindow.webContents.openDevTools(); }},
{label: 'Logs', click: showLogs}
]
});
}
}
];

appMenu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(appMenu);
Expand Down Expand Up @@ -657,28 +650,6 @@ function showPreferences() {
prefWindow.setMenu(null);
}

function showLogs() {
const logsWindow = new electron.BrowserWindow({
title: 'Logs',
width: 800,
height: 600,
minimizable: false,
maximizable: false,
fullscreenable: false,
backgroundColor: "#e7e7e7",
parent: mainWindow,
webPreferences: {
nodeIntegration: true
}
});
logsWindow.loadURL(`file://${__dirname}/Electron/html/logs/logs.html`);
logsWindow.on('closed', ()=>{
Menu.setApplicationMenu(appMenu);
});

Menu.setApplicationMenu(minimumMenu);
}

function switchLayout(layout) {
mainWindow.webContents.send('switch-layout', layout);
require('./Util/GA').default.eventMenu(`layout:${layout}`);
Expand Down

0 comments on commit 25e92bf

Please sign in to comment.