From e443df3b51e637baf1269aa55f5cb1a4dd395d75 Mon Sep 17 00:00:00 2001 From: 1549469775 <1549469775@qq.com> Date: Fri, 25 Feb 2022 22:47:21 +0800 Subject: [PATCH] god please --- log/SQL.log | 372 +++++++++++++++++++++++++++++++++++++++++ source/auth/index.ts | 27 +++ source/db/data.db | Bin 81920 -> 81920 bytes source/db/index.ts | 1 - source/route/api/user/index.ts | 2 +- source/route/index/index.ts | 4 +- source/route/route.txt | 2 +- source/run.ts | 2 +- source/schema/index.ts | 10 ++ source/validate.ts | 27 --- source/validateSchema/index.ts | 10 -- template/views/color.pug | 4 +- template/views/demo.ejs | 4 +- 13 files changed, 418 insertions(+), 47 deletions(-) create mode 100644 source/auth/index.ts create mode 100644 source/schema/index.ts delete mode 100644 source/validate.ts delete mode 100644 source/validateSchema/index.ts diff --git a/log/SQL.log b/log/SQL.log index cc60971..959fbe3 100644 --- a/log/SQL.log +++ b/log/SQL.log @@ -704,3 +704,375 @@ inMemory: 0, readWriteMode: 6 } +[2022-02-24T23:23:08.717] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyaxin' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyaxin'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-24T23:23:08.810] [DEBUG] SQL - Executing (default): INSERT INTO `Users` (`id`,`username`,`password`,`createdAt`,`updatedAt`) VALUES (NULL,$1,$2,$3,$4); { + plain: false, + raw: false, + logging: [Function: bound ], + hooks: true, + validate: true, + fields: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + defaultFields: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + returning: true, + hasTrigger: undefined, + dialect: 'sqlite', + dialectModule: null, + dialectModulePath: null, + protocol: 'tcp', + define: {}, + query: {}, + sync: {}, + timezone: '+00:00', + clientMinMessages: 'warning', + standardConformingStrings: true, + omitNull: false, + native: false, + replication: false, + ssl: undefined, + pool: {}, + quoteIdentifiers: true, + retry: { max: 5, match: [ 'SQLITE_BUSY: database is locked' ] }, + transactionType: 'DEFERRED', + isolationLevel: null, + databaseVersion: 0, + typeValidation: false, + benchmark: false, + minifyAliases: false, + logQueryParameters: false, + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + type: 'INSERT', + instance: User { + dataValues: { + id: null, + username: 'xieyaxin', + password: '$2b$10$YLkPy2gcnuP6vY7THjm/AOY2ep7qdybqP6T6hZbK3/Hd9ZzOAiyYa', + email: undefined, + updatedAt: 2022-02-24T15:23:08.805Z, + createdAt: 2022-02-24T15:23:08.805Z + }, + _previousDataValues: { username: undefined, password: undefined }, + _changed: Set(2) { 'username', 'password' }, + _options: { + isNewRecord: true, + _schema: null, + _schemaDelimiter: '', + attributes: undefined, + include: undefined, + raw: undefined, + silent: undefined + }, + isNewRecord: true + }, + model: User, + bind: [ + 'xieyaxin', + '$2b$10$YLkPy2gcnuP6vY7THjm/AOY2ep7qdybqP6T6hZbK3/Hd9ZzOAiyYa', + '2022-02-24 15:23:08.805 +00:00', + '2022-02-24 15:23:08.805 +00:00' + ], + uuid: 'default', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-24T23:38:02.696] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyaxin' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyaxin'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-24T23:38:25.085] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = '' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = ''", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:42:11.614] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:42:43.985] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:42:51.365] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:46:08.419] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:47:27.299] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:47:32.928] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:47:45.311] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:47:50.265] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:48:07.598] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:48:40.361] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyain' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyain'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:48:47.563] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`username` = 'xieyaxin' LIMIT 1; { + plain: true, + raw: false, + logging: [Function: bound ], + where: "`User`.`username` = 'xieyaxin'", + limit: 1, + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:48:47.657] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`id` = 4; { + plain: true, + raw: false, + logging: [Function: bound ], + where: '`User`.`id` = 4', + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T00:50:19.830] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`id` = 4; { + plain: true, + raw: false, + logging: [Function: bound ], + where: '`User`.`id` = 4', + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} +[2022-02-25T19:44:28.822] [DEBUG] SQL - Executing (default): SELECT `id`, `username`, `password`, `email`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`id` = 4; { + plain: true, + raw: false, + logging: [Function: bound ], + where: '`User`.`id` = 4', + hooks: true, + rejectOnEmpty: false, + originalAttributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + attributes: [ 'id', 'username', 'password', 'email', 'createdAt', 'updatedAt' ], + tableNames: [ 'Users' ], + type: 'SELECT', + model: User, + uuid: 'default', + storage: '/home/dash/code/demo/hapi-demo/source/db/data.db', + inMemory: 0, + readWriteMode: 6 +} diff --git a/source/auth/index.ts b/source/auth/index.ts new file mode 100644 index 0000000..102f8d0 --- /dev/null +++ b/source/auth/index.ts @@ -0,0 +1,27 @@ +import User from "@/model/User"; + +export async function validateJwt(decoded, request, h) { + if (decoded.id) { + const result = await User.findOne({ where: { id: decoded.id } }); + if (result == null) { + return { isValid: false }; + } + return { isValid: true }; + } else { + return { isValid: false }; + } +} + +export async function validateSession(request, session) { + console.log(`session id: ${session.id}`); + + if (session.id) { + const result = await User.findOne({ where: { id: session.id } }); + if (result == null) { + return { valid: false }; + } + return { valid: true, credentials: result }; + } else { + return { valid: false }; + } +} diff --git a/source/db/data.db b/source/db/data.db index 9e6c176da6de9b4edf5c69a38b697ebc4e398b64..6355ccc6fec4c697904f9e286a697db33d4d44b0 100644 GIT binary patch delta 200 zcmZo@U~On%ogmE^J5k1&F?M4@fjuM3=8N{m3%Hp1^ceUq^Xc)IZWa_!;M=VC&XTcS zkU_SQRo~OIA~Urzv7(WKg##qO029c}Q!z?XF*Hz#^vMpWG)hm-D-AF!i!=}M$ja4s z^p7-3Eif-ksZ1&iFbgruh)VJ{*7r!UjH>c?%&d$|G%_$U(ls#BH8N2!G_^7^wlc8L ZvoJ7K&^9ozGB5zi3S*Jp{PR6~006K~I0^s& delta 194 zcmZo@U~On%ogmE^Gf~EwF=k^zfjuMh=8N{m3%Hp0^ceUq^Xc*FZ59+z;M=VC&XTcy z4ufnXtG=gaMP_PcVnt@2icyk^p@E8fp=(iDaEfi<@tbdyr?ab7f_vp{a?biJ7Ijxv4{8p|o{6!gg0_Kym4N|BcCy!dE>5__=AZA`0|5URIEDZK diff --git a/source/db/index.ts b/source/db/index.ts index 4776b7d..f5c58ad 100644 --- a/source/db/index.ts +++ b/source/db/index.ts @@ -6,7 +6,6 @@ export const sequelize = new Sequelize({ logging: loggerSQL.debug.bind(loggerSQL) // Alternative way to use custom logger, displays all messages }); - export async function connect(){ try { await sequelize.authenticate(); diff --git a/source/route/api/user/index.ts b/source/route/api/user/index.ts index 1413501..103b293 100644 --- a/source/route/api/user/index.ts +++ b/source/route/api/user/index.ts @@ -11,7 +11,7 @@ import User from "@/model/User"; import * as bcrypt from "bcrypt"; import * as jwt from "jsonwebtoken"; import * as Joi from "joi"; -import { UserSchema } from "@/validateSchema"; +import { UserSchema } from "@/schema"; export default class { @validate({ diff --git a/source/route/index/index.ts b/source/route/index/index.ts index f18a1be..ae1f63d 100644 --- a/source/route/index/index.ts +++ b/source/route/index/index.ts @@ -40,7 +40,7 @@ export default class { const account = await User.findOne({ where: { username: username } }); if (!account || !(await bcrypt.compare(password, account.password))) { - return h.view("/login"); + return h.redirect("/login"); } request.cookieAuth.set({ id: account.id }); @@ -49,7 +49,7 @@ export default class { } @route("/about") - @auth() + @auth(false) about(request, h) { console.log(request.auth); return h.view("views/about.ejs"); diff --git a/source/route/route.txt b/source/route/route.txt index 3291b13..0c059a9 100644 --- a/source/route/route.txt +++ b/source/route/route.txt @@ -16,4 +16,4 @@ 需要权限: GET / 不需权限: GET /login 不需权限: POST /login - 需要权限: GET /about \ No newline at end of file + 不需权限: GET /about \ No newline at end of file diff --git a/source/run.ts b/source/run.ts index 934c546..6f9337c 100644 --- a/source/run.ts +++ b/source/run.ts @@ -2,7 +2,7 @@ import plugins from "@/plugins"; import path from "path"; import { baseDir, templateDir } from "@/util"; -import { validateJwt, validateSession } from "./validate"; +import { validateJwt, validateSession } from "./auth"; import Hapi, {Server} from "@hapi/hapi" // const Hapi = require("@hapi/hapi"); // const HapiSwagger = require("hapi-swagger"); diff --git a/source/schema/index.ts b/source/schema/index.ts new file mode 100644 index 0000000..2f97354 --- /dev/null +++ b/source/schema/index.ts @@ -0,0 +1,10 @@ +import * as Joi from "joi"; + +export const UserSchema = Joi.object({ + username: Joi.string().alphanum().min(6).max(35), + password: Joi.string().pattern(new RegExp("^[a-zA-Z0-9]{3,30}$")).required(), + email: Joi.string().email({ + minDomainSegments: 2, + tlds: { allow: ["com", "net"] }, + }), +}).or("username", "email"); diff --git a/source/validate.ts b/source/validate.ts deleted file mode 100644 index 102f8d0..0000000 --- a/source/validate.ts +++ /dev/null @@ -1,27 +0,0 @@ -import User from "@/model/User"; - -export async function validateJwt(decoded, request, h) { - if (decoded.id) { - const result = await User.findOne({ where: { id: decoded.id } }); - if (result == null) { - return { isValid: false }; - } - return { isValid: true }; - } else { - return { isValid: false }; - } -} - -export async function validateSession(request, session) { - console.log(`session id: ${session.id}`); - - if (session.id) { - const result = await User.findOne({ where: { id: session.id } }); - if (result == null) { - return { valid: false }; - } - return { valid: true, credentials: result }; - } else { - return { valid: false }; - } -} diff --git a/source/validateSchema/index.ts b/source/validateSchema/index.ts deleted file mode 100644 index 2f97354..0000000 --- a/source/validateSchema/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as Joi from "joi"; - -export const UserSchema = Joi.object({ - username: Joi.string().alphanum().min(6).max(35), - password: Joi.string().pattern(new RegExp("^[a-zA-Z0-9]{3,30}$")).required(), - email: Joi.string().email({ - minDomainSegments: 2, - tlds: { allow: ["com", "net"] }, - }), -}).or("username", "email"); diff --git a/template/views/color.pug b/template/views/color.pug index 2136921..20372cd 100644 --- a/template/views/color.pug +++ b/template/views/color.pug @@ -15,7 +15,7 @@ block content { color:"#999999",title: "辅助色",describe:"灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色"}, { color:"#999999",title: "辅助色",describe:"灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色"}, { color:"#999999",title: "辅助色",describe:"灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色灰色"}, - { color:"#999999",title: "辅助色",describe:""}, + { color:"#000000",title: "辅助色",describe:""}, { color:"#999999",title: "辅助色",describe:""}, { color:"#999999",title: "辅助色",describe:""}, { color:"#999999",title: "辅助色",describe:""}, @@ -35,7 +35,7 @@ block content ] each item in list div(class="color_item") - div(class="color_item_bg") + div(class="color_item_bg" style=`background: ${item.color}`) div(class="color_toggle_list") div(class="color_toggle_item") hex div(class="color_toggle_item") rgba diff --git a/template/views/demo.ejs b/template/views/demo.ejs index cd6b412..1ac7866 100644 --- a/template/views/demo.ejs +++ b/template/views/demo.ejs @@ -1,4 +1,4 @@ -
+
@@ -23,7 +23,7 @@ // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } - xmlhttp.open("POST", "/upload", true); + xmlhttp.open("POST", "/demo/upload", true); // 这里不需要自己加,会自己处理 // xmlhttp.setRequestHeader("Content-Type", "multipart/form-data");