Show a friendly guide when atom-shell is opened without app.
This commit is contained in:
parent
3c0ec73d75
commit
a132d2e5a0
4 changed files with 34 additions and 40 deletions
|
@ -1,6 +1,4 @@
|
||||||
var app = require('app');
|
var app = require('app');
|
||||||
var dialog = require('dialog');
|
|
||||||
var ipc = require('ipc');
|
|
||||||
var Menu = require('menu');
|
var Menu = require('menu');
|
||||||
var MenuItem = require('menu-item');
|
var MenuItem = require('menu-item');
|
||||||
var BrowserWindow = require('browser-window');
|
var BrowserWindow = require('browser-window');
|
||||||
|
@ -13,30 +11,12 @@ app.on('window-all-closed', function() {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('open-url', function(event, url) {
|
|
||||||
dialog.showMessageBox({message: url, buttons: ['OK']});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
app.commandLine.appendSwitch('js-flags', '--harmony_collections');
|
app.commandLine.appendSwitch('js-flags', '--harmony_collections');
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({ width: 800, height: 600 });
|
mainWindow = new BrowserWindow({ width: 800, height: 600 });
|
||||||
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
||||||
|
|
||||||
mainWindow.on('page-title-updated', function(event, title) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
this.setTitle('Atom Shell - ' + title);
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.on('closed', function() {
|
|
||||||
mainWindow = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.on('unresponsive', function() {
|
|
||||||
console.log('unresponsive');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
var template = [
|
var template = [
|
||||||
{
|
{
|
||||||
|
@ -117,16 +97,16 @@ app.on('ready', function() {
|
||||||
{
|
{
|
||||||
label: 'Reload',
|
label: 'Reload',
|
||||||
accelerator: 'Command+R',
|
accelerator: 'Command+R',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().restart(); }
|
click: function() { mainWindow.restart(); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Enter Fullscreen',
|
label: 'Enter Fullscreen',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); }
|
click: function() { mainWindow.setFullscreen(true); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle DevTools',
|
label: 'Toggle DevTools',
|
||||||
accelerator: 'Alt+Command+I',
|
accelerator: 'Alt+Command+I',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
|
click: function() { mainWindow.toggleDevTools(); }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -196,9 +176,4 @@ app.on('ready', function() {
|
||||||
menu = Menu.buildFromTemplate(template);
|
menu = Menu.buildFromTemplate(template);
|
||||||
mainWindow.setMenu(menu);
|
mainWindow.setMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.on('message', function(processId, routingId, type) {
|
|
||||||
if (type == 'menu')
|
|
||||||
menu.popup(mainWindow);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,18 +1,36 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
||||||
<title>Atom Shell</title>
|
<title>Atom Shell</title>
|
||||||
|
<style></style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
This is the default mode of Atom Shell, please follow the instructions in
|
<script>
|
||||||
wiki to get started.
|
var execPath = require('remote').process.execPath;
|
||||||
<script type="text/javascript" charset="utf-8">
|
var command = execPath + ' path-to-your-app';
|
||||||
var ipc = require('ipc');
|
|
||||||
|
|
||||||
window.addEventListener('contextmenu', function (e) {
|
var openWiki = function() {
|
||||||
e.preventDefault();
|
require('shell').openExternal('https://github.com/atom/atom-shell/blob/master/docs/tutorial/quick-start.md');
|
||||||
ipc.send('menu');
|
}
|
||||||
}, false);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<h1>Welcome to Atom Shell!</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Atom Shell is a cross-platform desktop application shell that enables you to
|
||||||
|
build native like applications with node.js and web page engine of Chromium.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
To run your app with atom-shell, execute the following command under your
|
||||||
|
Console (or Terminal):
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script>document.write('<pre>' + command + '</pre>')</script>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The <code>path-to-your-app</code> should be the path to your own atom-shell
|
||||||
|
app, you can read the <a href="javascript:openWiki()">Quick Start</a> guide
|
||||||
|
in atom-shell's docs on how to write one.
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "atom-shell-default-app",
|
"name": "atom-shell-default-app",
|
||||||
|
"productName": "Atom Shell Default App",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -15,11 +15,11 @@ describe 'app module', ->
|
||||||
|
|
||||||
describe 'app.getName()', ->
|
describe 'app.getName()', ->
|
||||||
it 'returns the name field of package.json', ->
|
it 'returns the name field of package.json', ->
|
||||||
assert.equal app.getName(), 'atom-shell-default-app'
|
assert.equal app.getName(), 'Atom Shell Default App'
|
||||||
|
|
||||||
describe 'app.setName(name)', ->
|
describe 'app.setName(name)', ->
|
||||||
it 'overrides the name', ->
|
it 'overrides the name', ->
|
||||||
assert.equal app.getName(), 'atom-shell-default-app'
|
assert.equal app.getName(), 'Atom Shell Default App'
|
||||||
app.setName 'test-name'
|
app.setName 'test-name'
|
||||||
assert.equal app.getName(), 'test-name'
|
assert.equal app.getName(), 'test-name'
|
||||||
app.setName 'atom-shell-default-app'
|
app.setName 'Atom Shell Default App'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue