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. android平台的技术架构

    Android平台采用了软件堆层(Software Stack)的架构,主要分为四个部分: 1.应用软件 Android 连同一个核心应用程序包一起发布,该应用程序包包括E-mail客户端.SMS短消 ...

  2. 配置Linux任务计划

    Linux有三种计划任务: at:指定一个时间执行一个任务 (适用一个或多个任务,执行一次后就不用) cron:根据一个时间表自动执行任务 (使用一个或多个任务,周期性执行) 系统级别的计划任务及其扩 ...

  3. 转!!Java 基础面试题的剖析: short s1=1;s1 = s1 +1 报错? s1+=1 呢

    short s1=1;s1 = s1 +1会报错吗?    package common; public class ShortTypeTest { /* * @param args */ publi ...

  4. aspx控件属性

    ASPxGridView属性:概述设置(Settings)    <Settings          GridLines="Vertical"            : 网 ...

  5. 使用ar命令删除iOS静态库重复编译的.o文件

    关于 xcode引入第三方静态类库 duplicate symbol _OBJC_XXX 重复编译错误 看这里 http://www.cnblogs.com/cocoajin/p/3917709.ht ...

  6. 开源HTML5 Canvas游戏Runtime发布

    Cantk-Runtime是通用的HTML5 Canvas 2D游戏引擎运行库,让HTML5游戏的性能飞起来.Cantk-Runtime以PhoneGap插件的方式提供,从此结束PhoneGap低性能 ...

  7. UIStepper

    @在IOS5中增加了一个UIStepper的新控件,UIStepper可以连续增加或减少一个数值.控件的外观是两个水平并排的按钮构成,一个显示为“+”,一个显示为“-”. 1. 初始化控件 UISte ...

  8. 利用mycat实现mysql数据库读写分离

    1.这里是在mysql主从复制实现的基础上,利用mycat做读写分离,架构图如下: 2.Demo 2.1 在mysql master上创建数据库创建db1 2.2 在数据库db1创建表student ...

  9. 设置westorm自动代码提示

    打开settings 然后在js文件下 打出co  按TAB键就出现了color了

  10. hibernate的懒加载问题

    产生原因: 当使用hibernate查询一个对象的时候,如果Session关闭,再调用该对象关联的集合或者对象的时候,会产生懒加载异常! 解决方案: 方案一: 在Session关闭之前,查询对象关联的 ...