var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./routes/index');
var users = require('./routes/users');

var appRouter = express();

// view engine setup
appRouter.set('views', path.join(__dirname, 'views'));
appRouter.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//appRouter.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
appRouter.use(logger('dev'));
appRouter.use(bodyParser.json());
appRouter.use(bodyParser.urlencoded({ extended: false }));
appRouter.use(cookieParser());
appRouter.use(express.static(path.join(__dirname, 'public')));

appRouter.use('/', routes);
appRouter.use('/users', users);

// catch 404 and forward to error handler
appRouter.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (appRouter.get('env') === 'development') {
appRouter.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}

// production error handler
// no stacktraces leaked to user
appRouter.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
appRouter.listen(3000,function(){
console.log("sss");
})

var app = module.exports = require('appjs');

app.serveFilesFrom(__dirname + '/content');

var menubar = app.createMenu([{
label:'&File',
submenu:[
{
label:'E&xit',
action: function(){
window.close();
}
}
]
},{
label:'&Window',
submenu:[
{
label:'Fullscreen',
action:function(item) {
window.frame.fullscreen();
console.log(item.label+" called.");
}
},
{
label:'Minimize',
action:function(){
window.frame.minimize();
}
},
{
label:'Maximize',
action:function(){
window.frame.maximize();
}
},{
label:''//separator
},{
label:'Restore',
action:function(){
window.frame.restore();
}
}
]
}]);

menubar.on('select',function(item){
console.log("menu item "+item.label+" clicked");
});

var trayMenu = app.createMenu([{
label:'Show',
action:function(){
window.frame.show();
},
},{
label:'Minimize',
action:function(){
window.frame.hide();
}
},{
label:'Exit',
action:function(){
window.close();
}
}]);

var statusIcon = app.createStatusIcon({
icon:'./data/content/icons/32.png',
tooltip:'AppJS Hello World',
menu:trayMenu
});

var window = app.createWindow('http://localhost:3000/',{
width : 640,
height : 460,
icons : __dirname + '/content/icons'
});
/*
var window = appjs.createWindow('http://localhost:23453/', {
width : 640,
height: 460,
icons : __dirname + '/content/icons'
});
var http = require('http');
server = http.createServer(function (req, res) {
res.writeHeader(200, {"Content-Type": "text/plain"});
res.end("Hello oschina\n");
})
server.listen(8000);
console.log("httpd start @8000");
var window = app.createWindow({
width : 1024,
height : 768,
icons : __dirname + '/content/icons',
showChrome : false,
alpha: true,
autoResize: false,
resizable: true,
margin: 0

/***************************** defaults ********************************
* url : 'http://appjs', // serve static file root and routers
* autoResize : false, // resizes in response to html content
* showChrome : true, // show border and title bar
* resizable : false, // control if users can resize window
* disableSecurity: true, // allow cross origin requests
* opacity : 1, // flat percent opacity for window
* alpha : false, // per-pixel alpha blended (Win & Mac)
* fullscreen : false, // client area covers whole screen
* left : -1, // centered by default
* top : -1, // centered by default

});*************************************************************************/
window.on('create', function(){
console.log("Window Created");
window.frame.show();
window.frame.center();
window.frame.setMenuBar(menubar);
});

window.on('ready', function(){
console.log("Window Ready");
window.process = process;
window.module = module;

function F12(e){ return e.keyIdentifier === 'F12' }
function Command_Option_J(e){ return e.keyCode === 74 && e.metaKey && e.altKey }

window.addEventListener('keydown', function(e){
if (F12(e) || Command_Option_J(e)) {
window.frame.openDevTools();
}
});
});

window.on('close', function(){
console.log("Window Closed");
});

