update
This commit is contained in:
parent
653bef8b2f
commit
75be76758d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.env
|
3425
package-lock.json
generated
Normal file
3425
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "zhao",
|
||||
"version": "0.0.1",
|
||||
"description": "赵家小站",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server",
|
||||
"dev": "nodemon server",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@nas:2222/zhaoxin/zhao.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Zhao Xin <7176466@qq.com> (https://github.com/archtaurus)",
|
||||
"license": "zhao",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"compression": "^1.7.4",
|
||||
"dotenv": "^16.0.2",
|
||||
"express": "^4.18.1",
|
||||
"mongoose": "^6.5.4",
|
||||
"pug": "^3.0.2",
|
||||
"socket.io": "^4.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.19"
|
||||
}
|
||||
}
|
7
public/css/bootstrap.min.css
vendored
Normal file
7
public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/css/bootstrap.min.css.map
Normal file
1
public/css/bootstrap.min.css.map
Normal file
File diff suppressed because one or more lines are too long
8
public/css/zhao.css
Normal file
8
public/css/zhao.css
Normal file
@ -0,0 +1,8 @@
|
||||
@font-face {
|
||||
font-family: '方正书宋';
|
||||
src: url('/fonts/方正书宋.ttf');
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 方正书宋;
|
||||
}
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
public/fonts/方正书宋.ttf
Normal file
BIN
public/fonts/方正书宋.ttf
Normal file
Binary file not shown.
BIN
public/images/raspberry.png
Normal file
BIN
public/images/raspberry.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
7
public/js/bootstrap.bundle.min.js
vendored
Normal file
7
public/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/js/bootstrap.bundle.min.js.map
Normal file
1
public/js/bootstrap.bundle.min.js.map
Normal file
File diff suppressed because one or more lines are too long
3
routers/home.js
Normal file
3
routers/home.js
Normal file
@ -0,0 +1,3 @@
|
||||
const router = require('express').Router()
|
||||
router.get('/', (req, res) => res.render('home'))
|
||||
module.exports = router
|
26
server.js
Normal file
26
server.js
Normal file
@ -0,0 +1,26 @@
|
||||
// Global Variables
|
||||
require('dotenv').config()
|
||||
|
||||
// Express
|
||||
const express = require('express')
|
||||
const compression = require('compression')
|
||||
const app = express()
|
||||
app.set('view engine', 'pug')
|
||||
app.use(compression())
|
||||
app.use(express.static('public'))
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded({ extended: false }))
|
||||
app.use('/', require('./routers/home'))
|
||||
const PORT = process.env.PORT || 3000
|
||||
const server = app.listen(PORT, () => console.log(`zhao server running at port ${PORT}`))
|
||||
|
||||
// WebSocket
|
||||
const io = require('socket.io')(server)
|
||||
io.on('connection', (client) => { })
|
||||
|
||||
// MongoDB
|
||||
const mongoose = require('mongoose')
|
||||
const MONGODB_URL = process.env.MONGODB_URL || 'mongodb://localhost/test'
|
||||
mongoose.connect(MONGODB_URL, { useNewUrlParser: true }).catch(error => console.error(error))
|
||||
mongoose.connection.on('connected', () => console.info('mongodb connected'))
|
||||
mongoose.connection.on('error', (error) => console.error(error))
|
200
views/home.pug
Normal file
200
views/home.pug
Normal file
@ -0,0 +1,200 @@
|
||||
extends layout
|
||||
|
||||
block main
|
||||
.container
|
||||
.row.row-cols-md-2
|
||||
section.table-responsive.text-center
|
||||
table.table.table-bordered
|
||||
thead.table-light
|
||||
tr
|
||||
th.table-primary(scope="col") 弟弟
|
||||
th.table-light(scope="col") 周一
|
||||
th.table-light(scope="col") 周二
|
||||
th.table-light(scope="col") 周三
|
||||
th.table-light(scope="col") 周四
|
||||
th.table-light(scope="col") 周五
|
||||
tbody
|
||||
tr
|
||||
th.table-light(scope="row") 第1节
|
||||
td 数学
|
||||
td 语文
|
||||
td 研学
|
||||
td 数学
|
||||
td 语文
|
||||
tr
|
||||
th.table-light(scope="row") 第2节
|
||||
td 语文
|
||||
td 数学
|
||||
td 语文
|
||||
td 语文
|
||||
td 数学
|
||||
tr
|
||||
th.table-light(scope="row") 第3节
|
||||
td 语文
|
||||
td 体育
|
||||
td 科学
|
||||
td 音乐
|
||||
td 美术
|
||||
tr
|
||||
th.table-light(scope="row") 第4节
|
||||
td 音乐
|
||||
td 综实
|
||||
td 科学
|
||||
td 语文
|
||||
td 劳动
|
||||
tr.table-light
|
||||
th(scope="row") 午休
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
tr
|
||||
th.table-light(scope="row") 第5节
|
||||
td 英语
|
||||
td 英语
|
||||
td 德法
|
||||
td 体育
|
||||
td 叮当
|
||||
tr
|
||||
th.table-light(scope="row") 第6节
|
||||
td 班会
|
||||
td 信息
|
||||
td 美术
|
||||
td 德法
|
||||
td 体育
|
||||
section.table-responsive.text-center
|
||||
table.table.table-bordered.align-middle
|
||||
thead.table-light
|
||||
tr
|
||||
th.table-danger(scope="col") 姐姐
|
||||
th.table-light(scope="col") 周一
|
||||
th.table-light(scope="col") 周二
|
||||
th.table-light(scope="col") 周三
|
||||
th.table-light(scope="col") 周四
|
||||
th.table-light(scope="col") 周五
|
||||
tbody
|
||||
tr
|
||||
th.table-light(scope="row") 第1节
|
||||
td 语文
|
||||
td 语文
|
||||
td 研学
|
||||
td 数学
|
||||
td 语文
|
||||
tr
|
||||
th.table-light(scope="row") 第2节
|
||||
td 数学
|
||||
td 数学
|
||||
td 语文
|
||||
td 美术
|
||||
td 数学
|
||||
tr
|
||||
th.table-light(scope="row") 第3节
|
||||
td 体育
|
||||
td 英语
|
||||
td 科学
|
||||
td 语文
|
||||
td 德法
|
||||
tr
|
||||
th.table-light(scope="row") 第4节
|
||||
td 英语
|
||||
td 体育
|
||||
td 科学
|
||||
td 语文
|
||||
td 数学
|
||||
tr.table-light
|
||||
th(scope="row") 午休
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
td 🍚🥢
|
||||
tr
|
||||
th.table-light(scope="row") 第5节
|
||||
td 德法
|
||||
td 美术
|
||||
td 综实
|
||||
td 体育
|
||||
td 信息
|
||||
tr
|
||||
th.table-light(scope="row") 第6节
|
||||
td 班会
|
||||
td 音乐
|
||||
td 英语
|
||||
td 劳动
|
||||
td 音乐
|
||||
script.
|
||||
const now = new Date()
|
||||
const tomorrow = now.getDay() + 1
|
||||
if (tomorrow >= 1 && tomorrow <= 5)
|
||||
document.querySelectorAll(`th:nth-child(${tomorrow + 1})`).forEach(cell => {
|
||||
cell.style.fontWeight = 900
|
||||
cell.classList.add('table-active')
|
||||
})
|
||||
document.querySelectorAll(`tr td:nth-child(${tomorrow + 1})`).forEach(cell => {
|
||||
cell.style.fontWeight = 900
|
||||
cell.classList.add('table-warning')
|
||||
})
|
||||
|
||||
.container
|
||||
.row.row-cols-md-2
|
||||
.col(style="min-width:15rem;")
|
||||
.card.border-danger
|
||||
.card-header
|
||||
img(src='/images/raspberry.png', height='32')
|
||||
.card-body
|
||||
p.card-text 主机名称:
|
||||
code zhao
|
||||
p.card-text 网络地址:
|
||||
code 10.10.10.80
|
||||
p.card-text
|
||||
| 核心温度:
|
||||
code#zhao_temp
|
||||
| ℃
|
||||
p.card-text
|
||||
| 系统负载:
|
||||
code#zhao_cpu
|
||||
| %
|
||||
p.card-text
|
||||
| 内存剩余:
|
||||
code#zhao_mem
|
||||
| MB
|
||||
.col(style="min-width:15rem;")
|
||||
.card.border-danger
|
||||
.card-header
|
||||
img(src='/images/raspberry.png', height='32')
|
||||
.card-body
|
||||
p.card-text 主机名称:
|
||||
code pi
|
||||
p.card-text 网络地址:
|
||||
code 10.10.10.42
|
||||
p.card-text
|
||||
| 核心温度:
|
||||
code#pi_temp
|
||||
| ℃
|
||||
p.card-text
|
||||
| 系统负载:
|
||||
code#pi_cpu
|
||||
| %
|
||||
p.card-text
|
||||
| 内存剩余:
|
||||
code#pi_mem
|
||||
| MB
|
||||
script.
|
||||
function get_rpis_status() {
|
||||
fetch(new Request('http://zhao/status'))
|
||||
.then(resp => resp.json())
|
||||
.then(data => {
|
||||
zhao_temp.innerText = data.cpu.temperature.toFixed(2)
|
||||
zhao_cpu.innerText = (data.cpu.load * 100).toFixed(2)
|
||||
zhao_mem.innerText = data.memory.available.toFixed(2)
|
||||
})
|
||||
fetch(new Request('http://pi/status'))
|
||||
.then(resp => resp.json())
|
||||
.then(data => {
|
||||
pi_temp.innerText = data.cpu.temperature.toFixed(2)
|
||||
pi_cpu.innerText = (data.cpu.load * 100).toFixed(2)
|
||||
pi_mem.innerText = data.memory.available.toFixed(2)
|
||||
})
|
||||
}
|
||||
setInterval(get_rpis_status, 1000)
|
33
views/layout.pug
Normal file
33
views/layout.pug
Normal file
@ -0,0 +1,33 @@
|
||||
doctype html
|
||||
html(lang='zh')
|
||||
head
|
||||
meta(charset='UTF-8')
|
||||
meta(http-equiv='X-UA-Compatible', content='IE=edge')
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
||||
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
||||
link(rel='stylesheet', href='/css/zhao.css')
|
||||
script(src='/socket.io/socket.io.min.js', defer)
|
||||
script(src='/js/bootstrap.bundle.min.js', defer)
|
||||
title 赵家小站
|
||||
body
|
||||
nav.navbar.navbar-expand-sm.navbar-light.bg-light
|
||||
.container-md
|
||||
a.navbar-brand(href='/')
|
||||
img(src="/favicon.ico", width=32)
|
||||
| 赵家小站
|
||||
button.navbar-toggler(type='button', data-bs-toggle='collapse', data-bs-target='#navbarNav', aria-controls='navbarNav', aria-expanded='false', aria-label='Toggle navigation')
|
||||
span.navbar-toggler-icon
|
||||
#navbarNav.collapse.navbar-collapse
|
||||
ul.navbar-nav
|
||||
li.nav-item
|
||||
a.nav-link(href='/chinese/poems') 背诗词
|
||||
li.nav-item.dropdown
|
||||
a.nav-link.dropdown-toggle(data-bs-toggle='dropdown', href='#', role='button', aria-haspopup='true', aria-expanded='false') 学习小组
|
||||
.dropdown-menu
|
||||
a.dropdown-item(href='/~xin/', target='_blank') 老爸
|
||||
a.dropdown-item(href='/~jun/', target='_blank') 鱼儿
|
||||
a.dropdown-item(href='/~yang/', target='_blank') 海洋
|
||||
.dropdown-divider
|
||||
a.dropdown-item(href='http://nas:3000/', target='_blank') 代码仓库
|
||||
.container-md.py-3
|
||||
block main
|
Loading…
Reference in New Issue
Block a user