diff --git a/app.js b/app.js index 4f55181..c1ea306 100644 --- a/app.js +++ b/app.js @@ -206,10 +206,6 @@ app.use("/user", router_register); var router_admin = require("./server/router_my.js"); app.use("/my", router_admin); -//系统平台路由 -var router_admin = require("./server/router_admin.js"); -app.use("/admin", router_admin); - //搜索api var router_search = require("./server/router_search.js"); app.use("/searchapi", router_search); @@ -232,20 +228,6 @@ app.use("/project", router_project); //项目处理路由 var router_comment = require("./server/router_comment.js"); app.use("/comment", router_comment); -app.get("/about", function (req, res, next) { - res.render("about.ejs"); -}); -app.get("/share", function (req, res, next) { - res.render("share.ejs"); -}); - -app.get("/search", function (req, res, next) { - res.render("search.ejs"); -}); - -//python路由 -var router_python = require("./server/router_python.js"); -app.use("/python", router_python); app.get("/check", function (req, res, next) { res.status(200).json({ @@ -270,7 +252,12 @@ app.use((err, req, res, next) => { //放在最后,友好的处理地址不存在的访问 app.all("*", function (req, res, next) { res.locals.tipType = "访问错误"; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); + }); module.exports = app; diff --git a/data/material/asset/0a5b8c55b5ef147f5fdf67ddab3bab28.svg b/data/material/asset/0a5b8c55b5ef147f5fdf67ddab3bab28.svg deleted file mode 100644 index 62c6225..0000000 --- a/data/material/asset/0a5b8c55b5ef147f5fdf67ddab3bab28.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/data/material/asset/12b7c852e83a2846942cb2ceb6c549d7.png b/data/material/asset/12b7c852e83a2846942cb2ceb6c549d7.png deleted file mode 100644 index 61a8875..0000000 Binary files a/data/material/asset/12b7c852e83a2846942cb2ceb6c549d7.png and /dev/null differ diff --git a/data/material/asset/365a43dce18a8020c6e2ba44f4507836.svg b/data/material/asset/365a43dce18a8020c6e2ba44f4507836.svg deleted file mode 100644 index 716826f..0000000 --- a/data/material/asset/365a43dce18a8020c6e2ba44f4507836.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/data/material/asset/7cb4e1f10e1b712eed814f04b40c7882.svg b/data/material/asset/7cb4e1f10e1b712eed814f04b40c7882.svg deleted file mode 100644 index e4ad29a..0000000 --- a/data/material/asset/7cb4e1f10e1b712eed814f04b40c7882.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/data/material/asset/91550946e41f0cf939ea8ddbc5a35b8d.png b/data/material/asset/91550946e41f0cf939ea8ddbc5a35b8d.png deleted file mode 100644 index e1998f6..0000000 Binary files a/data/material/asset/91550946e41f0cf939ea8ddbc5a35b8d.png and /dev/null differ diff --git a/data/material/asset/adeaea1c79253e30052b63462c885a53.png b/data/material/asset/adeaea1c79253e30052b63462c885a53.png deleted file mode 100644 index 87c47b7..0000000 Binary files a/data/material/asset/adeaea1c79253e30052b63462c885a53.png and /dev/null differ diff --git a/data/material/asset/bd76d9bb4699c3e431fb43315283eb4e.png b/data/material/asset/bd76d9bb4699c3e431fb43315283eb4e.png deleted file mode 100644 index 5d3704d..0000000 Binary files a/data/material/asset/bd76d9bb4699c3e431fb43315283eb4e.png and /dev/null differ diff --git a/data/material/asset/d08d9631057826d5e83c0ef13c844f2c.png b/data/material/asset/d08d9631057826d5e83c0ef13c844f2c.png deleted file mode 100644 index ae8a8bf..0000000 Binary files a/data/material/asset/d08d9631057826d5e83c0ef13c844f2c.png and /dev/null differ diff --git a/data/material/asset/f4f02527595957f021eca4b4bcdc5b45.svg b/data/material/asset/f4f02527595957f021eca4b4bcdc5b45.svg deleted file mode 100644 index 4069e52..0000000 --- a/data/material/asset/f4f02527595957f021eca4b4bcdc5b45.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/data/upload_tmp/-O_f2MCqcNuLSJ-rCl8mRwU7.webp b/data/upload_tmp/-O_f2MCqcNuLSJ-rCl8mRwU7.webp deleted file mode 100644 index a701c19..0000000 Binary files a/data/upload_tmp/-O_f2MCqcNuLSJ-rCl8mRwU7.webp and /dev/null differ diff --git a/data/upload_tmp/Sylosv78BeOaO5J-HwshiAKd.original b/data/upload_tmp/Sylosv78BeOaO5J-HwshiAKd.original deleted file mode 100644 index 8132fe6..0000000 Binary files a/data/upload_tmp/Sylosv78BeOaO5J-HwshiAKd.original and /dev/null differ diff --git a/data/upload_tmp/bPExd9Zi7VKQ5FIvSFQDKLYn b/data/upload_tmp/bPExd9Zi7VKQ5FIvSFQDKLYn deleted file mode 100644 index 3e0b06d..0000000 Binary files a/data/upload_tmp/bPExd9Zi7VKQ5FIvSFQDKLYn and /dev/null differ diff --git a/data/upload_tmp/gJkgHghb4BcEmrmP89tPX66l.webp b/data/upload_tmp/gJkgHghb4BcEmrmP89tPX66l.webp deleted file mode 100644 index 34f5ba7..0000000 Binary files a/data/upload_tmp/gJkgHghb4BcEmrmP89tPX66l.webp and /dev/null differ diff --git a/data/upload_tmp/ulFgB7e0JFp7f4T7zQfeK8ha b/data/upload_tmp/ulFgB7e0JFp7f4T7zQfeK8ha deleted file mode 100644 index 3e0b06d..0000000 Binary files a/data/upload_tmp/ulFgB7e0JFp7f4T7zQfeK8ha and /dev/null differ diff --git a/data/upload_tmp/vY5xvnoDu4gSPQ1EEuzq2c1n.webp b/data/upload_tmp/vY5xvnoDu4gSPQ1EEuzq2c1n.webp deleted file mode 100644 index 34f5ba7..0000000 Binary files a/data/upload_tmp/vY5xvnoDu4gSPQ1EEuzq2c1n.webp and /dev/null differ diff --git a/data/upload_tmp/zEv8nHojae-h0eweDNxjNvuq.webp b/data/upload_tmp/zEv8nHojae-h0eweDNxjNvuq.webp deleted file mode 100644 index 34f5ba7..0000000 Binary files a/data/upload_tmp/zEv8nHojae-h0eweDNxjNvuq.webp and /dev/null differ diff --git a/data/user/1 b/data/user/1 deleted file mode 100644 index 3e0b06d..0000000 Binary files a/data/user/1 and /dev/null differ diff --git a/server/router_account.js b/server/router_account.js index 347de14..335d70b 100644 --- a/server/router_account.js +++ b/server/router_account.js @@ -33,26 +33,9 @@ router.all("*", function (req, res, next) { } })(); */ -const request = require("request"); -router.get("/", function (req, res) { - res.render("user.ejs"); -}); -router.get("/login", function (req, res, next) { - var SQL = `SELECT id FROM sys_ini WHERE iniKey='regist' AND iniValue=1 LIMIT 1`; - DB.query(SQL, function (err, Regist) { - if (err || Regist.length == 0) { - res.locals.reg = 0; - } else { - res.locals.reg = 1; - } - res.render("login_or_register.ejs"); - }); -}); -router.get("/repw", function (req, res) { - res.render("repw.ejs"); -}); + const geetest = require("./lib/captcha/geetest.js"); //geetest, router.post("/login", async function (req, res, next) { diff --git a/server/router_admin.js b/server/router_admin.js deleted file mode 100644 index 51fa0e1..0000000 --- a/server/router_admin.js +++ /dev/null @@ -1,1913 +0,0 @@ -const configManager = require("./configManager"); - -var express = require("express"); -var router = express.Router(); -var fs = require("fs"); - -//功能函数集 -var I = require("./lib/global.js"); - -//数据库 -var DB = require("./lib/database.js"); - -router.all("*", function (req, res, next) { - if (!res.locals.login) { - res.render("404.ejs"); - return; - } - - if (res.locals["is_admin"] != 1) { - res.render("404.ejs"); - return; - } - - next(); -}); -//平台首页 -router.get("/", function (req, res, next) { - try { - res.render("admin/admin_index.ejs"); - } catch (err) { - next(err); - } -}); -//平台默认首页 -router.get("/default", function (req, res, next) { - try { - res.render("admin/admin_default.ejs"); - } catch (err) { - next(err); - } -}); - -//平台概况 -router.get("/info", function (req, res, next) { - try { - var SQL = - `SELECT ` + - ` (SELECT count(id) FROM ow_users ) AS user_count, ` + - ` (SELECT count(id) FROM ow_projects WHERE type='scratch') AS scratch_count, ` + - ` (SELECT count(id) FROM ow_projects WHILE type='python) AS python_count, ` + - ` (SELECT count(id) FROM material_backdrop) AS backdrop_count, ` + - ` (SELECT count(id) FROM material_sprite) AS sprite_count `; - DB.query(SQL, function (err, d) { - if (err || d.length == 0) { - res.locals["user_count"] = 0; - res.locals["scratch_count"] = 0; - res.locals["python_count"] = 0; - res.locals["backdrop_count"] = 0; - res.locals["sprite_count"] = 0; - } else { - res.locals["user_count"] = d[0].user_count; - res.locals["scratch_count"] = d[0].scratch_count; - res.locals["python_count"] = d[0].python_count; - res.locals["backdrop_count"] = d[0].backdrop_count; - res.locals["sprite_count"] = d[0].sprite_count; - } - - res.render("admin/admin_info.ejs"); - }); - } catch (err) { - next(err); - } -}); - -//用户管理 -router.get("/user", function (req, res, next) { - try { - var SQL = `SELECT id FROM sys_ini WHERE iniKey='regist' AND iniValue=1 LIMIT 1`; - DB.query(SQL, function (err, data) { - if (err || data.length == 0) { - res.locals.regist = 0; - } else { - res.locals.regist = 1; - } - res.render("admin/admin_user.ejs"); - }); - } catch (err) { - next(err); - } -}); -//用户管理:数据。0正常用户,2封号用户 -router.get("/user/data", function (req, res, next) { - try { - var state = parseInt(req.query["s"]); - if (state == 9) { - //0:正常用户,2:封号用户,9:查找用户 - var SQL = `SELECT count(id) AS c FROM ow_users WHERE email LIKE '%${req.query.t}%'`; - } else { - var SQL = `SELECT count(id) AS c FROM ow_users WHERE state=${state}`; - } - DB.query(SQL, function (err, count) { - if (err || count.length == 0 || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - - if (state == 9) { - //0:正常用户,2:封号用户,9:查找用户 - SQL = `SELECT id,email,display_name,state,regTime FROM ow_users WHERE email LIKE '%${ - req.query.t - }%' LIMIT ${(page - 1) * limit}, ${limit}`; - } else { - SQL = `SELECT id,email,display_name,state,regTime FROM ow_users WHERE state=${state} LIMIT ${ - (page - 1) * limit - }, ${limit}`; - } - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -//管理员重置用户密码 -router.post("/user_setpassword", function (req, res, next) { - try { - if (!req.body.pw || !req.body.un || !I.userpwTest(req.body.pw)) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - return; - } - - //对密码进行加密 - let pw = I.hash(req.body.pw); - var UPDATE = `UPDATE ow_users SET password='${pw}' WHERE email='${req.body["un"]}' LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - } else { - res.status(200).send({ status: "success", msg: "密码重置成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//用户管理:功能.0解封 2封号 -router.post("/user_setstate", function (req, res, next) { - try { - var state = 0; - if (req.body["s"] == undefined || req.body["s"] != 0) { - state = 2; //未知时,都当作封号处理 - } - //var state = parseInt(req.body['s']); - var UPDATE = `UPDATE ow_users SET state=${state} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - } else { - res.status(200).send({ status: "success", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//用户管理:创建新用户,功能 -router.post("/user_new", function (req, res, next) { - try { - if (!req.body.un || !I.emailTest(req.body.un)) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - return; - } - //检查账户是否已存在 - var SQL = `SELECT id FROM ow_users WHERE email='${req.body.un}' LIMIT 1`; - DB.query(SQL, function (err, User) { - if (err) { - res.status(200).send(msg_fail); - return; - } - if (User.length != 0) { - res.status(200).send({ status: "fail", msg: "该账户已存在" }); - return; - } - - //对密码进行加密:默认密码为用户手机号后8位 - var nn = req.body.un.substring(req.body.un.length - 6); //昵称 - var pw = nn; //req.body.un.substring(req.body.un.length-6);//初始密码 - pw = I.hash(pw); - SQL = `INSERT INTO ow_users (email,password,display_name) VALUES ('${req.body.un}','${pw}','${nn}')`; - DB.query(SQL, function (err, newUser) { - if (err) { - res.status(200).send({ status: "fail", msg: "再试一次" }); - return; - } - - oldpath = "./build/img/user_default_icon.png"; - newpath = "./data/user/" + newUser.insertId + ".png"; - let oldFile = fs["createReadStream"](oldpath); - let newFile = fs["createWriteStream"](newpath); - oldFile["pipe"](newFile); - - res.status(200).send({ status: "success", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); -//用户管理:批量创建新用户,功能 -router.post("/user_new100", function (req, res, next) { - try { - const qz = req.body.qz; - const sl = req.body.sl; - var reg = /^(?:\d+|[a-zA-Z]+){4,8}$/; - if (!reg["test"](qz)) { - res.status(200).send({ status: "x", msg: "前缀格式不正确" }); - return; - } - - reg = /^([0-9]+){1,3}$/; - if (!reg["test"](sl)) { - res.status(200).send({ status: "x", msg: "数量不正确:1~100" }); - return; - } - - if (sl == 0 || sl > 100) { - res.status(200).send({ status: "x", msg: "数量不正确:1~100" }); - return; - } - - // 生成账户 - - for (var i = 0; i < sl; i++) { - if (i < 10) { - un = qz + "0" + i; - } else { - un = qz + i; - } - - var pw = un.substring(un.length - 6); //初始密码 - pw = I.hash(pw); - SQL = `INSERT INTO ow_users (email, password, display_name) VALUES ('${un}','${pw}','${un}')`; - DB.query(SQL, function (err, newUser) { - if (err) { - return; - } - }); - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - } catch (err) { - next(err); - } -}); - -//用户管理:开启、关闭用户注册通道 -router.post("/user/setRegist", function (req, res, next) { - try { - let v = 1; - if (req.body.v != 1) { - v = 0; - } - - var SQL = `UPDATE sys_ini SET iniValue=${v} WHERE iniKey='regist' LIMIT 1`; - DB.query(SQL, function (err, User) { - if (err) { - res.status(200).send({ status: "x", msg: "数据错误" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); - -//作品管理:Scratch页面 -router.get("/works/scratch", function (req, res, next) { - try { - res.render("admin/admin_works_scratch.ejs"); - } catch (err) { - next(err); - } -}); -//作品管理:Scratch数据 -router.get("/works/scratch/data", function (req, res, next) { - try { - WHERE = ""; - NICKNAME = ""; //根据昵称查找 - if (req.query.w == "search_state0") { - WHERE = ` WHERE scratch.state='private' `; - } else if (req.query.w == "search_state1") { - WHERE = ` WHERE scratch.state='public' `; - } else if (req.query.w == "search_state2") { - WHERE = ` WHERE scratch.state='public' `; - } else if (req.query.w == "search_workname") { - WHERE = ` WHERE scratch.title LIKE '%${req.query.v}%' `; - } else if (req.query.w == "search_display_name") { - NICKNAME = ` AND ow_users.display_name LIKE '%${req.query.v}%' `; - } - - if (NICKNAME == "") { - var SQL = `SELECT count(id) AS c FROM scratch ${WHERE}`; - } else { - var SQL = - `SELECT count(scratch.id) AS c FROM scratch ` + - ` INNER JOIN ow_users ON (ow_users.id=scratch.authorid ${NICKNAME}) `; - } - DB.query(SQL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = - `SELECT scratch.id, scratch.state, scratch.title, scratch.time, ow_users.email, ow_users.display_name FROM scratch ` + - ` INNER JOIN ow_users ON (ow_users.id=scratch.authorid ${NICKNAME}) ` + - ` ${WHERE} ORDER BY scratch.time DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -//作品管理:设置作品的标题 -router.post("/works/scratch/changeTitle", function (req, res, next) { - try { - var UPDATE = `UPDATE scratch SET title=? WHERE id=${req.body.id} LIMIT 1`; - var SET = [`${req.body.t}`]; - DB.qww(UPDATE, SET, function (err, d) { - if (err) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - } else { - res.status(200).send({ status: "success", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//作品管理:设置作品的发布状态 -router.post("/works/scratch/setState", function (req, res, next) { - try { - if (req.body.s == undefined || req.body.s < 0 || 2 < req.body.s) { - s = 0; //未知时,都当作取消推荐处理 - } else { - s = req.body.s; - } - - var UPDATE = `UPDATE scratch SET state=${s} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "failed", msg: "再试一次" }); - } else { - res.status(200).send({ status: "success", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//作品管理:复制作品为默认作品 -router.post("/works/scratch/setDefaultWork", function (req, res, next) { - try { - if (!req.body.id || req.body.id == 1) { - // 客服端传参数问题 - res.status(200).send({ status: "ok", msg: "操作成功" }); - return; - } - - const SELECT = `SELECT title, src FROM scratch WHERE id=${req.body.id}`; - DB.query(SELECT, function (err, d) { - if (err || d.length == 0) { - res.status(200).send({ status: "x", msg: "再试一次" }); - return; - } - - const UPDATE = `UPDATE scratch SET title=?, src=? WHERE id=1`; - const VAL = [d[0].title, d[0].src]; - DB.qww(UPDATE, VAL, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - }); - } catch (err) { - next(err); - } -}); - -//作品管理:Python页面 -router.get("/works/python", function (req, res, next) { - try { - res.render("admin/admin_works_python.ejs"); - } catch (err) { - next(err); - } -}); -//作品管理:Python数据 -router.get("/works/python/data", function (req, res, next) { - try { - WHERE = ""; - NICKNAME = ""; //根据昵称查找 - if (req.query.w == "search_state0") { - WHERE = ` WHERE python.state='private' `; - } else if (req.query.w == "search_state1") { - WHERE = ` WHERE python.state='public' `; - } else if (req.query.w == "search_state2") { - WHERE = ` WHERE python.state='public' `; - } else if (req.query.w == "search_workname") { - WHERE = ` WHERE python.title LIKE '%${req.query.v}%' `; - } else if (req.query.w == "search_display_name") { - NICKNAME = ` AND ow_users.display_name LIKE '%${req.query.v}%' `; - } - - if (NICKNAME == "") { - var SQL = `SELECT count(id) AS c FROM python ${WHERE}`; - } else { - var SQL = - `SELECT count(python.id) AS c FROM python ` + - ` INNER JOIN ow_users ON (ow_users.id=python.authorid ${NICKNAME}) `; - } - DB.query(SQL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = - `SELECT python.id, python.state, python.title, python.time, ow_users.email, ow_users.display_name FROM python ` + - ` INNER JOIN ow_users ON (ow_users.id=python.authorid ${NICKNAME}) ` + - ` ${WHERE} ORDER BY python.time DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -//作品管理:Python 设置作品的标题 -router.post("/works/python/changeTitle", function (req, res, next) { - try { - var UPDATE = `UPDATE python SET title=? WHERE id=${req.body.id} LIMIT 1`; - var SET = [`${req.body.t}`]; - DB.qww(UPDATE, SET, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//作品管理:Python设置作品的发布状态 -router.post("/works/python/setState", function (req, res, next) { - try { - if (req.body.s == undefined || req.body.s < 0 || 2 < req.body.s) { - s = 0; //未知时,都当作取消推荐处理 - } else { - s = req.body.s; - } - - var UPDATE = `UPDATE python SET state=${s} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); -//作品管理:Python复制作品为默认作品 -router.post("/works/python/setDefaultWork", function (req, res, next) { - try { - if (!req.body.id || req.body.id == 1) { - // 客服端传参数问题 - res.status(200).send({ status: "ok", msg: "操作成功" }); - return; - } - - const SELECT = `SELECT title, src FROM python WHERE id=${req.body.id}`; - DB.query(SELECT, function (err, d) { - if (err || d.length == 0) { - res.status(200).send({ status: "x", msg: "再试一次" }); - return; - } - - const UPDATE = `UPDATE python SET title=?, src=? WHERE id=1`; - const VAL = [d[0].title, d[0].src]; - DB.qww(UPDATE, VAL, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - }); - } catch (err) { - next(err); - } -}); - -// 素材分类管理:数据 -router.get("/material/tag", function (req, res, next) { - try { - res.render("admin/admin_tag.ejs"); - } catch (err) { - next(err); - } -}); -// 素材分类管理:数据 -router.get("/material/tag/data", function (req, res, next) { - try { - var type = parseInt(req.query["t"]); - if (!type || type < 1 || 4 < type) { - // 1背景、2角色、3造型、4声音 - res.status(200).send({ status: "x", msg: "素材类型参数错误" }); - return; - } - - var SQL = `SELECT id, tag FROM material_tags WHERE type=${type} ORDER BY id DESC`; - DB.query(SQL, function (err, tags) { - if (err) { - res.status(200).send({ status: "x", msg: "服务器错误" }); - return; - } - - res.status(200).send({ status: "ok", data: tags }); - }); - } catch (err) { - next(err); - } -}); -// 素材分类管理:添加 -router.post("/material/tag/add", function (req, res, next) { - try { - var type = parseInt(req.body.t); - if (!type || type < 1 || 4 < type) { - // 1背景、2角色、3造型、4声音 - res.status(200).send({ status: "x", msg: "素材类型参数错误" }); - return; - } - - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "标签名错误" }); - return; - } - - SQL = `INSERT INTO material_tags (type, tag) VALUES ('${type}', '${req.body.v}')`; - DB.query(SQL, function (err, newTag) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res - .status(200) - .send({ status: "ok", msg: "操作成功", newTagId: newTag.insertId }); - }); - } catch (err) { - next(err); - } -}); -// 素材分类管理:修改 -router.post("/material/tag/mod", function (req, res, next) { - try { - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "标签名错误" }); - return; - } - - SQL = `UPDATE material_tags SET tag=? WHERE id=?`; - var VAL = [`${req.body.v}`, req.body.id]; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 素材分类管理:删除 -router.post("/material/tag/del", function (req, res, next) { - try { - // 判断此标签下是否有素材:只能删除空标签 - var type = parseInt(req.body.t); - var tabelname = ""; // 1背景、2角色、3造型、4声音 - if (type == 1) { - tabelname = "material_backdrop"; - } else if (type == 2) { - tabelname = "material_sprite"; - } else if (type == 3) { - tabelname = "material_costume"; - } else if (type == 4) { - tabelname = "material_sound"; - } else { - res.status(200).send({ status: "x", msg: "素材类型参数错误" }); - return; - } - - var VAL = [req.body.id]; - var SQL = `SELECT id FROM ${tabelname} WHERE tagId=? LIMIT 1`; - DB.qww(SQL, VAL, function (err, MATE) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - if (MATE.length != 0) { - res.status(200).send({ status: "x", msg: "只能删除空标签" }); - return; - } - - SQL = `DELETE FROM material_tags WHERE id=?`; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res - .status(200) - .send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); - -/*生成32位随机流水号*/ -const random_32ID_With_Time_Tag = function () { - var chars = "ABCDEFabcdef0123456789"; // 角色文件必须是:^[a-fA-F0-9]{32}$ - var maxPos = chars.length; - var randomID = - "B100" + - parseInt(new Date().getTime() / 1000) - .toString(16) - .toUpperCase(); - for (i = 0; i < 20; i++) { - randomID += chars.charAt(Math.floor(Math.random() * maxPos)); - } - return randomID; -}; - -// 背景管理:页面 -router.get("/material/backdrop", function (req, res, next) { - try { - var SQL = `SELECT id, tag FROM material_tags WHERE type=1 ORDER BY id DESC`; - DB.query(SQL, function (err, tags) { - if (err) { - res.locals["tags"] = []; - } else { - res.locals["tags"] = tags; - } - - res.render("admin/admin_material_backdrop.ejs"); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:数据 -router.get("/material/backdrop/data", function (req, res, next) { - try { - var VAL = [req.query.tagId]; - var SQL = `SELECT count(id) AS c FROM material_backdrop WHERE tagId=?`; - DB.qww(SQL, VAL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = `SELECT * FROM material_backdrop WHERE tagId=? ORDER BY id DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.qww(SQL, VAL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:添加 -router.post("/material/backdrop/add", function (req, res, next) { - try { - var newFileName = random_32ID_With_Time_Tag(); - const SQL = `INSERT INTO material_backdrop (tagId, md5) VALUES ('${req.body.tagId}', '${newFileName}.png')`; - DB.query(SQL, function (err, newTag) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - //保存文件到正确位置 - exampleFile = `./data/material/backdrop_example.png`; - md5File = `./data/material/asset/${newFileName}.png`; - fs.copyFile(exampleFile, md5File, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:修改素材 -router.post("/material/backdrop/modImage", function (req, res, next) { - try { - if (!req["files"]["file"]) { - res.status(200).send({ status: "x", msg: "文件上传失败,请再试一次" }); - return; - } - - //保存文件到正确位置 - const tmppath = req["files"]["file"]["path"]; - arr = tmppath.split("."); - let newExt = arr[arr.length - 1]; //取上传文件的扩展名jpg|png|gif|svg|bmp - if ( - newExt != "jpg" && - newExt != "png" && - newExt != "gif" && - newExt != "svg" && - newExt != "bmp" - ) { - res.status(200).send({ status: "x", msg: "文件类型错误,请再试一次" }); - return; - } - - let md5 = req.body.md5; - const oldExt = md5.substring(md5.length - 3); - if (oldExt == newExt) { - // 后缀未变,直接替换 - const newpath = `./data/material/asset/${md5}`; - fs.rename(tmppath, newpath, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "修改成功", imgFile: md5 }); - } else { - // 删除原图片文件 - fs.unlink(`./data/material/asset/${md5}`, function (err) { - if (err) { - console.log(err); - } - }); - - md5 = md5.substring(0, md5.length - 3) + newExt; // 组合新文件名 - const newpath = `./data/material/asset/${md5}`; - fs.rename(tmppath, newpath, function (err) { - if (err) { - } - }); - - SQL = `UPDATE material_backdrop SET md5=? WHERE id=${req.body.id}`; - VAL = [md5]; - DB.qww(SQL, VAL, function (err, R) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "修改成功", imgFile: md5 }); - }); - } - } catch (err) { - next(err); - } -}); -// 背景管理:修改名称 -router.post("/material/backdrop/modName", function (req, res, next) { - try { - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "名称错误" }); - return; - } - - var SQL = `UPDATE material_backdrop SET name=? WHERE id=?`; - var VAL = [req.body.v, req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:修改尺寸 -router.post("/material/backdrop/modMateSize", function (req, res, next) { - try { - let infoValue = parseInt(req.body.v); - if (req.body.t == "info0" || req.body.t == "info1") { - if (!infoValue || infoValue < 1 || 9999 < infoValue) { - res - .status(200) - .send({ status: "x", msg: "参数错误:宽、高只能在 1~9999 之间" }); - return; - } - } else if (req.body.t == "info2") { - if (!infoValue || infoValue < 1 || 2 < infoValue) { - res - .status(200) - .send({ - status: "x", - msg: "参数错误!显示方式:1=铺开显示;2=原图显示", - }); - return; - } - } else { - res.status(200).send({ status: "x", msg: "参数错误" }); - return; - } - - const SQL = `UPDATE material_backdrop SET ${req.body.t}=${infoValue} WHERE id=?`; - var VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:删除:未删除其文件,仅仅删除数据库记录 -router.post("/material/backdrop/del", function (req, res, next) { - try { - var VAL = [req.body.id]; - var SQL = `DELETE FROM material_backdrop WHERE id=?`; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 背景管理:状态管理 -router.post("/material/backdrop/setState", function (req, res, next) { - try { - let v = 0; //默认都当作 停用 处理 - if (req.body.v && req.body.v == 1) { - v = 1; - } - - var UPDATE = `UPDATE material_backdrop SET state=${v} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); - -// 造型管理:页面 -router.get("/material/costume", function (req, res, next) { - try { - var SQL = `SELECT id, tag FROM material_tags WHERE type=3 ORDER BY id DESC`; - DB.query(SQL, function (err, tags) { - if (err) { - res.locals["tags"] = []; - } else { - res.locals["tags"] = tags; - } - - res.render("admin/admin_material_costume.ejs"); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:数据 -router.get("/material/costume/data", function (req, res, next) { - try { - var VAL = [req.query.tagId]; - var SQL = `SELECT count(id) AS c FROM material_costume WHERE tagId=?`; - DB.qww(SQL, VAL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = `SELECT * FROM material_costume WHERE tagId=? ORDER BY id DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.qww(SQL, VAL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:添加 -router.post("/material/costume/add", function (req, res, next) { - try { - var newFileName = random_32ID_With_Time_Tag(); - const SQL = `INSERT INTO material_costume (tagId, md5) VALUES ('${req.body.tagId}', '${newFileName}.png')`; - DB.query(SQL, function (err, newTag) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - //保存文件到正确位置 - exampleFile = `./data/material/backdrop_example.png`; - md5File = `./data/material/asset/${newFileName}.png`; - fs.copyFile(exampleFile, md5File, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:修改素材文件 -router.post("/material/costume/modImage", function (req, res, next) { - try { - if (!req["files"]["file"]) { - res.status(200).send({ status: "x", msg: "文件上传失败,请再试一次" }); - return; - } - - //保存文件到正确位置 - const tmppath = req["files"]["file"]["path"]; - arr = tmppath.split("."); - let newExt = arr[arr.length - 1]; //取上传文件的扩展名jpg|png|gif|svg|bmp - if ( - newExt != "jpg" && - newExt != "png" && - newExt != "gif" && - newExt != "svg" && - newExt != "bmp" - ) { - res.status(200).send({ status: "x", msg: "文件类型错误,请再试一次" }); - return; - } - - let md5 = req.body.md5; - const oldExt = md5.substring(md5.length - 3); - if (oldExt == newExt) { - // 后缀未变,直接替换 - const newpath = `./data/material/asset/${md5}`; - fs.rename(tmppath, newpath, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "修改成功", imgFile: md5 }); - } else { - // 删除原图片文件 - fs.unlink(`./data/material/asset/${md5}`, function (err) { - if (err) { - console.log(err); - } - }); - - md5 = md5.substring(0, md5.length - 3) + newExt; // 组合新文件名 - const newpath = `./data/material/asset/${md5}`; - fs.rename(tmppath, newpath, function (err) { - if (err) { - } - }); - - SQL = `UPDATE material_costume SET md5=? WHERE id=${req.body.id}`; - VAL = [md5]; - DB.qww(SQL, VAL, function (err, R) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "修改成功", imgFile: md5 }); - }); - } - } catch (err) { - next(err); - } -}); -// 造型管理:修改名称 -router.post("/material/costume/modName", function (req, res, next) { - try { - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "名称错误" }); - return; - } - - var SQL = `UPDATE material_costume SET name=? WHERE id=?`; - var VAL = [req.body.v, req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:修改素材属性:尺寸 -router.post("/material/costume/modMateSize", function (req, res, next) { - try { - let infoValue = parseInt(req.body.v); - if (req.body.t == "info0" || req.body.t == "info1") { - if (!infoValue || infoValue < 1 || 9999 < infoValue) { - res - .status(200) - .send({ status: "x", msg: "参数错误:宽、高只能在 1~9999 之间" }); - return; - } - } else if (req.body.t == "info2") { - if (!infoValue || infoValue < 1 || 2 < infoValue) { - res - .status(200) - .send({ - status: "x", - msg: "参数错误!显示方式:1=铺开显示;2=原图显示", - }); - return; - } - } else { - res.status(200).send({ status: "x", msg: "参数错误" }); - return; - } - - const SQL = `UPDATE material_costume SET ${req.body.t}=${infoValue} WHERE id=?`; - var VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:删除素材,未删除其文件,仅仅删除数据库记录 -router.post("/material/costume/del", function (req, res, next) { - try { - // 需要判断是否在角色中有被使用到,有被角色使用到时,不能删除 - var VAL = [req.body.id]; - var SQL = `DELETE FROM material_costume WHERE id=?`; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 造型管理:素材状态管理 -router.post("/material/costume/setState", function (req, res, next) { - try { - let v = 0; //默认都当作 停用 处理 - if (req.body.v && req.body.v == 1) { - v = 1; - } - - var UPDATE = `UPDATE material_costume SET state=${v} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); - -// 角色管理:页面 -router.get("/material/sprite", function (req, res, next) { - try { - var SQL = `SELECT id, tag FROM material_tags WHERE type=2 ORDER BY id DESC`; - DB.query(SQL, function (err, tags) { - if (err) { - res.locals["tags"] = []; - } else { - res.locals["tags"] = tags; - } - - res.render("admin/admin_material_sprite.ejs"); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:页面数据 -router.get("/material/sprite/data", function (req, res, next) { - try { - var VAL = [req.query.tagId]; - var SQL = `SELECT count(id) AS c FROM material_sprite WHERE tagId=?`; - DB.qww(SQL, VAL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = `SELECT * FROM material_sprite WHERE tagId=? ORDER BY id DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.qww(SQL, VAL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:添加 -router.post("/material/sprite/add", function (req, res, next) { - try { - const sprite = require("./lib/scratch_default_sprite.js"); // 默认角色 - const SQL = `INSERT INTO material_sprite (tagId, json) VALUES (?, ?)`; - const VAL = [req.body.tagId, sprite]; - DB.qww(SQL, VAL, function (err, R) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:删除素材,未删除其文件,仅仅删除数据库记录 -router.post("/material/sprite/del", function (req, res, next) { - try { - // 需要判断是否在角色中有被使用到,有被角色使用到时,不能删除 - var VAL = [req.body.id]; - var SQL = `DELETE FROM material_sprite WHERE id=?`; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:导入角色:作品数据 -router.get("/material/sprite/worklist", function (req, res, next) { - try { - var _title = ""; - if (req.query["t"] != undefined && req.query["t"] != "") { - _title = ` AND title LIKE '%${req.query["t"]}%' `; - } - - var SQL = `SELECT count(id) AS c FROM scratch WHERE authorid=${res.locals.userid} ${_title}`; - DB.query(SQL, function (err, count) { - if (err || count.length == 0 || count[0].c == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - var SQL = `SELECT id,title FROM scratch WHERE authorid=${ - res.locals.userid - } ${_title} ORDER BY time DESC LIMIT ${(page - 1) * limit}, ${limit}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0].c, data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:导入角色:导入{tagid: _tagId, workid:select_data.id} -router.post("/material/sprite/import", function (req, res, next) { - try { - // 1、获取作品src - var SELECT = `SELECT src FROM scratch WHERE id=${req.body.workid} LIMIT 1`; - DB.query(SELECT, function (err, SRC) { - if (err || SRC.length == 0) { - res.status(200).send({ status: "x", msg: "再试一次" }); - return; - } - - // 组合角色数据 values="(),(),()" - let spriteCount = 0; - let values = ""; - let targets = JSON.parse(SRC[0].src).targets; - for (var i = 0; i < targets.length; i++) { - if (!targets[i].isStage) { - let json = {}; - json["costumes"] = targets[i]["costumes"]; - json["sounds"] = targets[i]["sounds"]; - - if (values != "") { - values += ","; - } - - values += `(${req.body.tagid}, '${targets[i].name}', '${JSON.stringify( - json - ).replace(/'/g, "’")}')`; - - spriteCount++; - } - } - - if (spriteCount == 0) { - res.status(200).send({ status: "ok", msg: "作品中无角色数据" }); - } - - var SQL = `INSERT INTO material_sprite(tagId, name, json) VALUES ${values}`; - DB.query(SQL, function (err, D) { - if (err) { - res.status(200).send({ status: "x", msg: "操作失败,请再试一次" }); - return; - } - - res - .status(200) - .send({ status: "ok", msg: `操作成功,导入角色数:${spriteCount}` }); - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:修改名称 -router.post("/material/sprite/modName", function (req, res, next) { - try { - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "名称错误" }); - return; - } - - var SQL = `UPDATE material_sprite SET name=? WHERE id=?`; - var VAL = [req.body.v, req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:素材状态管理 -router.post("/material/sprite/setState", function (req, res, next) { - try { - let v = 0; //默认都当作 停用 处理 - if (req.body.v && req.body.v == 1) { - v = 1; - } - - var UPDATE = `UPDATE material_sprite SET state=${v} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); - -// 角色管理:造型管理 页面 -router.get("/material/sprite/setCostume", function (req, res, next) { - try { - res.locals._id = req.query["id"]; - res.render("admin/admin_material_sprite_costume.ejs"); - } catch (err) { - next(err); - } -}); -// 角色管理:造型管理 页面数据 -router.get("/material/sprite/setCostume/data", function (req, res, next) { - try { - var SQL = `SELECT json FROM material_sprite WHERE id=${req.query["id"]} LIMIT 1`; - DB.query(SQL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", data: "" }); - return; - } - - res.status(200).send({ status: "ok", data: D[0].json }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:造型管理:删除素材,未删除其文件,仅仅删除数据库记录 -// 参数:{id: _id, index: obj.data.index, md5: obj.data.md5ext} -router.post("/material/sprite/setCostume/del", function (req, res, next) { - try { - // 需要判断是否在角色中有被使用到,有被角色使用到时,不能删除 - var SQL = `SELECT json FROM material_sprite WHERE id=?`; - var VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - let json = JSON.parse(D[0].json); // json 包含了造型与声音 - if (json.costumes.length < 2) { - // 角色的造型,必须最少有一个造型 - res.status(200).send({ status: "x", msg: "角色最少有一个造型" }); - return; - } - - // 判断要移除的造型是否存在 - var costume = json.costumes[req.body.index]; - if (!costume || costume.md5ext != req.body.md5) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - // 移除造型 并 保存 - json.costumes.splice(req.body.index, 1); - SQL = `UPDATE material_sprite SET json='${JSON.stringify(json)}' WHERE id=${ - req.body.id - }`; - DB.query(SQL, function (err, D1) { - if (err) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:造型管理:添加造型时,可选择造型 数据 -// {text: 搜索文本,默认为空:''} -router.get("/material/sprite/setCostume/select", function (req, res, next) { - try { - var SQL = `SELECT count(id) AS c FROM material_costume WHERE name LIKE '%${req.query.text}%'`; - DB.query(SQL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = - `SELECT c.id, c.name, t.tag FROM material_costume c ` + - ` LEFT JOIN material_tags t ON (c.tagId = t.id) ` + - ` WHERE c.name LIKE '%${req.query.text}%' LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:造型管理:添加 -// {sid: 角色ID, cid: 将被添加的造型ID} -router.post("/material/sprite/setCostume/add", function (req, res, next) { - try { - // 取造型数据 - let SQL = - `SELECT c.name, c.md5, c.info0, c.info1, c.info2, s.json FROM material_costume c` + - ` LEFT JOIN material_sprite s ON (s.id=?) ` + - ` WHERE c.id=?`; - let VAL = [req.body.sid, req.body.cid]; - DB.qww(SQL, VAL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - // 组合数据 - const md5 = D[0].md5.split("."); - let newCostume = { - name: D[0].name, // 名称 - assetId: md5[0] ? md5[0] : "error", // md5ext前部分 - dataFormat: md5[1] ? md5[1] : "error", // md5ext 后部分 - md5ext: D[0].md5, - rotationCenterX: D[0].info0, // info0 - rotationCenterY: D[0].info1, // info1 - bitmapResolution: D[0].info2, // info2 - }; - - let json = JSON.parse(D[0].json); - json.costumes.push(newCostume); - - SQL = `UPDATE material_sprite SET json='${JSON.stringify(json)}' WHERE id=${ - req.body.sid - }`; - DB.query(SQL, function (err, D) { - if (err) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); - -// 角色管理:声音管理 页面 -router.get("/material/sprite/setSound", function (req, res, next) { - try { - res.locals._id = req.query["id"]; - res.render("admin/admin_material_sprite_sound.ejs"); - } catch (err) { - next(err); - } -}); -// 角色管理:声音管理 页面 数据 -router.get("/material/sprite/setSound/data", function (req, res, next) { - try { - var SQL = `SELECT json FROM material_sprite WHERE id=${req.query["id"]} LIMIT 1`; - DB.query(SQL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", data: "" }); - return; - } - - res.status(200).send({ status: "ok", data: D[0].json }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:声音管理:删除素材,未删除其文件,仅仅删除数据库记录 -// 参数:{id: _id, index: obj.data.index, md5: obj.data.md5ext} -router.post("/material/sprite/setSound/del", function (req, res, next) { - try { - // 需要判断是否在角色中有被使用到,有被角色使用到时,不能删除 - var SQL = `SELECT json FROM material_sprite WHERE id=?`; - var VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - let json = JSON.parse(D[0].json); // json 包含了造型与声音 - if (json.sounds.length < 2) { - // 角色的声音,必须最少有一个声音 - res.status(200).send({ status: "x", msg: "角色最少有一个声音" }); - return; - } - - // 判断要移除的声音是否存在 - var sound = json.sounds[req.body.index]; - if (!sound || sound.md5ext != req.body.md5) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - // 移除 并 保存 - json.sounds.splice(req.body.index, 1); - SQL = `UPDATE material_sprite SET json='${JSON.stringify(json)}' WHERE id=${ - req.body.id - }`; - DB.query(SQL, function (err, D1) { - if (err) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:声音管理:添加声音时,可选择声音 数据 -// {text: 搜索文本,默认为空:''} -router.get("/material/sprite/setSound/select", function (req, res, next) { - try { - var SQL = `SELECT count(id) AS c FROM material_sound WHERE name LIKE '%${req.query.text}%'`; - DB.query(SQL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = - `SELECT c.id, c.name, t.tag FROM material_sound c ` + - ` LEFT JOIN material_tags t ON (c.tagId = t.id) ` + - ` WHERE c.name LIKE '%${req.query.text}%' LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 角色管理:声音管理:添加 -// {sid: 角色ID, cid: 将被添加的声音ID} -router.post("/material/sprite/setSound/add", function (req, res, next) { - try { - // 取声音数据 - let SQL = - `SELECT c.name, c.md5, c.format, c.rate, c.sampleCount, s.json FROM material_sound c` + - ` LEFT JOIN material_sprite s ON (s.id=?) ` + - ` WHERE c.id=?`; - let VAL = [req.body.sid, req.body.cid]; - DB.qww(SQL, VAL, function (err, D) { - if (err || D.length == 0) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - // 组合数据 - const md5 = D[0].md5.split("."); - let newSound = { - name: D[0].name, // 名称 - assetId: md5[0] ? md5[0] : "error", // md5ext前部分 - dataFormat: md5[1] ? md5[1] : "error", // md5ext 后部分 - md5ext: D[0].md5, - format: D[0].format, // format - rate: D[0].rate, // rate - sampleCount: D[0].sampleCount, // sampleCount - }; - - let json = JSON.parse(D[0].json); - json.sounds.push(newSound); - - SQL = `UPDATE material_sprite SET json='${JSON.stringify(json)}' WHERE id=${ - req.body.sid - }`; - DB.query(SQL, function (err, D) { - if (err) { - res.status(200).send({ status: "x", msg: "数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - }); - } catch (err) { - next(err); - } -}); - -// 声音管理:页面 -router.get("/material/sound", function (req, res, next) { - try { - var SQL = `SELECT id, tag FROM material_tags WHERE type=4 ORDER BY id DESC`; - DB.query(SQL, function (err, tags) { - if (err) { - res.locals["tags"] = []; - } else { - res.locals["tags"] = tags; - } - - res.render("admin/admin_material_sound.ejs"); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:数据 -router.get("/material/sound/data", function (req, res, next) { - try { - var VAL = [req.query.tagId]; - var SQL = `SELECT count(id) AS c FROM material_sound WHERE tagId=?`; - DB.qww(SQL, VAL, function (err, count) { - if (err || count[0]["c"] == 0) { - res.status(200).send({ count: 0, data: [] }); - return; - } - - //获取当前数据集合 - var page = parseInt(req.query["page"]); - var limit = parseInt(req.query["limit"]); - SQL = `SELECT * FROM material_sound WHERE tagId=? ORDER BY id DESC LIMIT ${ - (page - 1) * limit - },${limit}`; - DB.qww(SQL, VAL, function (err, data) { - if (err) { - res.status(200).send({ count: 0, data: [] }); - } else { - res.status(200).send({ count: count[0]["c"], data: data }); - } - }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:添加 -router.post("/material/sound/add", function (req, res, next) { - try { - // 仅仅支持wav格式的声音素材 - var newFileName = random_32ID_With_Time_Tag() + ".wav"; - const SQL = `INSERT INTO material_sound (tagId, md5) VALUES ('${req.body.tagId}', '${newFileName}')`; - DB.query(SQL, function (err, newTag) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - //保存文件到正确位置 - exampleFile = `./data/material/sound_example.wav`; - md5File = `./data/material/asset/${newFileName}`; - fs.copyFile(exampleFile, md5File, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:修改素材文件 -router.post("/material/sound/modWav", function (req, res, next) { - try { - if (!req["files"]["file"]) { - res.status(200).send({ status: "x", msg: "文件上传失败,请再试一次" }); - return; - } - - const tmppath = req["files"]["file"]["path"]; - arr = tmppath.split("."); - let newExt = arr[arr.length - 1]; //取上传文件的扩展名wav - if (newExt != "wav") { - res.status(200).send({ status: "x", msg: "文件类型错误,请再试一次" }); - return; - } - - const SQL = `SELECT md5 FROM material_sound WHERE id=?`; - const VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, DATA) { - if (err || DATA.length == 0) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - //保存文件 - const newpath = `./data/material/asset/${DATA[0].md5}`; - fs.rename(tmppath, newpath, function (err) { - if (err) { - } - }); - - res.status(200).send({ status: "ok", msg: "修改成功" }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:修改名称 -router.post("/material/sound/modName", function (req, res, next) { - try { - if (!req.body.v || req.body.v == "") { - res.status(200).send({ status: "x", msg: "名称错误" }); - return; - } - - var SQL = `UPDATE material_sound SET name=? WHERE id=?`; - var VAL = [req.body.v, req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:修改素材属性:rate/sampleCount -router.post("/material/sound/modMateAttr", function (req, res, next) { - try { - if (req.body.t != "sampleCount") { - res.status(200).send({ status: "x", msg: "参数错误" }); - return; - } - - let infoValue = parseInt(req.body.v); - if (!infoValue || infoValue < 0 || 10000000 < infoValue) { - res - .status(200) - .send({ status: "x", msg: "参数错误:只能在 0~1000,0000 之间" }); - return; - } - - const SQL = `UPDATE material_sound SET sampleCount=${infoValue} WHERE id=?`; - var VAL = [req.body.id]; - DB.qww(SQL, VAL, function (err, Mate) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:删除素材,未删除其文件,仅仅删除数据库记录 -router.post("/material/sound/del", function (req, res, next) { - try { - // 需要判断是否在角色中有被使用到,有被角色使用到时,不能删除 - var VAL = [req.body.id]; - var SQL = `DELETE FROM material_sound WHERE id=?`; - DB.qww(SQL, VAL, function (err, TAG) { - if (err) { - res.status(200).send({ status: "x", msg: "保存数据错误,请再试一次" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); -// 声音管理:素材状态管理 -router.post("/material/sound/setState", function (req, res, next) { - try { - let v = 0; //默认都当作 停用 处理 - if (req.body.v && req.body.v == 1) { - v = 1; - } - - var UPDATE = `UPDATE material_sound SET state=${v} WHERE id=${req.body.id} LIMIT 1`; - DB.query(UPDATE, function (err, d) { - if (err) { - res.status(200).send({ status: "x", msg: "再试一次" }); - } else { - res.status(200).send({ status: "ok", msg: "操作成功" }); - } - }); - } catch (err) { - next(err); - } -}); - -// 清理scratch缩略图 -router.get("/clear_scratch_slt", function (req, res, next) { - try { - var SQL = "SELECT id FROM scratch"; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send("清理scratch缩略图数据库查询出错!"); - return; - } - - // 把缩略图目录 - var slt_path = "./data/scratch_slt"; - var backup_time = new Date().getTime().toString(16); - var backup_path = `./data/scratch_slt_backup_${backup_time}`; - try { - fs.renameSync(slt_path, backup_path); - } catch (e) { - res.status(200).send("备份缩略图文件夹出错!"); - return; - } - try { - fs.mkdirSync(slt_path); - } catch (e) { - res.status(200).send("创建缩略图文件夹出错!"); - return; - } - - for (var i = data.length - 1; i >= 0; i--) { - let slt_old = `${backup_path}/${data[i].id}`; - let slt = `${slt_path}/${data[i].id}`; - - fs.copyFile(slt_old, slt, function (err) { - if (err) { - } - }); - } - - res.status(200).send("OK!"); - }); - } catch (err) { - next(err); - } -}); - -module.exports = router; diff --git a/server/router_api.js b/server/router_api.js index da33876..c284652 100644 --- a/server/router_api.js +++ b/server/router_api.js @@ -85,7 +85,11 @@ router.get("/usertx", async function (req, res, next) { DB.query(SQL, async function (err, USER) { if (err || USER.length == 0) { res.locals.tip = { opt: "flash", msg: "用户不存在" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } res.redirect(302, await configManager.getConfig('s3.staticurl') + "/user/" + USER[0].images); @@ -127,7 +131,11 @@ router.get("/getuserinfo", async function (req, res, next) { if (!user[0]) { console.log("用户不存在"); res.locals.tip = { opt: "flash", msg: "用户不存在" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); } res.send({ status: "ok", diff --git a/server/router_my.js b/server/router_my.js index 70056f4..cfbb3a0 100644 --- a/server/router_my.js +++ b/server/router_my.js @@ -32,51 +32,6 @@ router.get("/project", function (req, res) { res.redirect("/my/scratch"); }); -//作品 -router.get("/scratch", function (req, res) { - var SQL = - `SELECT ` + - ` count(case when state='private' then 1 end) AS state0_count, ` + - ` count(case when state='public' then 1 end) AS state1_count, ` + - ` '' AS state2_count ` + - ` FROM scratch WHERE authorid=${res.locals["userid"]}`; - - DB.query(SQL, function (err, data) { - if (err) { - res.locals.state0_count = 0; - res.locals.state1_count = 0; - res.locals.state2_count = 0; - } else { - res.locals.state0_count = data[0].state0_count; - res.locals.state1_count = data[0].state1_count; - res.locals.state2_count = data[0].state2_count; - } - res.render("scratch/my_scratch_projects.ejs"); - }); -}); - -//作品 -router.get("/python", function (req, res) { - var SQL = - `SELECT ` + - ` count(case when state='private' then 1 end) AS state0_count, ` + - ` count(case when state='public' then 1 end) AS state1_count, ` + - ` '' AS state2_count ` + - ` FROM python WHERE authorid=${res.locals.userid}`; - - DB.query(SQL, function (err, data) { - if (err) { - res.locals.state0_count = 0; - res.locals.state1_count = 0; - res.locals.state2_count = 0; - } else { - res.locals.state0_count = data[0].state0_count; - res.locals.state1_count = data[0].state1_count; - res.locals.state2_count = data[0].state2_count; - } - res.render("python/my_python_projects.ejs"); - }); -}); //显示Scratch项目列表:数据,{curr:obj.curr, limit:obj.limit,state:state} router.get("/getScratchProjects", function (req, res) { var curr = parseInt(req.query.curr); //当前要显示的页码 @@ -293,10 +248,6 @@ router.post("/project/del", function (req, res) { res.status(200).send({ status: "success", msg: "删除成功" }); }); }); -//个人设置 -router.get("/info", function (req, res) { - res.render("my_info.ejs"); -}); //修改头像 router.post("/set/avatar", geetest, function (req, res) { //保存文件到正确位置 diff --git a/server/router_python.js b/server/router_python.js deleted file mode 100644 index ba24ad2..0000000 --- a/server/router_python.js +++ /dev/null @@ -1,324 +0,0 @@ -const configManager = require("./configManager"); - -var express = require("express"); -var router = express.Router(); - -var DB = require("./lib/database.js"); // 数据库 - -router.all("*", function (req, res, next) { - next(); -}); -//router.get('/', function (req, res) {}) - -//首页 -router.get("/", function (req, res, next) { - try { - res.render("python/python_projects.ejs"); - } catch (err) { - next(err); - } -}); -//首页 -router.get("/next", function (req, res, next) { - try { - res.render("python/next_python_play.ejs"); - } catch (err) { - next(err); - } -}); -router.get("/pythoncount", function (req, res, next) { - try { - //获取已分享的作品总数:1:普通作品,2:推荐的优秀作品 - var SQL = - `SELECT ` + - ` (SELECT count(id) FROM ow_projects WHERE state='public' ) AS python_count `; - DB.query(SQL, function (err, data) { - if (err) { - // console.error('数据库操作出错:'); - res.locals.python_count = 0; - } else { - res.locals.python_count = data[0].python_count; - } - res.status(200).send(data[0]); - }); - } catch (err) { - next(err); - } -}); -//翻页:Python作品列表:数据 -router.get("/view/getPythonProjects", function (req, res, next) { - try { - var curr = parseInt(req.query.curr); //当前要显示的页码 - var limit = parseInt(req.query.limit); //每页显示的作品数 - var type = "view_count"; - if (req.query.type == "new") { - type = "time"; - } - - var SQL = `SELECT ow_projects.id, ow_projects.title, ow_projects.state,ow_projects.authorid, ow_projects.description,ow_projects.view_count,ow_users.display_name,ow_users.motto FROM ow_projects JOIN ow_users ON ow_projects.authorid = ow_users.id WHERE ow_projects.state='public' AND ow_projects.type='python' ORDER BY ow_projects.${type} DESC LIMIT ${ - (curr - 1) * limit - }, ${limit}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send([]); - } else { - res.status(200).send(data); - } - }); - } catch (err) { - next(err); - } -}); - -//搜索:Scratch项目列表:数据//只搜索标题 -router.get("/view/seachPythonProjects", function (req, res, next) { - try { - if (!req.query.txt) { - res.status(200).send([]); - return; - } - var tabelName = "python"; - var searchinfo = "title"; - if (req.query.searchall == "true") { - searchinfo = "source"; - } - //var SQL = `SELECT id, title FROM ow_projects WHERE state='public' AND (${searchinfo} LIKE ?) LIMIT 12`; - var SQL = `SELECT ow_projects.id, ow_projects.title, ow_projects.state,ow_projects.authorid,ow_projects.description,ow_projects.view_count, ow_users.display_name,ow_users.motto FROM ow_projects JOIN ow_users ON ow_projects.authorid = ow_users.id WHERE ow_projects.state='public' AND (${searchinfo} LIKE ?) AND ow_projects.type='${tabelName}'`; - var WHERE = [`%${req.query.txt}%`]; - DB.qww(SQL, WHERE, function (err, data) { - if (err) { - res.status(200).send([]); - } else { - res.status(200).send(data); - } - }); - } catch (err) { - next(err); - } -}); - -//python项目展示界面 -router.get("/play", function (req, res, next) { - try { - res.render("python/python_play.ejs"); - } catch (err) { - next(err); - } -}); - -//python项目编辑界面:获取项目源代码 -router.get("/edit", function (req, res, next) { - try { - res.render("python/python_edit.ejs"); - } catch (err) { - next(err); - } -}); - -// 从数据库获取作品 -router.post("/getWork", function (req, res, next) { - try { - var projectid = 0; - if (req.body.id && req.body.id > 1) { - projectid = req.body.id; - } - - if (projectid == 0 || projectid == 1) { - // 默认作品 - //***当把该块注释后,则从数据库加载默认作品*** - //从指定文件加载默认作品:BEGIN========================================== - var DefaultPython = { - id: 0, - title: "Python新项目", - state: 0, - source: `import turtle\n\nt = turtle.Turtle()\nt.forward(100)\n\nprint ("Welcome to ZeroCat!")`, - }; - if (projectid == 1) { - res.status(200).send({ status: "ok", work: DefaultPython }); - return; - } - //从指定文件加载默认作品:END============================================ - //*/ - SQL = `SELECT * FROM ow_projects WHERE id=1`; //默认作品为1号作品 - } else { - if (!res.locals.login) { - //未登录时,只能打开已发布的作品 - SQL = `SELECT * FROM ow_projects WHERE id=${projectid} AND state='public'`; - } else { - //作品编辑:能够打开一个作品的几种权限: - //1、自己的作品; - //2、开源的作品; - SQL = `SELECT * FROM ow_projects WHERE id=${projectid} AND (authorid=${res.locals.userid} OR state='public')`; - } - } - - DB.query(SQL, function (err, WORK) { - if (err || WORK.length == 0) { - res.status(200).send({ status: "x", msg: "作品不存在或无权打开" }); //需要前端内部处理 - } else { - var UPDATE = `UPDATE ow_projects SET view_count=view_count+1 WHERE id=${projectid} LIMIT 1`; - DB.query(UPDATE, function (err, s) { - if (err) { - } - }); - - if (WORK[0].id == 1) { - WORK[0].id = 0; // 通知浏览器作品ID为0 - } - res.status(200).send({ status: "ok", work: WORK[0] }); - } - }); - } catch (err) { - next(err); - } -}); - -// python 保存 -router.post("/save", function (req, res, next) { - try { - if (!res.locals.userid) { - res.status(200).send({ status: "0", msg: "请先登录" }); - return; - } - - // 新作品 - if (req.body.id == "0") { - var INSERT = `INSERT INTO ow_projects (authorid, title,source) VALUES (${res.locals.userid}, ?, ?)`; - var SET = [req.body.title, req.body.data]; - DB.qww(INSERT, SET, function (err, newPython) { - if (err || newPython.affectedRows == 0) { - res.status(200).send({ status: "0", msg: "保存失败" }); - return; - } - - res - .status(200) - .send({ status: "ok", msg: "保存成功", newid: newPython["insertId"] }); - }); - - return; - } - - // 旧作品 - var UPDATE = `UPDATE ow_projects SET ? WHERE id=${req.body.id} AND authorid=${res.locals.userid} LIMIT 1`; - var SET = { - title: req.body.title, - source: req.body.data, - description: req.body.description, - }; - DB.qww(UPDATE, SET, function (err, u) { - if (err) { - res.status(200).send({ status: "0", msg: "保存失败" }); - return; - } - - res.status(200).send({ status: "ok", msg: "保存成功" }); - }); - } catch (err) { - next(err); - } -}); - -router.post("/publish", function (req, res, next) { - try { - if (!res.locals.userid) { - res.status(200).send({ status: "0", msg: "请先登录" }); - return; - } - - var state = req.body.s == "0" ? 1 : 0; - var UPDATE = `UPDATE ow_projects SET state=${state} WHERE id=${req.body.id} AND authorid=${res.locals.userid} LIMIT 1`; - DB.query(UPDATE, function (err, u) { - if (err) { - res.status(200).send({ status: "0", msg: "操作失败!" }); - return; - } - - res.status(200).send({ status: "ok", msg: "操作成功" }); - }); - } catch (err) { - next(err); - } -}); - -// python 优秀作品 -router.post("/YxLibrary_count", function (req, res, next) { - try { - var SQL = `SELECT count(id) AS c FROM ow_projects WHERE state='public'`; - DB.query(SQL, function (err, COUNT) { - if (err) { - res.status(200).send({ status: "ok", total: 0 }); - } else { - res.status(200).send({ status: "ok", total: COUNT[0].c }); - } - }); - } catch (err) { - next(err); - } -}); -//显示Python项目列表:数据,流加载模式 -router.post("/YxLibrary_data", function (req, res, next) { - try { - //获取当前数据集合:以被浏览次数降序排列,每次取16个 - var page = parseInt(req.body.page); - SQL = - `SELECT ow_projects.id, ow_projects.authorid, ow_projects.view_count, ow_projects.time, ow_projects.title, ow_projects.description, ow_users.display_name AS author_display_name FROM ow_projects ` + - ` LEFT JOIN ow_users ON ow_users.id=ow_projects.authorid ` + - ` WHERE ow_projects.state='public' ORDER BY ow_projects.view_count DESC LIMIT ${ - (page - 1) * 16 - },${16}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ status: "ok", data: [] }); - } else { - res.status(200).send({ status: "ok", data: data }); - } - }); - } catch (err) { - next(err); - } -}); - -router.all("*", function (req, res, next) { - if (!res.locals.userid) { - res.status(200).send({ status: "0", msg: "请先登录" }); - return; - } - - next(); -}); - -router.post("/MyLibrary_count", function (req, res, next) { - try { - var SQL = `SELECT count(id) AS c FROM ow_projects WHERE authorid=${res.locals.userid}`; - DB.query(SQL, function (err, COUNT) { - if (err) { - res.status(200).send({ status: "ok", total: 0 }); - } else { - res.status(200).send({ status: "ok", total: COUNT[0].c }); - } - }); - } catch (err) { - next(err); - } -}); -router.post("/MyLibrary_data", function (req, res, next) { - try { - //获取当前数据集合:以被浏览次数降序排列,每次取16个 - var page = parseInt(req.body.page); - SQL = `SELECT id, state, time, title FROM ow_projects WHERE authorid=${ - res.locals.userid - } ORDER BY time DESC LIMIT ${(page - 1) * 16},${16}`; - DB.query(SQL, function (err, data) { - if (err) { - res.status(200).send({ status: "ok", data: [] }); - } else { - res.status(200).send({ status: "ok", data: data }); - } - }); - } catch (err) { - next(err); - } -}); - -module.exports = router; diff --git a/server/router_scratch.js b/server/router_scratch.js index 67b91c1..9177198 100644 --- a/server/router_scratch.js +++ b/server/router_scratch.js @@ -12,14 +12,6 @@ router.all("*", function (req, res, next) { next(); }); -//首页 -router.get("/", function (req, res, next) { - try { - res.render("scratch/scratch_projects.ejs"); - } catch (err) { - next(err); - } -}); router.get("/scratchcount", function (req, res, next) { try { @@ -97,13 +89,6 @@ router.get("/view/seachScratchProjects", function (req, res, next) { //1:已发布; //2:已开源;(开源的必须发布) //Scratch项目展示 -router.get("/play", function (req, res, next) { - try { - res.render("scratch/scratch_play.ejs"); - } catch (err) { - next(err); - } -}); router.get("/projectinfo", function (req, res, next) { try { @@ -271,13 +256,14 @@ router.get("/play/project/:id", function (req, res, next) { DB.query(SQL, function (err, U) { if (err || U.affectedRows == 0) { res.locals.tip = { opt: "flash", msg: "项目不存在或未发布" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } - //res.render("scratch/scratch_play.ejs"); - - ////console.log(SCRATCH[0]); }); }); } catch (err) { @@ -321,21 +307,6 @@ router.post("/play/openSrc", function (req, res, next) { } }); -//Scratch编程界面 -router.get("/edit", function (req, res, next) { - try { - res.render("scratch/scratch_edit.ejs"); - } catch (err) { - next(err); - } -}); -router.get("/editnew", function (req, res, next) { - try { - res.render("scratch/scratch_edit_next.ejs"); - } catch (err) { - next(err); - } -}); //Scratch内部调用一:获取作品数据:JSON源代码 //支持两种方案加载默认作品 //1、从指定文件加载 diff --git a/server/router_user.js b/server/router_user.js index 098e276..d4e7108 100644 --- a/server/router_user.js +++ b/server/router_user.js @@ -15,26 +15,6 @@ router.all("*", function (req, res, next) { const request = require("request"); -router.get("/", function (req, res) { - res.render("user.ejs"); -}); - -router.get("/login", function (req, res) { - var SQL = `SELECT id FROM sys_ini WHERE iniKey='regist' AND iniValue=1 LIMIT 1`; - DB.query(SQL, function (err, Regist) { - if (err || Regist.length == 0) { - res.locals.reg = 0; - } else { - res.locals.reg = 1; - } - - res.render("login_or_register.ejs"); - }); -}); - -router.get("/repw", function (req, res) { - res.render("repw.ejs"); -}); router.get("/logout", function (req, res) { logout(req, res); @@ -63,7 +43,11 @@ router.get("/tuxiaochao", async function (req, res) { DB.query(SQL, async function (err, USER) { if (err || USER.length == 0) { res.locals.tip = { opt: "flash", msg: "用户不存在" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } uid = res.locals["userid"].toString(); diff --git a/server/router_webhost.js b/server/router_webhost.js index dab4b36..7b1b341 100644 --- a/server/router_webhost.js +++ b/server/router_webhost.js @@ -19,12 +19,20 @@ router.get("/:id/*", function (req, res) { DB.query(SQL, function (err, PROJECT) { if (err) { res.locals.tip = { opt: "flash", msg: "项目不存在或未发布" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } if (PROJECT.length == 0) { res.locals.tip = { opt: "flash", msg: "项目不存在或未发布" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } function getValue(arr, obj) { @@ -62,7 +70,11 @@ router.get("/:id/*", function (req, res) { DB.query(SQL, function (err, U) { if (err || U.affectedRows == 0) { res.locals.tip = { opt: "flash", msg: "项目不存在或未发布" }; - res.render("404.ejs"); + res.status(404).json({ + status: "error", + code: "404", + message: "找不到页面", + }); return; } }); diff --git a/totp.js b/tools/totp.js similarity index 100% rename from totp.js rename to tools/totp.js diff --git a/views/404.ejs b/views/404.ejs deleted file mode 100644 index 0efcbc9..0000000 --- a/views/404.ejs +++ /dev/null @@ -1,11 +0,0 @@ -<%- include('./html-head.ejs', {pageTitle: '首页'}); %> - -

