From 160e42914ebd261d25cb6c7c863125e5020256c8 Mon Sep 17 00:00:00 2001 From: npmrun Date: Mon, 26 Jun 2023 10:23:53 +0800 Subject: [PATCH] add --- package.json | 4 ++-- public/style/views/404.css | 0 route.txt | 2 +- source/route/views/index.ts | 2 +- template/404.pug | 2 +- tsconfig.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 public/style/views/404.css diff --git a/package.json b/package.json index ef56041..93c6eec 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "zip": "node script/zip.js", "build": "tsc && tsc-alias", "start": "node -r dotenv/config dist/main.js dotenv_config_path=.env.production", - "dev": "tsx watch -r tsconfig-paths/register -r dotenv/config ./source/main.ts dotenv_config_path=.env.development", - "devb": "ts-node-dev --watch ./source/route --ignore-watch ./source/route/route.txt --respawn --project ./tsconfig.json -r tsconfig-paths/register -r dotenv/config ./source/main.ts dotenv_config_path=.env.development", + "devb": "tsx watch -r tsconfig-paths/register -r dotenv/config ./source/main.ts dotenv_config_path=.env.development", + "dev": "ts-node-dev --watch ./source/route --ignore-watch ./route.txt --respawn --project ./tsconfig.json -r tsconfig-paths/register -r dotenv/config ./source/main.ts dotenv_config_path=.env.development", "deva": "nodemon --exec 'ts-node --project ./tsconfig.json -r tsconfig-paths/register ./source/main.ts'", "test": "lab --require tsconfig-paths/register --typescript -P test -v" }, diff --git a/public/style/views/404.css b/public/style/views/404.css new file mode 100644 index 0000000..e69de29 diff --git a/route.txt b/route.txt index 6b5ce96..3977c2a 100644 --- a/route.txt +++ b/route.txt @@ -1,5 +1,5 @@ D:\1XYX\pro\hapi-demo\source\route\views对应路径: - 不需权限(提供无需验证try): GET /404 + 不需权限(提供即需验证optional): GET /404 不需权限(提供即需验证optional): GET / 不需权限(提供无需验证try): GET /about 需要权限 : POST /color/del diff --git a/source/route/views/index.ts b/source/route/views/index.ts index d53f27f..60e1b90 100644 --- a/source/route/views/index.ts +++ b/source/route/views/index.ts @@ -155,7 +155,7 @@ export default class Index { return h.redirect("/404?r=" + encodeURIComponent(req.raw.req.url)) } @route("/404") - @auth("try") + @auth("optional") async 404(request: Req, h: Res): ReturnValue { if (request.auth.isAuthenticated) { // 登录了 diff --git a/template/404.pug b/template/404.pug index 8d761b1..d5b5e27 100644 --- a/template/404.pug +++ b/template/404.pug @@ -1,7 +1,7 @@ extends layout/layout block head - link(rel="stylesheet", href="/public/css/views/404.css") + link(rel="stylesheet", href="/public/style/views/404.css") block content include @/helper/flush.pug diff --git a/tsconfig.json b/tsconfig.json index 92ff006..321fc2a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "sourceMap": false, "module": "commonjs", "experimentalDecorators": true, - "moduleResolution": "nodenext", + "moduleResolution": "Node", "esModuleInterop": true, // esModuleInterop选项的作用是支持使用import d from 'cjs'的方式引入commonjs包。 "baseUrl": ".", "paths": {