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. Java编程思想学习笔记_4(异常机制,容器)

    一.finally语句注意的细节: 当涉及到break和continue语句的时候,finally字句也会得到执行. public class Test7 { public static void m ...

  2. 在beforeAction里redirect无效,Yii2.0.8

    我是在官方GitHub上得到回答,试了一下,确实解决问题了.之前的问题描述: 之前是2.0.3,然后用composer直接升级到2.0.8,就不正常了,以为是我代码的问题,于是再次尝试 用compos ...

  3. Asp.Net_Web身份验证

    百度一下”asp.net身份认证“,你会得到很多相关的资料,这些资料通常上来就会介绍诸如”Form认证“”Windows认证“等内容,而没有给出一个完整的流程.初学者对此往往一头雾水,我也曾经被坑过很 ...

  4. 【转载】PHP运行模式的深入理解

    PHP运行模式的深入理解 作者: 字体:[增加 减小] 类型:转载 时间:2013-06-03我要评论 本篇文章是对PHP运行模式进行了详细的分析介绍,需要的朋友参考下   PHP运行模式有4钟:1) ...

  5. 项目解析- JspLibrary - part3

    CRUD read: String sql = "select b.*,c.name as bookcaseName,p.pubname as publishing,t.typename f ...

  6. mac app icon 设置

    mac app icon 设置 1:目前 mac app 所需要的icon 图标尺寸 icon_16x16.png 16px icon_16x16@2x.png 32px icon_32x32.png ...

  7. python 暴力破解密码脚本

    python 暴力破解密码脚本 以下,仅为个人测试代码,环境也是测试环境,暴力破解原理都是一样的, 假设要暴力破解登陆网站www.a.com 用户 testUser的密码, 首先,该网站登陆的验证要支 ...

  8. noip赛前小结2

    嗯...赛前的第二份小结. 总结一下应该做的几个事情就好了. (1)关于做题顺序 做题顺序是很重要的. 开始的时候先审题,看清数据范围什么的,随便想一想,大概估计一下自己的得分. 第二题再把每道题仔细 ...

  9. Android Support Library控件详细介绍之RecyclerView

    RecyclerView控件 依赖  compile 'com.android.support:recyclerview-v7:24.1.1'RecyclerView也是容器控件,大多数的效果显示可通 ...

  10. A New Tetris Game

    时间限制(普通/Java):1000MS/10000MS     运行内存限制:65536KByte 总提交: 40            测试通过: 12 描述 曾经,Lele和他姐姐最喜欢,玩得最 ...