404 此页面未找到

-
页面不存在或已被删除,无需紧张,这与您的设备及浏览器无关
-
如果由他人向您分享了此链接,请联系与您分享此链接的人
-
如果您认为此问题与ZeroCat本身有关,请在左上角菜单中选择反馈
-
-首页 -返回上一页 - -<%- include('html-footer.ejs', {page: 'home'}); %> diff --git a/views/about.ejs b/views/about.ejs deleted file mode 100644 index 19b170d..0000000 --- a/views/about.ejs +++ /dev/null @@ -1,16 +0,0 @@ -<%- include('html-head.ejs', {pageTitle: '关于' }); %> -
也许某天会想到这里些什么
- - -<%- include('./html-footer.ejs', {page: 'about' }); %> diff --git a/views/admin/admin_default.ejs b/views/admin/admin_default.ejs deleted file mode 100644 index 5246080..0000000 --- a/views/admin/admin_default.ejs +++ /dev/null @@ -1,63 +0,0 @@ - - - -
-
-
- -
- -

- 欢迎使用<%= global.configManager['site.name'] %> -

-
<%= global.configManager['site.name'] %>,每一行代码都足以改变世界
-
-
- - - - diff --git a/views/admin/admin_index.ejs b/views/admin/admin_index.ejs deleted file mode 100644 index c5d52d1..0000000 --- a/views/admin/admin_index.ejs +++ /dev/null @@ -1,193 +0,0 @@ - - - - 系统管理平台 - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
-
- - - - - - - diff --git a/views/admin/admin_info.ejs b/views/admin/admin_info.ejs deleted file mode 100644 index 98f6d38..0000000 --- a/views/admin/admin_info.ejs +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - -
-
-
-
-
-
-
用户数
-
-

