Browse Source

修改

develop
npmrun 2 years ago
parent
commit
ad3f10e32f
  1. BIN
      data/data.db
  2. 67
      public/js/common/main.js
  3. 47
      public/js/page/index.js
  4. BIN
      public/upload/7ZKwRVLAZjvE4Q1TiaFKyNyl.jpg
  5. BIN
      public/upload/DfSnBa86Z1esxB5TZ4YWVi-i.jpg
  6. BIN
      public/upload/LbD5KJJ1nIdAJjrCSCpigySZ.jpg
  7. BIN
      public/upload/WHS-v_iuvglYsGar7Pysc5cG.jpg
  8. BIN
      public/upload/qF_hiQxR_hrv30spi7L-jM_4.jpg
  9. 46
      source/route/func/index.ts
  10. 1
      template/helper/flush.pug
  11. 6
      template/helper/helper.pug
  12. 50
      template/htmx/path/color.pug
  13. 35
      template/htmx/path/index.pug
  14. 48
      template/htmx/ui/color-list.pug
  15. 2
      template/layout/layout.pug
  16. 2
      template/layout/single-page.pug
  17. 17
      template/ui/header.pug
  18. 26
      template/ui/tree.pug

BIN
data/data.db

Binary file not shown.

67
public/js/common/main.js

@ -1,67 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0)
// Add a click event on each of them
$navbarBurgers.forEach(el => {
el.addEventListener("click", () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target
const $target = document.getElementById(target)
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle("is-active")
$target.classList.toggle("is-active")
})
})
})
document.addEventListener("DOMContentLoaded", () => {
// Functions to open and close a modal
function openModal($el) {
$el.classList.add("is-active")
}
function closeModal($el) {
$el.classList.remove("is-active")
}
function closeAllModals() {
;(document.querySelectorAll(".modal") || []).forEach($modal => {
closeModal($modal)
})
}
// Add a click event on buttons to open a specific modal
;(document.querySelectorAll(".js-modal-trigger") || []).forEach($trigger => {
const modal = $trigger.dataset.target
const $target = document.getElementById(modal)
$trigger.addEventListener("click", () => {
openModal($target)
})
})
// Add a click event on various child elements to close the parent modal
;(
document.querySelectorAll(
".modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button",
) || []
).forEach($close => {
const $target = $close.closest(".modal")
$close.addEventListener("click", () => {
closeModal($target)
})
})
// Add a keyboard event to close all modals
document.addEventListener("keydown", event => {
const e = event || window.event
if (e.keyCode === 27) {
// Escape key
closeAllModals()
}
})
})

47
public/js/page/index.js

@ -1 +1,46 @@
console.log(2222)
// Functions to open and close a modal
function openModal($el) {
$el.classList.add("is-active")
}
function closeModal($el) {
$el.classList.remove("is-active")
}
function closeAllModals() {
;(document.querySelectorAll(".modal") || []).forEach($modal => {
closeModal($modal)
})
}
// Add a click event on buttons to open a specific modal
;(document.querySelectorAll(".js-modal-trigger") || []).forEach($trigger => {
const modal = $trigger.dataset.target
const $target = document.getElementById(modal)
$trigger.addEventListener("click", () => {
openModal($target)
})
})
// Add a click event on various child elements to close the parent modal
;(
document.querySelectorAll(".modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button") ||
[]
).forEach($close => {
const $target = $close.closest(".modal")
$close.addEventListener("click", () => {
closeModal($target)
})
})
// Add a keyboard event to close all modals
document.addEventListener("keydown", event => {
const e = event || window.event
if (e.keyCode === 27) {
// Escape key
closeAllModals()
}
})

BIN
public/upload/7ZKwRVLAZjvE4Q1TiaFKyNyl.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/upload/DfSnBa86Z1esxB5TZ4YWVi-i.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/upload/LbD5KJJ1nIdAJjrCSCpigySZ.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/upload/WHS-v_iuvglYsGar7Pysc5cG.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/upload/qF_hiQxR_hrv30spi7L-jM_4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

46
source/route/func/index.ts

@ -0,0 +1,46 @@
import { auth } from "@noderun/hapi-router"
import { Req, Res, ReturnValue } from "#/global"
import { exec } from "child_process"
export default class Index {
@auth(false)
async index(request: Req, h: Res): ReturnValue {
exec("git pull", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
if (stderr) {
console.log(`stderr: ${stderr}`)
return
}
console.log(`stdout: ${stdout}`)
exec('pkill -f "node"', (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
if (stderr) {
console.log(`stderr: ${stderr}`)
return
}
console.log(`stdout: ${stdout}`)
exec("pnpm start", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
if (stderr) {
console.log(`stderr: ${stderr}`)
return
}
console.log(`stdout: ${stdout}`)
})
})
})
return h.response().code(200)
}
}

1
template/helper/flush.pug

@ -1,5 +1,4 @@
//- 服务器反馈UI
include @/helper/helper.pug
if flash
- index = 0
if flash.error

6
template/helper/helper.pug

@ -1,7 +1,11 @@
mixin css(href)
link(rel="stylesheet", href="/public/"+href)
mixin script(src)
script(src="/public/"+src)
mixin security
include ./form_security.pug
include ./form_security.pug
mixin flush
include ./flush.pug

50
template/htmx/path/color.pug

