First, the preparatory work
Refer to Previous article: THINKJS framework Getting Started detailed tutorial (i) Development environment
Install the THINKJS command
NPM install-g THINK-CLI
Monitor for installation success
Thinkjs-v
Ii. Creation of the project
New Thinkjsplus
Specific source code reference: Https://github.com/saucxs/thinkJSLearning/tree/master/thinkjsplus
If you do not understand, you can put forward, if you feel OK, please give star, welcome fork
Follow-up will continue to improve.
III. Structure of the project
|---development.js//Portal files in the development environment|---nginx.conf//nginx configuration file|---Package.json|---Pm2.json//PM2 configuration file|---production.js//import file in production environment|---readme.md|---src| |---Bootstrap//start the Auto-execute directory| | |---master.js//automatic execution under Master process| | |---worker.js//automatic execution under Worker process| |---Config//Configuration file Directory| | |---adapter.js//Adapter configuration file| | |---config.js//Default configuration file| | |---config.production.js//default profile in production environment, and Config.js merge| | |---extend.js//Extend configuration file| | |---middleware.js//Middleware configuration file| | |---router.js//Customizing the routing configuration file| |---Controller//Controller Directory| | |---Base.js| | |---Index.js| |---logic//Logic Directory| | |---Index.js| |---model//Model Catalog| | |---Index.js|---View//Template Catalog| |---index_index.html|---www| |---Static//Static Resource Directory| | |---CSS| | |---img| | |---JS
Iv. Project start-up service
The entry file is Development.js, and the node Development.js can be started directly as the normal node. Viewing the portal file tells you that when you start, you are actually instantiating the application class in ThinkJS and executing the Run method.
V. Configuration database
The project is using the MySQL database, the location of the configuration file: src/config/adapter.js
Exports.model = { ' mysql ', common: { Logconnect:isdev, Logsql:isdev, + = think.logger.info (msg) }, MySQL: { handle:mysql, ' Thinkjsplus ', ' , ' UTF8 ', ' 127.0.0.1 ', ' 3306 ', ' root ', //local user name ' root ', //own local password true };
MySQL database is its own local database account and password
, the account here is root and the password is set at the time of installation.
, the thinkjsplus here is the database under the root account.
Vi. Creating a Model file
Not for the moment.
Seven, the controller
The command to create the controller is the THINKJS Controller + director name, we create the admin background login controller, while in the view layer we create the admin controller corresponding HTML page admin_index.html page, launch service, browser access HTTP ://localhost:8360/admin will be able to access the login page of admin_index.html.
Viii. operation of the project
First install MySQL, then import the project SQL folder, then run NPM install under the project root, then run NPM start to start the project
Nine
1. Login Page
Login Error
Not optimized yet
2. Login to enter
Thinkjs Framework Getting Started detailed tutorial (ii) Beginner's starter project