npmrun 2 years ago
parent
commit
8372f4a127
  1. 1
      public/js/page/index.js
  2. 2
      route.txt
  3. 2
      source/plugins/index.ts
  4. 1
      source/run.ts
  5. 16
      template/htmx/path/index.pug
  6. 12
      template/layout/layout.pug
  7. 5
      template/views/index.pug

1
public/js/page/index.js

@ -0,0 +1 @@
console.log(2222)

2
route.txt

@ -1,4 +1,4 @@
/home/topuser/Code/@project/hapi-demo/source/route/views对应路径:
D:\1XYX\pro\hapi-demo\source\route\views对应路径:
不需权限(提供无需验证try): GET /404
不需权限(提供即需验证optional): GET /
不需权限(提供无需验证try): GET /about

2
source/plugins/index.ts

@ -24,7 +24,7 @@ const transport = pino.transport({
level: "trace",
options: {
destination: path.resolve(logsDir, "./pino.log"),
colorize: true,
colorize: false,
translateTime: 'HH:MM:ss.l mmmm dS yyyy "UTC"',
mkdir: true,
// append: false

1
source/run.ts

@ -164,7 +164,6 @@ const run = async (): Promise<Server> => {
server.ext('onPreResponse', (request, h) => {
const { response } = request
// 如果状态码为403,则调用自定义错误处理程序
if (response instanceof Boom && (response.output.statusCode < 200 || response.output.statusCode > 299)) {
return h.view('403.pug', { error: response})

16
template/htmx/path/index.pug

@ -9,7 +9,23 @@ 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
#modal-js-example.modal
.modal-background
.modal-card
header.modal-card-head
p.modal-card-title Modal title
button.delete(aria-label='close')
section.modal-card-body
p 是大大撒大撒
footer.modal-card-foot
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!

12
template/layout/layout.pug

@ -25,15 +25,3 @@ html(lang="zh-cn" class=hideHeader?"":"has-navbar-fixed-top")
+script("js/common/htmx.min.js")
+script("js/common/main.js")
block script
#modal-js-example.modal
.modal-background
.modal-card
header.modal-card-head
p.modal-card-title Modal title
button.delete(aria-label='close')
section.modal-card-body
p 是大大撒大撒
footer.modal-card-foot
button.button.is-success Save changes
button.button Cancel
button.modal-close.is-large(aria-label='close')

5
template/views/index.pug

@ -1,7 +1,4 @@
extends @/layout/single-page
block page
include @hxpath/index.pug
button.js-modal-trigger(data-target='modal-js-example').
Open JS example modal
include @hxpath/index.pug
Loading…
Cancel
Save