{"size": 1286, "ext": "js", "max_stars_repo_path": "control/index.js", "max_stars_repo_name": "heHarry/Hi_node", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "control/index.js", "max_issues_repo_name": "heHarry/Hi_node", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "control/index.js", "max_forks_repo_name": "heHarry/Hi_node", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.2641509434, "max_line_length": 89, "alphanum_fraction": 0.5583203733}
// 初始化
const initialize = (req, res) => {
    // if(!req.session.islogin) return res.redirect("/login")
    res.render("index.ejs", { 
        user:req.session.user,
        islogin:req.session.islogin
     })
}
const showLogin = (req, res) => {
    res.render("./user/login.ejs", {})
}
const showRegister = (req, res) => {
    res.render("./user/register.ejs", {})
}

// 主页面
const conn = require("../db/index.js")
const showIndexPage = (req, res) => {
    // 每页显示3条数据
    const pagesize = 3
    const nowpage = Number(req.query.page) || 1
    console.log(nowpage)
    const sql = `select a.id,a.title,a.ctime,a.authorId,users.nickname  from article as a
    LEFT JOIN users 
    ON a.authorId=users.id
    ORDER BY a.id desc 
    limit 0, 3 `
    conn.query(sql, (err, result) => {
        // console.log(result)
        // console.log(result[1].ctime)
      if (err) { 
        return res.render('index.ejs', {
          user: req.session.user,
          islogin: req.session.islogin,
          // 文章列表
          articles: []
        })
      }
      res.render('index.ejs', {
        user: req.session.user,
        islogin: req.session.islogin,
        data: result,
      
      })
    })
  }
module.exports = {
    showLogin,
    showRegister,
    initialize,
    showIndexPage
}