appjs desktop2的更多相关文章

  1. appjs desktop

    /*   author: daimajia       name: appjs Express example       email: daimajia@gmail.com       any qu ...

  2. vuecli开发项目,文件打包后,appjs/vendorjs文件过大

    项目上线后,浏览器第一次加载会特别特别慢,network中看到vendorjs文件1.9M,不慢才怪. echarts按需引入后,也有1.1M左右,由于对vue脚手架理解不深,自己扒了大量的文档,又测 ...

  3. nw.js桌面软件开发系列 第0.1节 HTML5和桌面软件开发的碰撞

    第0.1节 HTML5和桌面软件开发的碰撞 当我们谈论桌面软件开发技术的时候,你会想到什么?如果不对技术本身进行更为深入的探讨,在我的世界里,有这么多技术概念可以被罗列出来(请原谅我本质上是一个Win ...

  4. NodeJS+Express下构建后端MVC文件结构

    关于MVC的结构大体上有两种方式,其一按照层级进行文件夹分类,其二是按照业务进行文件夹分类.关于这个demo相关的业务简单,所以暂采用第一种的方式,当然实际当中很恨复杂的项目可以采用两种方式相结合的方 ...

  5. 2014 年最热门的国人开发开源软件 TOP 100 - 开源中国社区

    不知道从什么时候开始,很多一说起国产好像就非常愤慨,其实大可不必.做开源中国六年有余,这六年时间国内的开源蓬勃发展,从一开始的使用到贡献,到推出自己很多的开源软件,而且还有很多软件被国外的认可.中国是 ...

  6. 使用Intellij IDEA搭建Ext JsMVC web项目

    由于自己从android开发转来学习web开发,最近在学习Jsp,之前接触过一点Extjs,所以用jsp来配合ext试试. Ext JS介绍 extjs是一个javascript框架,它的好处就是有它 ...

  7. 2014 年最热门的国人开发开源软件TOP 100

    不知道从什么时候开始,很多一说起国产好像就非常愤慨,其实大可不必.做开源中国六年有余,这六年时间国内的开源蓬勃发展,从一开始的使用到贡献,到推出自己很多的开源软件,而且还有很多软件被国外认可.中国是开 ...

  8. 自己家里搭建NAS服务器有什么好方案?

    转自:https://www.zhihu.com/question/21359049 作者:陈二发链接:https://www.zhihu.com/question/21359049/answer/6 ...

  9. 最新的hosts

    # Copyright (c) 2014-2016, racaljk.# https://github.com/racaljk/hosts# Last updated: 2016-07-03 # Th ...

随机推荐

  1. js optiontransferselect

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  2. DDL之操作表

    DDL之操作表 DDL是数据定义语言,用来定义数据库对象:数据库.表.列等.其中定义数据库我们已经在DDL之操作数据库中详细讲解了,今天我们来学习使用DDL操作表. 1.创建表 使用数据定义语言创建表 ...

  3. 【转载】高性能IO设计 & Java NIO & 同步/异步 阻塞/非阻塞 Reactor/Proactor

    开始准备看Java NIO的,这篇文章:http://xly1981.iteye.com/blog/1735862 里面提到了这篇文章 http://xmuzyq.iteye.com/blog/783 ...

  4. iOS开发之 Xcode svn更新代码后,不能打开.xcodeproj,因为该项目文件不能被解析

    http://www.cfanz.cn/?c=article&a=read&id=41565 解决方法:    1.对.xcodeproj 文件右键,显示包内容 2.双击打开 proj ...

  5. embed object以及video标签的区别以及使用

    embed object以及video标签的区别以及使用?

  6. 工作流学习——Activiti整体认识二步曲 (zhuan)

    http://blog.csdn.net/zwk626542417/article/details/46594505 ***************************************** ...

  7. 接收ET采集器数据页面

    <%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="u ...

  8. AOP 之 6.1 AOP基础(拾陆)

    6.1.1  AOP是什么 考虑这样一个问题:需要对系统中的某些业务做日志记录,比如支付系统中的支付业务需要记录支付相关日志,对于支付系统可能相当复杂,比如可能有自己的支付系统,也可能引入第三方支付平 ...

  9. Java中print、printf、println

    Java中的System.out输出会用到print.println以及printf命令. 其中 print一般的标准输出,但是不换行. println对比print即在结尾处多了换行.  eg:pr ...

  10. Windows下Git的安装及配置

    Git的BASH Git的为Windows提供了用于命令行运行的一个仿真BASH的Git.习惯LINUX和UNIX环境的你,可以在该BASH环境中输入“git”命令来完成各种版本控制的操作. 简介 G ...