Skip to content

Commit

Permalink
first working version;
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddli committed Oct 13, 2019
1 parent 22fcb10 commit 97d98a2
Show file tree
Hide file tree
Showing 8 changed files with 621 additions and 134 deletions.
27 changes: 0 additions & 27 deletions app/bg.js

This file was deleted.

107 changes: 77 additions & 30 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,77 @@
nw.Window.open(
'templates/index.html',
{
"id": "happypandax_desktop_main",
"title": "HappyPanda X Desktop",
"width": 1024,
"height": 800,
"icon": "static/favicon/favicon.ico",
"min_width": 500,
"min_height": 500,
'inject_js_start': 'app/start.js',
},
function (win) {

win.on('close', function () {
this.hide()
this.close(true)
});

// global.contextmenu = new nw.Menu();
// global.contextmenu.createMacBuiltin("HappyPanda X Desktop");
// global.contextmenu.append(new nw.MenuItem({ label: 'Quit' }));

// win.window.document.body.addEventListener('contextmenu', function (ev) {
// ev.preventDefault();
// global.contextmenu.popup(ev.x, ev.y);
// return false;
// });

});
const { app, BrowserWindow } = require('electron')
const path = require('path')

function create_window () {
let win = new BrowserWindow({
title: "HappyPanda X Desktop",
icon: "static/favicon/favicon.ico",
width: 1024,
height: 800,
minWidth: 500,
minHeight: 500,
webPreferences: {
preload: path.join(__dirname, 'pre.js'),
nodeIntegration: true
},
backgroundColor: '#f9f9f9',
show: false
})

win.loadFile('templates/index.html')

win.webContents.openDevTools()

win.on('closed', () => {
win = null
})

win.once('ready-to-show', () => {
win.show()
})
}

app.on('ready', create_window)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (win === null) {
create_window()
}
})


// nw.Window.open(
// 'templates/index.html',
// {
// "id": "happypandax_desktop_main",
// "title": "HappyPanda X Desktop",
// "width": 1024,
// "height": 800,
// "icon": "static/favicon/favicon.ico",
// "min_width": 500,
// "min_height": 500,
// 'inject_js_start': 'app/start.js',
// },
// function (win) {

// win.on('close', function () {
// this.hide()
// this.close(true)
// });

// // global.contextmenu = new nw.Menu();
// // global.contextmenu.createMacBuiltin("HappyPanda X Desktop");
// // global.contextmenu.append(new nw.MenuItem({ label: 'Quit' }));

// // win.window.document.body.addEventListener('contextmenu', function (ev) {
// // ev.preventDefault();
// // global.contextmenu.popup(ev.x, ev.y);
// // return false;
// // });

// });
43 changes: 43 additions & 0 deletions app/pre.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var __OS__ = require('os');

global.SERVER = {
HOST: 'localhost',
PORT: 7007
}
global.CONFIG_PATH = require('path').join(process.cwd(), 'desktop.json')

global.SERVER_SSL = false;
global.SERVER_HOST = global.SERVER.HOST;
global.SERVER_PORT = global.SERVER.PORT;
global.WEBSERVER_HOST = 'localhost';
global.WEBSERVER_PORT = 7008;
global.SERVER_URL = (global.SERVER_SSL ? 'https://' : 'http://') + global.SERVER_HOST + ':' + global.SERVER_PORT.toString();
global.WEBSERVER_URL = (global.SERVER_SSL ? 'https://' : 'http://') + global.WEBSERVER_HOST + ':' + global.WEBSERVER_PORT.toString();
global.SOCKETIO_MODULE = require('./socket-io-client');
global.VERSION = require('../package.json').version;
global.TITLE = "HPX Desktop - Alpha";

global.IS_SAME_MACHINE = function(host) {
let same = false;
let ifaces = __OS__.networkInterfaces();

Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if (iface.address === host)
same = true;
});
});
return same;
}

class _DESKTOP_API {

constructor() {
}

show_context_menu(ev) {
}

}

global.DESKTOP_API = new _DESKTOP_API()
54 changes: 0 additions & 54 deletions app/start.js

This file was deleted.

Loading

0 comments on commit 97d98a2

Please sign in to comment.