<%= user_count %>

-
-
-
- -
-
-
Scratch作品数
-
-

<%= scratch_count %>

-
-
-
- -
-
-
Python作品数
-
-

<%= python_count %>

-
-
-
- -
-
-
背景素材数
-
-

<%= backdrop_count %>

-
-
-
- -
-
-
角色素材数
-
-

<%= sprite_count %>

-
-
-
-
-
- -
-
diff --git a/views/admin/admin_material_backdrop.ejs b/views/admin/admin_material_backdrop.ejs deleted file mode 100644 index 20fb11d..0000000 --- a/views/admin/admin_material_backdrop.ejs +++ /dev/null @@ -1,47 +0,0 @@ - - - - - -
-
-
-
-

添加背景的两种模式:

-

1、背景的真实宽高:960*720,三个参数分别为:480、360、2

-

2、背景的真实宽高:480*360,三个参数分别为:240、180、1

-
- - - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_material_costume.ejs b/views/admin/admin_material_costume.ejs deleted file mode 100644 index f7433e8..0000000 --- a/views/admin/admin_material_costume.ejs +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
-
-
-
-

添加造型的两种模式:

-

1、SVG格式:三个参数分别为:自定宽、自定高、1(宽高比与SVG真实宽高比一致)

-

2、其他格式:三个参数分别为:真实宽/2、真实高/2、2(图片格式可以是:JPG、PNG)