@ -1,13 +1,11 @@
include @/helper/flush.pug
include @/helper/helper.pug
+flush()
block var
-title="颜色" // 网页标题
title 颜色
div(class="container page")
style
:public style/views/color.css
if isLogin
form(action="/color" method="post" style="margin: 0 auto; width: 500px;margin-top: 50px")
h1 提交新颜色
@ -32,47 +30,5 @@ div(class="container page")
//- div(class=".wrapper_input"): input(type="text" tabindex="1" value="sadsa" name="a")
//- div(class=".wrapper_input"): input(type="text" tabindex="3" value="sadsa" name="b")
//- button(type="submit" tabindex="2") 提交
h1 颜色表 #{temp.a}
div(class="color_list")
//- -
//- var list=[
//- { color:"#00ffff",title: "青色",describe:""},
//- { color:"#222222",title: "辅助色",describe:""},
//- { color:"#8f8f8f",title: "辅助色",describe:""},
//- { color:"#00d1b2",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- ]
if list.length === 0
div 空
each item in list
div(class="color_item")
div(class="color_item_bg" style=`background: ${item.value}`)
div(class="color_toggle_list")
div(class="color_toggle_item") hex
div(class="color_toggle_item") rgba
div(class="color_item_name") #{item.color}
div(class="color_item_content")
div(class="color_item_title") #{item.name}
div(class="color_item_desc" title=item.desctibe) #{item.desctibe || "暂无描述"}
if isLogin
form(action="/color/del" method="post")
+security
input(type="text" value=item.id name="id" hidden)
button(type="submit" style="background: transparent;border:0;color:red;cursor: pointer;float: right;") 删除
//- div(class="color_item")
//- img(src="/public/image/add.png", alt="添加" title="添加" class="color_add")
.color-content
include @/htmx/ui/color-list.pug

35
template/htmx/path/index.pug

@ -1,5 +1,5 @@
include @/helper/flush.pug
include @/helper/helper.pug
+flush()
title 首页
block var
@ -9,8 +9,6 @@ block page
div
style
:public style/views/index.css
script
:public js/page/index.js
.content!= md
button.js-modal-trigger(data-target='modal-js-example').
Open JS example modal
@ -26,31 +24,6 @@ block page
button.button.is-success Save changes
button.button Cancel
button.modal-close.is-large(aria-label='close')
//- if isLogin
//- button(hx-target="#single-page" hx-get="/about?htmx" hx-push-url="/about" hx-trigger="click" hx-swap="innerHTML") Click Me!
//- .tree#tree
//- details(open="true" style="direction: ltr;")
//- summary
//- span.tree-item sad
//- a.op(href="") 新建
//- details(open="true")
//- summary
//- span.tree-item sad
//- a.op(href="") 新建
//- details
//- summary
//- span.tree-item.tree-md-file
//- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
//- a.op(href="") 新建
//- details
//- summary
//- span.tree-item.tree-md-file
//- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
//- a.op(href="") 新建
//- details
//- summary
//- span.tree-item.tree-md-file.active
//- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
//- a.op(href="") 新建
script
:public js/page/index.js
include @/ui/tree.pug

48
template/htmx/ui/color-list.pug

@ -0,0 +1,48 @@
style
:public style/views/color.css
h1 颜色表 #{temp.a}
div(class="color_list")
//- -
//- var list=[
//- { color:"#00ffff",title: "青色",describe:""},
//- { color:"#222222",title: "辅助色",describe:""},
//- { color:"#8f8f8f",title: "辅助色",describe:""},
//- { color:"#00d1b2",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- { color:"#999999",title: "辅助色",describe:""},
//- ]
if list.length === 0
div 空
each item in list
div(class="color_item")
div(class="color_item_bg" style=`background: ${item.value}`)
div(class="color_toggle_list")
div(class="color_toggle_item") hex
div(class="color_toggle_item") rgba
div(class="color_item_name") #{item.color}
div(class="color_item_content")
div(class="color_item_title") #{item.name}
div(class="color_item_desc" title=item.desctibe) #{item.desctibe || "暂无描述"}
if isLogin
form(action="/color/del" method="post")
+security
input(type="text" value=item.id name="id" hidden)
button(type="submit" style="background: transparent;border:0;color:red;cursor: pointer;float: right;") 删除
//- div(class="color_item")
//- img(src="/public/image/add.png", alt="添加" title="添加" class="color_add")

2
template/layout/layout.pug

@ -1,6 +1,5 @@
doctype html
include @/helper/helper.pug
include @/helper/flush.pug
block var
html(lang="zh-cn" class=hideHeader?"":"has-navbar-fixed-top")
@ -23,5 +22,4 @@ html(lang="zh-cn" class=hideHeader?"":"has-navbar-fixed-top")
block content
//- script(src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous")
+script("js/common/htmx.min.js")
+script("js/common/main.js")
block script

2
template/layout/single-page.pug

@ -1,6 +1,6 @@
extends @/layout/layout
block content
section.section
main
.container(id="single-page")
block page

17
template/ui/header.pug

@ -49,3 +49,20 @@ nav.is-fixed-top.navbar(role='navigation', aria-label='main navigation', style="
+security
a.navbar-item
button(type="submit") 删除
script.
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0)
// Add a click event on each of them
$navbarBurgers.forEach(el => {
el.addEventListener("click", () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target
const $target = document.getElementById(target)
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle("is-active")
$target.classList.toggle("is-active")
})
})

26
template/ui/tree.pug

@ -0,0 +1,26 @@
.tree#tree
details(open="true" style="direction: ltr;")
summary
span.tree-item sad
a.op(href="") 新建
details(open="true")
summary
span.tree-item sad
a.op(href="") 新建
details
summary
span.tree-item.tree-md-file
div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
a.op(href="") 新建
details
summary
span.tree-item.tree-md-file
div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
a.op(href="") 新建
details
summary
span.tree-item.tree-md-file.active
div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda
a.op(href="") 新建
Loading…
Cancel
Save