Browse Source

add pages

theme
npmrun 2 years ago
parent
commit
b2cf5898cf
  1. 4
      readme.md
  2. 4
      route.txt
  3. 4
      source/route/views/user.ts
  4. 2
      template/htmx/path/about.pug
  5. 7
      template/htmx/path/user.pug
  6. 2
      template/ui/header.pug
  7. 4
      template/views/user.pug

4
readme.md

@ -39,4 +39,6 @@ docker stop 容器ID
docker container prune docker container prune
docker image rm 镜像名 docker image rm 镜像名
docker image ls -a docker image ls -a
docker container ls -a docker container ls -a
https://blog.csdn.net/LIFENG0402/article/details/117930091

4
route.txt

@ -1,6 +1,6 @@
D:\1XYX\pro\hapi-demo\source\route\htmx对应路径: /home/topuser/Code/@project/hapi-demo/source/route/htmx对应路径:
不需权限 : GET /htmx/path/{path*} 不需权限 : GET /htmx/path/{path*}
D:\1XYX\pro\hapi-demo\source\route\views对应路径: /home/topuser/Code/@project/hapi-demo/source/route/views对应路径:
不需权限(提供无需验证): GET /404 不需权限(提供无需验证): GET /404
不需权限(提供无需验证): GET / 不需权限(提供无需验证): GET /
不需权限(提供无需验证): GET /about 不需权限(提供无需验证): GET /about

4
source/route/views/user.ts

@ -10,6 +10,7 @@ export default class {
@method("GET") @method("GET")
@auth() @auth()
async index(request: Req, h: Res): ReturnValue { async index(request: Req, h: Res): ReturnValue {
const isRenderHtmx = Reflect.has(request.query, "htmx")
const { id } = request.auth.credentials const { id } = request.auth.credentials
const User = request.getModel("User") const User = request.getModel("User")
let result = await User.findOne({ where: { id: id } }) let result = await User.findOne({ where: { id: id } })
@ -18,6 +19,9 @@ export default class {
} }
const userinfo = result.toJSON() const userinfo = result.toJSON()
delete userinfo.password delete userinfo.password
if (isRenderHtmx) {
return h.view("htmx/path/user.pug", { userinfo })
}
return h.view("views/user.pug", { userinfo }) return h.view("views/user.pug", { userinfo })
} }

2
template/htmx/path/about.pug

@ -5,7 +5,7 @@ block var
-title="关于" // 网页标题 -title="关于" // 网页标题
title 关于 title 关于
div about div aboutasdad
section.section section.section
.container .container
if user if user

7
template/htmx/path/user.pug

@ -0,0 +1,7 @@
include @/helper/helper.pug
block var
-title=user.nickname || "Welcome" // 网页标题
title #{user.nickname || "Welcome"}
div user

2
template/ui/header.pug

@ -36,7 +36,7 @@ nav.is-fixed-top.navbar(role='navigation', aria-label='main navigation', style="
a.navbar-link a.navbar-link
div #{user.nickname} div #{user.nickname}
.navbar-dropdown.is-right .navbar-dropdown.is-right
a.navbar-item a.navbar-item(hx-get="/user?htmx" hx-push-url="/user" hx-trigger="click" hx-target="#single-page" hx-swap="innerHTML")
| 用户资料 | 用户资料
hr.navbar-divider hr.navbar-divider
a.navbar-item(href="/user/logout") a.navbar-item(href="/user/logout")

4
template/views/user.pug

@ -0,0 +1,4 @@
extends @/layout/single-page
block page
include @hxpath/user.pug
Loading…
Cancel
Save