-

提示:可以先直接在Scratch造型中上传文件,会得到半宽与半高,再按提示修改原图片文件尺寸。

-
- - - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_material_sound.ejs b/views/admin/admin_material_sound.ejs deleted file mode 100644 index 14d5623..0000000 --- a/views/admin/admin_material_sound.ejs +++ /dev/null @@ -1,37 +0,0 @@ - - - - - -
-
-
- - - - - - \ No newline at end of file diff --git a/views/admin/admin_material_sprite.ejs b/views/admin/admin_material_sprite.ejs deleted file mode 100644 index 7693962..0000000 --- a/views/admin/admin_material_sprite.ejs +++ /dev/null @@ -1,46 +0,0 @@ - - - - - -
-
-
- - - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_material_sprite_costume.ejs b/views/admin/admin_material_sprite_costume.ejs deleted file mode 100644 index 5af4cf6..0000000 --- a/views/admin/admin_material_sprite_costume.ejs +++ /dev/null @@ -1,38 +0,0 @@ - - - - - -
-
-
- - - - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_material_sprite_sound.ejs b/views/admin/admin_material_sprite_sound.ejs deleted file mode 100644 index 106af76..0000000 --- a/views/admin/admin_material_sprite_sound.ejs +++ /dev/null @@ -1,33 +0,0 @@ - - - - - -
-
-
- - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_tag.ejs b/views/admin/admin_tag.ejs deleted file mode 100644 index 4a90888..0000000 --- a/views/admin/admin_tag.ejs +++ /dev/null @@ -1,30 +0,0 @@ - - - - - -
-
-
- - - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_user.ejs b/views/admin/admin_user.ejs deleted file mode 100644 index 782658e..0000000 --- a/views/admin/admin_user.ejs +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -
-
-
- - - - - - - \ No newline at end of file diff --git a/views/admin/admin_works_python.ejs b/views/admin/admin_works_python.ejs deleted file mode 100644 index 56d06d8..0000000 --- a/views/admin/admin_works_python.ejs +++ /dev/null @@ -1,41 +0,0 @@ - - - - - -
-
-
- - - - - - - - \ No newline at end of file diff --git a/views/admin/admin_works_scratch.ejs b/views/admin/admin_works_scratch.ejs deleted file mode 100644 index 286031a..0000000 --- a/views/admin/admin_works_scratch.ejs +++ /dev/null @@ -1,41 +0,0 @@ - - - - - -
-
-
- - - - - - - - \ No newline at end of file diff --git a/views/admin/style_script.ejs b/views/admin/style_script.ejs deleted file mode 100644 index e69de29..0000000 diff --git a/views/html-footer.ejs b/views/html-footer.ejs deleted file mode 100644 index 78c1ea7..0000000 --- a/views/html-footer.ejs +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - - - - - - \ No newline at end of file diff --git a/views/html-head.ejs b/views/html-head.ejs deleted file mode 100644 index 34f8422..0000000 --- a/views/html-head.ejs +++ /dev/null @@ -1,480 +0,0 @@ - - - - - - <%= global.configManager['site.name'] %> - <%= pageTitle %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
加载中
-
-
- Scratch - Python - 个人信息 - 退出 - - 关闭 -
-
- - - - - Scratch桌面版下载镜像 - 项目比较器 - 切换主题 - 开发者选项 - - - - ZeroCat - 由 孙悟元 开发 - Github - - 赞助 - - - 雨云 - - 关闭 - - - - - - Scratch - Python - 关闭 - - - - - - 修复登录问题 - 使用整活UI - - - - - - - - 主页 - Scratch - Python - 赞助 - - - - - - - - -
- -
- - - - Scratch - Python - - - - - 兔小巢 - 兔小巢(不登录) - QQ频道 - - Github Issues - 联系 孙悟元 - QQ交流群 - - - -
- - -
- - - - - - - - - -
\ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index bc20bcb..e62e223 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -1,364 +1,91 @@ -<%- include('./html-head.ejs', {pageTitle: '首页' }); %> - + + -
-
-
-
-
-
🚀
-
- <%= global.configManager['site.name'] %>,
启动! -
-

