From 9611e33b82b686661341031c7082d7af106b0be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E4=BA=9A=E6=98=95?= <1549469775@qq.com> Date: Thu, 19 Jun 2025 09:51:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E4=BB=B6=E4=BB=A5=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=EF=BC=8C=E9=87=8D=E6=9E=84=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E4=B8=AD=E9=97=B4=E4=BB=B6=E5=B9=B6=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/development.sqlite3-shm | Bin 32768 -> 32768 bytes src/middlewares/Auth/auth.js | 9 +++++++-- src/middlewares/Views/index.js | 21 --------------------- src/views/htmx/fuck.pug | 5 ++++- src/views/index.pug | 12 ++++++++++++ 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/database/development.sqlite3-shm b/database/development.sqlite3-shm index 30b59383a59677fa2f9fd05e32d9b064c39c5d84..e1a0be2a4f4716941976cdba8127f040204e4ae6 100644 GIT binary patch delta 55 ucmZo@U}|V!;*@x#%K!!wIpqZ_j!odc { - const suffix = paths.ext - const state = Object.assign(locals, options, ctx.state || {}) - state.partials = Object.assign({}, options.partials || {}) - - if (isHtml(suffix) && !map) { - return send.getBody(ctx, paths.rel, { root: path }) - } - - const engineName = map && map[suffix] ? map[suffix] : suffix - const render = engineSource[engineName] - - if (!engineName || !render) { - return Promise.reject(new Error(`Engine not found for the ".${suffix}" file extension`)) - } - - return render(resolve(path, paths.rel), state) - }) - } - // 将 render 注入到 context 和 response 对象中 ctx.response.render = ctx.render = function (relPath, locals = {}) { return getPaths(path, relPath, extension).then(paths => { diff --git a/src/views/htmx/fuck.pug b/src/views/htmx/fuck.pug index 858d086..b27ccf8 100644 --- a/src/views/htmx/fuck.pug +++ b/src/views/htmx/fuck.pug @@ -1 +1,4 @@ -#{title || '默认标题'} \ No newline at end of file +if title + h1 #{title} +else + h1 默认标题 \ No newline at end of file diff --git a/src/views/index.pug b/src/views/index.pug index b03e8f5..b83b665 100644 --- a/src/views/index.pug +++ b/src/views/index.pug @@ -24,3 +24,15 @@ block pageContent a(href='https://your-website.com', target='_blank') i.fas.fa-globe.me-2 | 个人网站 + + // 登录表单区域 + .row.justify-content-center.mt-5 + .col-md-6 + form#loginForm(method="post" action="/api/login" hx-post="/api/login" hx-trigger="submit" hx-target="body" hx-swap="none" hx-on:htmx:afterRequest="if(event.detail.xhr.status===200){window.location='/';}") + .mb-3 + label.form-label(for="username") 用户名 + input.form-control(type="text" id="username" name="username" required) + .mb-3 + label.form-label(for="password") 密码 + input.form-control(type="password" id="password" name="password" required) + button.btn.btn-primary(type="submit") 登录