This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>koa2-blog</title> | |
<link rel="icon" href="./images/icon.png"> | |
<link rel="stylesheet" href="/index.css"> | |
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.min.js"></script> | |
<script> | |
function fade(txt){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('mysql'); | |
var config = require('../config/default.js') | |
var pool = mysql.createPool({ | |
host : config.database.HOST, | |
user : config.database.USERNAME, | |
password : config.database.PASSWORD, | |
database : config.database.DATABASE, | |
port : config.database.PORT | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Koa = require('koa'); | |
const path = require('path') | |
const bodyParser = require('koa-bodyparser'); | |
const ejs = require('ejs'); | |
const session = require('koa-session-minimal'); | |
const MysqlStore = require('koa-mysql-session'); | |
const config = require('./config/default.js'); | |
const router = require('koa-router') | |
const views = require('koa-views') | |
// const koaStatic = require('koa-static') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE generatorConfiguration | |
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" | |
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> | |
<!-- 配置產生器 --> | |
<generatorConfiguration> | |
<!-- 可以用於加載配置項或者配置文件,在整個配置文件中就可以使用${propertyKey}的方式來引用配置項 | |
resource:配置資源加載地址,使用resource,MBG(mybatis generator)從classpath開始找,比如com/myproject/generatorConfig.properties | |
url:配置資源加載地址,使用URL的方式,比如file:///C:/myfolder/generatorConfig.properties. | |
ps : 注意,兩個屬性只能選擇一個; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require('koa-router')(); // 引入koa路由器框架 | |
router.get('/signout', async(ctx, next) => { | |
ctx.session = null; | |
console.log('登出成功') | |
ctx.body = true | |
}) | |
module.exports = router |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require('koa-router')(); // 引入koa路由器框架 | |
const controller = require('../controller/posts-ctl') // 引入我們新增的注冊控制器(控制它到那條路上) | |
// 重置到文章頁 | |
router.get('/', controller.getRedirectPosts) | |
// 文章頁 | |
router.get('/posts', controller.getPosts) | |
// 首頁分頁,每次輸出10條 | |
router.post('/posts/page', controller.postPostsPage) | |
// 個人文章分頁,每次輸出10條 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require('koa-router')(); // 引入koa路由器框架 | |
const controller = require('../controller/signin-ctl') // 引入我們新增的注冊控制器(控制它到那條路上) | |
router.get('/signin', controller.getSignin) | |
router.post('/signin', controller.postSignin) | |
module.exports = router |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require('koa-router')(); // 引入koa框架 | |
const controller = require('../controller/signup-ctl') // 引入我們新增的注冊控制器(控制它到那條路上) | |
// 注冊頁面 | |
router.get('/signup', controller.getSignup) | |
// post 注冊 | |
router.post('/signup', controller.postSignup) | |
module.exports = router |
NewerOlder