mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
update
This commit is contained in:
parent
1d2d1f22ab
commit
687bcf6e4e
@ -26,6 +26,7 @@ var content = [
|
||||
'global.APP_PATH = __dirname + "/../App";',
|
||||
'//静态资源根目录',
|
||||
'global.RESOURCE_PATH = __dirname;',
|
||||
'global.ROOT_PATH = __dirname;',
|
||||
'global.APP_DEBUG = true;',
|
||||
'require("thinkjs");'
|
||||
].join("\n");
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
module.exports = {
|
||||
port: 9876
|
||||
//配置项: 配置值
|
||||
}
|
||||
3
web/App/Conf/route.js
Normal file
3
web/App/Conf/route.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = [
|
||||
[/^(.*)$/, "index/doc?doc=:1"]
|
||||
]
|
||||
0
web/App/Conf/tag.js
Normal file
0
web/App/Conf/tag.js
Normal file
@ -5,8 +5,15 @@
|
||||
module.exports = Controller(function(){
|
||||
return {
|
||||
indexAction: function(){
|
||||
//render View/Home/index_index.html file
|
||||
this.display();
|
||||
this.display("index:index");
|
||||
},
|
||||
docAction: function(doc){
|
||||
var viewFile = VIEW_PATH + "/Home/doc_" + doc + ".html";
|
||||
if (isFile(viewFile)) {
|
||||
this.display("doc:" + doc);
|
||||
}else{
|
||||
this.display("index:index");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
180
web/App/View/Home/doc_api.html
Normal file
180
web/App/View/Home/doc_api.html
Normal file
@ -0,0 +1,180 @@
|
||||
<% include inc/header.html %>
|
||||
<div class="container" style="margin-top:60px;">
|
||||
<div class="row">
|
||||
<h2>原生对象的扩展</h2>
|
||||
<h4>Object.values(obj)</h4>
|
||||
<ul>
|
||||
<li>obj <code>Object</code></li>
|
||||
<li>return: <code>Array</code></li>
|
||||
</ul>
|
||||
<p>获取对象值的集合</p>
|
||||
|
||||
<h4>Array.prototype.sum</h4>
|
||||
<ul>
|
||||
<li>return: <code>Number</code></li>
|
||||
</ul>
|
||||
<p>获取数组的和</p>
|
||||
|
||||
<h2>全局函数</h2>
|
||||
<h4>Class</h4>
|
||||
<h4>extend</h4>
|
||||
<h4>isBoolean</h4>
|
||||
<h4>isNumber</h4>
|
||||
<h4>isObject</h4>
|
||||
<h4>isString</h4>
|
||||
<h4>isFunction</h4>
|
||||
<h4>isDate</h4>
|
||||
<h4>isRegexp</h4>
|
||||
<h4>isError</h4>
|
||||
<h4>isEmpty</h4>
|
||||
<h4>isArray</h4>
|
||||
<h4>isIP</h4>
|
||||
<h4>isIP4</h4>
|
||||
<h4>isIP6</h4>
|
||||
<h4>isFile</h4>
|
||||
<h4>isDir</h4>
|
||||
<h4>isBuffer</h4>
|
||||
<h4>isPromise</h4>
|
||||
<h4>isWritable</h4>
|
||||
<h4>mkdir</h4>
|
||||
<h4>chmod</h4>
|
||||
<h4>getFileContent</h4>
|
||||
<h4>setFileContent</h4>
|
||||
<h4>ucfirst</h4>
|
||||
<h4>md5</h4>
|
||||
<h4>getPromise</h4>
|
||||
<h4>getDefer</h4>
|
||||
<h4>getObject</h4>
|
||||
|
||||
<h4>thinkRequire</h4>
|
||||
<h4>inherits</h4>
|
||||
<h4>Cache</h4>
|
||||
<h4>Behavior</h4>
|
||||
<h4>Controller</h4>
|
||||
<h4>Session</h4>
|
||||
<h4>Model</h4>
|
||||
<h4>Db</h4>
|
||||
<h4>B</h4>
|
||||
<h4>tag</h4>
|
||||
<h4>C</h4>
|
||||
<h4>A</h4>
|
||||
<h4>F</h4>
|
||||
<h4>D</h4>
|
||||
<h4>S</h4>
|
||||
<h4>E</h4>
|
||||
|
||||
<h2>Controller类的方法</h2>
|
||||
|
||||
<h4>controller.ip()</h4>
|
||||
<ul>
|
||||
<li>return: <code>String</code></li>
|
||||
</ul>
|
||||
<p>获取当前用户的ip</p>
|
||||
|
||||
<h4>controller.isGet()</h4>
|
||||
<ul>
|
||||
<li>return: <code>Boolean</code></li>
|
||||
</ul>
|
||||
<p>是否为GET请求</p>
|
||||
|
||||
<h4>controller.isPost()</h4>
|
||||
<ul>
|
||||
<li>return: <code>Boolean</code></li>
|
||||
</ul>
|
||||
<p>是否为POST请求</p>
|
||||
|
||||
<h4>controller.isMethod(method)</h4>
|
||||
<ul>
|
||||
<li>method <code>String</code> 请求类型</li>
|
||||
<li>return: <code>Boolean</code></li>
|
||||
</ul>
|
||||
<p>判断当前请求类型与传递的参数是否相同</p>
|
||||
|
||||
<h4>controller.isAjax()</h4>
|
||||
<ul>
|
||||
<li>return: <code>Boolean</code></li>
|
||||
</ul>
|
||||
<p>是否为ajax请求</p>
|
||||
|
||||
<h4>controller.get(name)</h4>
|
||||
<ul>
|
||||
<li>name <code>String|undefined</code></li>
|
||||
<li>return: <code>String|Object</code></li>
|
||||
</ul>
|
||||
<p>获取get参数的值,如果name为undefined,则返回所有的参数值</p>
|
||||
|
||||
<h4>controller.post(name)</h4>
|
||||
<ul>
|
||||
<li>name <code>String|undefined</code></li>
|
||||
<li>return: <code>String|Object</code></li>
|
||||
</ul>
|
||||
<p>获取POST参数的值,如果name为undefined,则返回所有的POST值</p>
|
||||
|
||||
<h4>controller.param(name)</h4>
|
||||
<ul>
|
||||
<li>name <code>String|undefined</code></li>
|
||||
<li>return: <code>String|Object</code></li>
|
||||
</ul>
|
||||
<p>获取POST或者GET参数的值(优先从POST里获取),如果name为undefined,则返回所有的值</p>
|
||||
|
||||
<h4>controller.file(name)</h4>
|
||||
<ul>
|
||||
<li>name <code>String</code></li>
|
||||
<li>return: <code>Object</code></li>
|
||||
</ul>
|
||||
<p>获取上传的文件对象</p>
|
||||
|
||||
<h4>controller.header(name, value)</h4>
|
||||
<p>获取或者设置header</p>
|
||||
<ul>
|
||||
<li>如果name为object, 则循环设置header</li>
|
||||
<li>如果设置了value,则设置header</li>
|
||||
<li>如果name为undefined,则返回所有的header</li>
|
||||
<li>返回name对应的header值</li>
|
||||
</ul>
|
||||
|
||||
<h4>controller.userAgent()</h4>
|
||||
<ul>
|
||||
<li>return: <code>String</code></li>
|
||||
</ul>
|
||||
<p>返回用户的userAgent</p>
|
||||
|
||||
<h4>controller.referrer()</h4>
|
||||
<ul>
|
||||
<li>return: <code>String</code></li>
|
||||
</ul>
|
||||
<p>返回当前请求的referrer</p>
|
||||
|
||||
<h4>controller.cookie(name, value, options)</h4>
|
||||
|
||||
<h4>controller.session(name, value)</h4>
|
||||
|
||||
<h4>controller.redirect(url, code)</h4>
|
||||
|
||||
<h4>controller.assign(name, value)</h4>
|
||||
|
||||
<h4>controller.fetch(templateFile, content)</h4>
|
||||
|
||||
<h4>controller.display(templateFile, charset, contentType, content)</h4>
|
||||
|
||||
<h4>controller.action(action)</h4>
|
||||
|
||||
<h4>controller.jsonp(data)</h4>
|
||||
|
||||
<h4>controller.json(data)</h4>
|
||||
|
||||
<h4>controller.status(status)</h4>
|
||||
|
||||
<h4>controller.echo(obj, encoding)</h4>
|
||||
|
||||
<h4>controller.end(obj)</h4>
|
||||
|
||||
<h4>controller.download(file, contentType)</h4>
|
||||
|
||||
<h4>controller.success(data)</h4>
|
||||
|
||||
<h4>controller.error(data)</h4>
|
||||
|
||||
<h2>Model类的方法</h2>
|
||||
</div>
|
||||
</div>
|
||||
58
web/App/View/Home/doc_guide.html
Normal file
58
web/App/View/Home/doc_guide.html
Normal file
@ -0,0 +1,58 @@
|
||||
<% include inc/header.html %>
|
||||
<div class="container" style="margin-top:60px;">
|
||||
<div class="row">
|
||||
|
||||
<h2>安装</h2>
|
||||
<pre><code>sudo npm install -g thinkjs</code></pre>
|
||||
|
||||
<h2>创建项目</h2>
|
||||
<pre><code>mkdir path/to/xxx;
|
||||
cd path/to/xxx;
|
||||
thinkjs .</code></pre>
|
||||
<p>执行后,如果当前环境有浏览器,会自动用浏览器打开 <a href="http://127.0.0.1:8360">http://127.0.0.1:8360</a>,并且会看到如下的内容</p>
|
||||
<pre><code>hello, thinkjs!</code></pre>
|
||||
|
||||
<h2>项目结构</h2>
|
||||
<pre><code>.
|
||||
├── App
|
||||
│ ├── Common
|
||||
│ │ └── common.js ---- 通用函数文件,一般将项目里的一些全局函数放在这里
|
||||
│ ├── Conf
|
||||
│ │ └── config.js ---- 项目配置文件
|
||||
│ ├── Lib
|
||||
│ │ ├── Behavior ---- 行为类存放位置
|
||||
│ │ ├── Controller
|
||||
│ │ │ └── Home
|
||||
│ │ │ └── IndexController.js ---- 逻辑控制类
|
||||
│ │ └── Model ---- 模型类
|
||||
│ ├── Runtime ---- 运行时的一些文件
|
||||
│ │ ├── Cache ---- 缓存目录
|
||||
│ │ ├── Data ---- 数据目录
|
||||
│ │ ├── Log
|
||||
│ │ └── Temp
|
||||
│ └── View
|
||||
│ └── Home
|
||||
│ └── index_index.html ---- 模版文件,默认使用ejs模版引擎
|
||||
├── ctrl.sh ---- 项目启动、停止脚本
|
||||
└── www
|
||||
├── index.js ---- 入口文件
|
||||
└── resource ---- 静态资源目录
|
||||
├── css
|
||||
├── img
|
||||
├── js
|
||||
├── module
|
||||
└── swf</code></pre>
|
||||
|
||||
<h2>模版引擎</h2>
|
||||
<p>Think.js默认使用的是ejs模版引擎,你可以从<a href="https://github.com/visionmedia/ejs" target="_blank">这里</a>查看ejs的具体使用方法。</p>
|
||||
<p>修改<code>App/View/Home/index_index.html</code>页面,保存后刷新页面,即可看到修改后的内容。</p>
|
||||
|
||||
<h2>开发模式</h2>
|
||||
<p>Think.js默认为debug开发模式,这种模式下修改当前项目下的任意文件,刷新页面后即可看到效果,不需要重启Node.js服务。</p>
|
||||
<p>代码上线时需要将www/index.js里的<code>global.APP_DEBUG = true;</code>设置为false,从而提高性能。</p>
|
||||
|
||||
<h2>启动/关闭Node.js服务</h2>
|
||||
<p>开发环境下建议通过<code>cd www; node index.js</code>来启动服务。</p>
|
||||
<p>线上环境可以通过<code>sh ctrl.sh start/restart/stop</code>命令来启动/重启/关闭服务。</p>
|
||||
</div>
|
||||
</div>
|
||||
6
web/App/View/Home/doc_intro.html
Normal file
6
web/App/View/Home/doc_intro.html
Normal file
@ -0,0 +1,6 @@
|
||||
<% include inc/header.html %>
|
||||
<div class="container" style="margin-top:60px;">
|
||||
<div class="row">
|
||||
<h2>介绍</h2>
|
||||
</div>
|
||||
</div>
|
||||
44
web/App/View/Home/inc/header.html
Normal file
44
web/App/View/Home/inc/header.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>thinkjs官方网站</title>
|
||||
<link href="/static/css/base.css" rel="stylesheet">
|
||||
<link href="/static/module/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="/static/module/highlight/styles/github.css" rel="stylesheet">
|
||||
<script src="/static/module/jquery/1.9.1/jquery.js"></script>
|
||||
<script src="/static/module/bootstrap/js/bootstrap.js"></script>
|
||||
<script src="/static/module/require/2.1.8/require.js"></script>
|
||||
<script>
|
||||
var URL_PREFIX = "";
|
||||
require.config({
|
||||
baseUrl : '/static', //配置模块根路径到静态资源根目录。
|
||||
urlArgs : "r=" + (new Date()).getTime() //避免开发环境缓存
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/" style="width:200px;font-size:30px;">Think.js</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="/">首页</a></li>
|
||||
<li><a href="/intro">介绍</a></li>
|
||||
<li><a href="/guide">快速上手</a></li>
|
||||
<li><a href="/api">API</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<a class="fork" href="https://github.com/welefen/thinkjs" target="_blank">Fork me on Github</a>
|
||||
</div>
|
||||
@ -1,69 +1,43 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>thinkjs官方网站</title>
|
||||
<link href="/static/css/base.css" rel="stylesheet">
|
||||
<link href="/static/module/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="/static/module/highlight/styles/github.css" rel="stylesheet">
|
||||
<script src="/static/module/jquery/1.9.1/jquery.js"></script>
|
||||
<script src="/static/module/bootstrap/js/bootstrap.js"></script>
|
||||
<script src="/static/module/require/2.1.8/require.js"></script>
|
||||
<script>
|
||||
var URL_PREFIX = "";
|
||||
require.config({
|
||||
baseUrl : '/static', //配置模块根路径到静态资源根目录。
|
||||
urlArgs : "r=" + (new Date()).getTime() //避免开发环境缓存
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/" style="width:200px">thinkjs</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="https://github.com/welefen/thinkjs" target="_blank">首页</a></li>
|
||||
<li><a href="https://github.com/welefen/thinkjs" target="_blank">介绍</a></li>
|
||||
<li><a href="https://github.com/welefen/thinkjs" target="_blank">API</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<a class="fork" href="https://github.com/welefen/thinkjs" target="_blank">Fork me on Github</a>
|
||||
</div>
|
||||
<% include inc/header.html %>
|
||||
<div class="jumbotron" style="padding-top:50px;background:url(/static/img/bg.jpg); background-size:cover">
|
||||
<div class="container" style="padding-top:50px;">
|
||||
<h1 style="font-size:48px;">node.js web application framework</h1>
|
||||
<p style="margin-top:40px;">thinkjs是一个快速、简单的基于MVC和面向对象的轻量级node.js开发框架,遵循MIT协议发布。秉承简洁易用的设计原则,在保持出色的性能和至简的代码同时,注重开发体验和易用性,为WEB应用开发提供强有力的支持。</p>
|
||||
<h1 style="font-size:48px;">A Node.js Web Application Framework</h1>
|
||||
<p style="margin-top:40px;">Think.js是一个快速、简单的基于MVC和面向对象的轻量级Node.js开发框架,遵循MIT协议发布。秉承简洁易用的设计原则,在保持出色的性能和至简的代码同时,注重开发体验和易用性,为WEB应用开发提供强有力的支持。</p>
|
||||
<p style="margin-top:40px;">Think.js里面很多特性来源于ThinkPHP,同时根据Node.js的特点,使用了Promise, WebSocket等特性,让代码更简洁、优雅。</p>
|
||||
<p style="margin-top:40px;"><a class="btn btn-success btn-lg" role="button" href="/introduce">查看更多 »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2>解决的问题</h2>
|
||||
<div class="col-md-4">
|
||||
<h2>开发者</h2>
|
||||
<ul style="padding-left:20px;">
|
||||
<li>发现页面中的问题</li>
|
||||
<li><a href="https://github.com/welefen/">welefen</a></li>
|
||||
<li><a href="https://github.com/akira-cn/">akira-cn</a></li>
|
||||
<li><a href="https://github.com/qgy18">qgy18</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Changelog</h2>
|
||||
<ul style="padding-left:20px;">
|
||||
<li>优化Session机制,实现gc</li>
|
||||
<li>支持websocket,无缝切换</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>已经使用的产品</h2>
|
||||
<ul style="padding-left:20px;">
|
||||
<li><a href="http://www.gitpress.org/">gitpress</a></li>
|
||||
<li><a href="https://www.imququ.com/">JerryQu 的小站</a></li>
|
||||
<li><a href="">welefen的随笔</a></li>
|
||||
</ul>
|
||||
<p><a class="btn btn-default" href="/introduce" role="button">查看更多 »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="container">
|
||||
<footer>
|
||||
<p style="color:#666">by welefen</p>
|
||||
<p style="color:#666;" class="text-center">@2014</p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user