新一代开源编程社区

+ + + + + <%= global.configManager['site.name'] %> + + + + -
- 立刻加入 - 了解更多 - ZeroCat现由厚浪云提供支持 - -
-
- -
-
-
-
+ -
-
-
-
- - - - -
-
Scratch
-
图形化编程
-
-
-
-
- - - - -
-
Python
-
- 适合新手的代码编程语言 + + + + + + + + + + + +
+ + +
+
+
+
+
+
🚀
+
+ <%= global.configManager['site.name'] %>,
启动! +
+

+ <%= global.configManager['site.slogan'] %> +

+ +
+ 立刻加入 + 了解更多 + ZeroCat现由厚浪云提供支持 + +
+
+
- -
-
-
-
-
-
-
-
-
- 开源 -
-
ZeroCat 完全开源
-

- 自豪的作为国内少有的完整开源且内容完善的编程社区,我们向您提供了完整的在线编程解决方案 -

-
- GitHub -
-
-
-
-
-
-
- - - 名用户 -
-
-
-
-
- - - 个作品 -
-
-
-
-
- - 多位开发者 -
-
-
-
-
- 1 - 个大饼
-
-
-
+ + + + - - -<%- include('html-footer.ejs', {page: 'home' }); %> + \ No newline at end of file diff --git a/views/login_or_register.ejs b/views/login_or_register.ejs deleted file mode 100644 index 3196f6a..0000000 --- a/views/login_or_register.ejs +++ /dev/null @@ -1,157 +0,0 @@ -<%- include('html-head.ejs', {pageTitle: '登录/注册' }); %> - - - - -
- - - -
-
- - - -
-
- -
刷新 -
-
-
- - - - - -
-
- - -
- - - - -
-
您正在使用由厚浪(孙悟元)提供的服务
-
- 我们可能会收集您的个人信息,具体参见隐私策略
- -

