## 创建项目骨架
创建一个基于单模块的项目框架
### 安装 ThinkJS 命令
~~~sh
$ npm install -g think-cli
~~~
安装完成后,系统中会有`thinkjs`命令(可以通过`thinkjs -V`查看 think-cli 的版本号,此版本号非 thinkjs 的版本号)。如果找不到这个命令,请确认环境变量是否正确。
### 创建项目
执行`thinkjs new [project_name]`来创建项目,如:
~~~
$ thinkjs new cms-server-thinkjs
$ cd cms-server-thinkjs
$ npm install
$ npm start
~~~
在询问是否打开Babel的时候选择是,开启Babel,其他的选择默认值就可以了。
```
PS D:\在线课程\JS与WEB前端框架技术\web-js-framework-code\code\projects\cms\module-01\learning> thinkjs new cms-server-thinkjs
? Project name cms-server-thinkjs
? Project description application created by thinkjs
? Author zengqs <pypzengqs@126.com>
? Do you want to turn on babel? Yes
think-cli · Generated cms-server-thinkjs
To get started:
# enter path
$ cd cms-server-thinkjs
# install dependencies:
$ npm install
# run the app
$ npm start
```
package.json文件内容
~~~
{
"name": "cms-server-thinkjs",
"description": "application created by thinkjs",
"version": "1.0.0",
"author": "",
"scripts": {
"start": "node development.js",
"test": "THINK_UNIT_TEST=1 nyc ava test/ && nyc report --reporter=html",
"compile": "babel --no-babelrc src/ --presets think-node --out-dir app/",
"lint": "eslint src/",
"lint-fix": "eslint --fix src/"
},
"dependencies": {
"mockjs": "^1.1.0",
"think-cache": "^1.0.0",
"think-cache-file": "^1.0.8",
"think-logger3": "^1.0.0",
"think-model": "^1.0.0",
"think-model-mysql": "^1.0.0",
"think-session": "^1.0.0",
"think-session-file": "^1.0.5",
"think-view": "^1.0.0",
"think-view-nunjucks": "^1.0.1",
"thinkjs": "^3.0.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-preset-think-node": "^1.0.0",
"node-notifier": "^5.0.2",
"think-inspect": "0.0.2",
"think-babel": "^1.0.3",
"think-watcher": "^3.0.0",
"eslint": "^4.2.0",
"eslint-config-think": "^1.0.0",
"ava": "^0.18.0",
"nyc": "^7.0.0"
},
"repository": "",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"readmeFilename": "README.md",
"thinkjs": {
"metadata": {
"name": "cms-server-thinkjs",
"description": "application created by thinkjs",
"author": "",
"babel": true
},
"projectName": "cms-server-thinkjs",
"template": "C:\\Users\\jszx\\AppData\\Roaming\\npm\\node_modules\\think-cli\\default_template",
"clone": false,
"isMultiModule": false
}
}
~~~
- 文档说明
- 服务端开发指南
- 客户端开发指南
- 请求拦截器
- API接口实例分析
- 页面文件
- NPM包管理
- 创建NPM包项目
- 课程设计
- 概述
- 内容管理系统项目
- 配置开发环境
- 设计静态原型
- 快速构建项目
- 构建CMS系统前端界面
- 门户模块
- 新闻列表
- API接口规范
- 生成模拟数据
- 显示新闻列表
- NavigatorPath组件
- ChannelHeader组件
- v-line-clamp指令
- formatDate过滤器
- 新闻详情页
- 修改顶部导航菜单
- 实现访问远程API
- 扩展功能
- 组件开发
- 服务端项目
- 编写服务模块
- 项目配置
- 数据库
- 创建数据库脚本
- 配置数据库
- 创建模拟数据
- 新闻模块控制器
- 添加逻辑验证层
- 实现接口
- 书栈模块
- QA