- - 我们将在中国大陆安全的存储您的数据,我们暂不提供自助删除您的个人数据,如果您希望删除您的数据,您需要优先选择联系我们
- -

- 在<%= global.configManager['site.name'] %>上,你需要遵守社区行为准则(第三方站点)
- -

- 你需要同意用户协议
- -

对于技术手段绕过此页面的行为(视为对<%= global.configManager['site.name'] %> - 的基础设施进行攻击)涉嫌违法(非法入侵计算机系统),我们将保留追究法律责任的权利,且违规获得的账号不受保护,如果您同意以上内容,请点击“复选框”以完成注册流程. -
- -
- - -
-
- - - - - <%- include('./html-footer.ejs', {page: 'login' }); %> - - - - - - \ No newline at end of file diff --git a/views/my_info.ejs b/views/my_info.ejs deleted file mode 100644 index 00a245e..0000000 --- a/views/my_info.ejs +++ /dev/null @@ -1,186 +0,0 @@ -<%- include('./html-head.ejs', {pageTitle: '个人中心' }); %> - -
个人信息
-
- 您可以随时修改个人信息,可能要重新登录后本地生效 -
-
- - - 用户信息 - 头像 - 安全 - 用户名 - - -
- -
-
- -
-
-
- -
-
- - - - 猫娘 - -
- -
- 取消 - 确认 -
-
-
- -
-
- - - - 修改头像 - -

- -
-

-
-
- 确认 -
-
- -
- -
-
- 确认 -
-

-
- - - - 请完成验证码 - 部分地区加载可能较慢,请耐心等待。 - - - 刷新 - - 完成 - - - - - -<%- include('./html-footer.ejs', {page: 'myinfo' }); %> - - - - - - - diff --git a/views/python/my_python_projects.ejs b/views/python/my_python_projects.ejs deleted file mode 100644 index 1c17244..0000000 --- a/views/python/my_python_projects.ejs +++ /dev/null @@ -1,34 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Python'}); %> - - - 未分享的作品 - 已分享的作品 - 精选作品 - -
-
-
-
-<%- include('../html-footer.ejs', {page: 'python'}); %> - - - - diff --git a/views/python/my_python_work.py b/views/python/my_python_work.py deleted file mode 100644 index 3a0458c..0000000 --- a/views/python/my_python_work.py +++ /dev/null @@ -1,6 +0,0 @@ -import turtle - -t = turtle.Turtle() -t.forward(100) - -print "Hello World" diff --git a/views/python/next_python_play.ejs b/views/python/next_python_play.ejs deleted file mode 100644 index 38bd9af..0000000 --- a/views/python/next_python_play.ejs +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - <%= global.configManager['site.name'] %> - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- 运行 - - 清除 -
-
- -
- -
- - - - - - - - - - - - - - - - - - - - - - diff --git a/views/python/python_edit.ejs b/views/python/python_edit.ejs deleted file mode 100644 index 357145c..0000000 --- a/views/python/python_edit.ejs +++ /dev/null @@ -1,462 +0,0 @@ - - - - - - Python编程 - <%= global.configManager['site.name'] %> - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- 登录为 -
-
选择操作前请保存作品
-
- - -
-
-
- - -
-
-
-
-
-
- -
-
-
- -
-
- -
- -
-
-
-
-
-
/pythonstatic/img/welcome_python_editor.png") - no-repeat center; - background-size: contain; - background-size: auto 100%; - " - > -
-
-
-
- -
-
-
-
-
-
-
- -
-
项目信息
-
- 修改内容请手动保存到云端 -
- 分享 - -
- -
-
- -
-
-
- -
-
- -
-
文件操作
-
选择操作前请保存作品
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/views/python/python_play.ejs b/views/python/python_play.ejs deleted file mode 100644 index 49e7d60..0000000 --- a/views/python/python_play.ejs +++ /dev/null @@ -1,104 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Python' }); %> - -
-
- -
-
-
-
-
-
- -
-
- - -
- -
- - 运行 - - 清除 -
- -
- - -
- -
-
- 项目简介 -
- - - - - 浏览量: 加载中 - - Python - Python
- 查看代码 - - - -
-
-
-
- <%- include('../html-footer.ejs', {page: 'python' }); %> - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/views/python/python_projects.ejs b/views/python/python_projects.ejs deleted file mode 100644 index f9d061f..0000000 --- a/views/python/python_projects.ejs +++ /dev/null @@ -1,48 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Python'}); %> -
-

Python

- -
- - - - - -
- 搜索 - 内容搜索 -
- -
- - 最新 - 最热 - -
-
-
-
-
-
-<%- include('../html-footer.ejs', {page: 'python'}); %> - - diff --git a/views/repw.ejs b/views/repw.ejs deleted file mode 100644 index fc27787..0000000 --- a/views/repw.ejs +++ /dev/null @@ -1,79 +0,0 @@ -<%- include('./html-head.ejs', {pageTitle: '找回密码'}); %> <% if (login) { %> - -<% } %> - -
- - -
-
-
重设密码
- -
- -
- -
- 刷新 - -
- - 重设密码 - - 1 - -
-
-
-
-
- -<%- include('./html-footer.ejs', {page: 'login'}); %> - - - - - - - - - - diff --git a/views/scratch/my_scratch_projects.ejs b/views/scratch/my_scratch_projects.ejs deleted file mode 100644 index 495eeb7..0000000 --- a/views/scratch/my_scratch_projects.ejs +++ /dev/null @@ -1,35 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Scratch'}); %> - - - 未分享的作品 - 已分享的作品 - 精选作品 - -
-
-
-
-<%- include('../html-footer.ejs', {page: 'scratch'}); %> - - - - - diff --git a/views/scratch/scratch_edit.ejs b/views/scratch/scratch_edit.ejs deleted file mode 100644 index 7a18c5b..0000000 --- a/views/scratch/scratch_edit.ejs +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - Scratch编程 - <%= global.configManager['site.name'] %> - - - - - - - - - diff --git a/views/scratch/scratch_edit_next.ejs b/views/scratch/scratch_edit_next.ejs deleted file mode 100644 index 8baac20..0000000 --- a/views/scratch/scratch_edit_next.ejs +++ /dev/null @@ -1,608 +0,0 @@ - - - - - - - - ZeroCat - Run Scratch projects faster - - - - - - - - - - - - - - - - - - - - - 保存媒体库 - 清空log - 强制保存作品 - -
-
- - ZeroCat授权 - - - 保存 - - - -
- - - - - - - diff --git a/views/scratch/scratch_play.ejs b/views/scratch/scratch_play.ejs deleted file mode 100644 index 0e3c86b..0000000 --- a/views/scratch/scratch_play.ejs +++ /dev/null @@ -1,282 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Scratch' }); %> - - - -
-
- - - - -
- - - - -
-
/scratch_slt/1"); - " - > - 运行 -
-
-
- - 运行 - - 停止 - 打开旧版创作页
-
-
-
- 加载中 -
-
- 加载中 -
- - - - - - 加载中 - 加载中 - 加载中 - Scratch
- 复制链接 - 分析 - 打开创作页 - - 旧版播放器 - - - - - 作品分析 - 由 ZeroCat 统计 -
- 请加载旧版播放器后再使用分析 -
- -
-
- - -
-
-
- -
-
- -<%- include('../html-footer.ejs', {page: 'scratch' }); %> - - - - - - - - - - - - - - diff --git a/views/scratch/scratch_projects.ejs b/views/scratch/scratch_projects.ejs deleted file mode 100644 index a0fcaea..0000000 --- a/views/scratch/scratch_projects.ejs +++ /dev/null @@ -1,46 +0,0 @@ -<%- include('../html-head.ejs', {pageTitle: 'Scratch'}); %> - -
-

Scratch

- -
- - - -
- 搜索 - 内容搜索 -
- -
- - 最新 - 最热 - - -
-
-
-
-
-
- -<%- include('../html-footer.ejs', {page: 'scratch'}); %> - - diff --git a/views/search.ejs b/views/search.ejs deleted file mode 100644 index 2d14780..0000000 --- a/views/search.ejs +++ /dev/null @@ -1,100 +0,0 @@ -<%- include('./html-head.ejs', {pageTitle: 'Scratch' }); %> - -
-

搜索

- -
- - - - - - - - - - - 序号升序 - 序号降序 - 时间升序 - 时间降序 - 观看量升序 - 观看量降序 - - - - 所有 - scratch - python - - - - - - 选择用户 - - -
- - - - 搜索 - 取消选中 -
-
- 选择用户 - 点击选择在用户中搜索 - - - - -
-
- 搜索 - 解释 -
- -
-
-
-
-
-
-
- -<%- include('./html-footer.ejs', {page: 'scratch' }); %> - - diff --git a/views/share.ejs b/views/share.ejs deleted file mode 100644 index f960e9f..0000000 --- a/views/share.ejs +++ /dev/null @@ -1,135 +0,0 @@ - - - - - <%= global.configManager['site.name'] %>分享页面 - - - -
-
-
-
-
-
-
-

Hello there!

-
- - - - diff --git a/views/user.ejs b/views/user.ejs deleted file mode 100644 index c450690..0000000 --- a/views/user.ejs +++ /dev/null @@ -1,86 +0,0 @@ -<%- include('html-head.ejs', {pageTitle: '用户个人主页' }); %> - - - -
- 创作者 -
- - - 创作者 - -
- 创作者 -
-
- - Scratch - Python - - -
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
- -<%- include('./html-footer.ejs', {page: 'user' }); %> - - -