Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
SunWuyuan committed Oct 14, 2023
1 parent 0cec0c9 commit 522de00
Show file tree
Hide file tree
Showing 338 changed files with 639 additions and 144,116 deletions.
89 changes: 24 additions & 65 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,72 +189,31 @@ app.get("/", function (req, res) {
});
});

//翻页:Scratch作品列表:数据
app.post("/index/getScratchProjects", function (req, res) {
var curr = parseInt(req.body.curr); //当前要显示的页码
var limit = parseInt(req.body.limit); //每页显示的作品数
var type = "view_count";
if (req.body.type == "new") {
type = "time";
}

var SQL = `SELECT scratch.id, scratch.title, scratch.state,scratch.authorid, user.nickname,user.motto FROM scratch JOIN user ON scratch.authorid = user.id WHERE scratch.state > 0 ORDER BY scratch.${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);
}
});
});
//翻页:Python作品列表:数据
app.post("/index/getPythonProjects", function (req, res) {
var curr = parseInt(req.body.curr); //当前要显示的页码
var limit = parseInt(req.body.limit); //每页显示的作品数
var type = "view_count";
if (req.body.type == "new") {
type = "time";
}

var SQL = `SELECT python.id, python.title, python.state,python.authorid, python.description,user.nickname,user.motto FROM python JOIN user ON python.authorid = user.id WHERE python.state > 0 ORDER BY python.${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);
}
});
});

//搜索:Scratch项目列表:数据//只搜索标题
app.post("/index/seachProjects", function (req, res) {
if (!req.body.txt) {
res.status(200).send([]);
return;
}
var tabelName = "scratch";
if (req.body.t == "p") {
tabelName = "python";
}
var searchinfo = "title";
if (req.body.searchall == "true") {
searchinfo = "src";
}
//var SQL = `SELECT id, title FROM ${tabelName} WHERE state>0 AND (${searchinfo} LIKE ?) LIMIT 12`;
var SQL = `SELECT ${tabelName}.id, ${tabelName}.title, ${tabelName}.state,${tabelName}.authorid,${tabelName}.description, user.nickname,user.motto FROM ${tabelName} JOIN user ON ${tabelName}.authorid = user.id WHERE ${tabelName}.state>0 AND (${searchinfo} LIKE ?)`;
var WHERE = [`%${req.body.txt}%`];
DB.qww(SQL, WHERE, function (err, data) {
if (err) {
res.status(200).send([]);
} else {
res.status(200).send(data);
}
});
});
//app.post("/index/seachProjects", function (req, res) {
// if (!req.body.txt) {
// res.status(200).send([]);
// return;
// }
// var tabelName = "scratch";
// if (req.body.t == "p") {
// tabelName = "python";
// }
// var searchinfo = "title";
// if (req.body.searchall == "true") {
// searchinfo = "src";
// }
// //var SQL = `SELECT id, title FROM ${tabelName} WHERE state>0 AND (${searchinfo} LIKE ?) LIMIT 12`;
// var SQL = `SELECT ${tabelName}.id, ${tabelName}.title, ${tabelName}.state,${tabelName}.authorid,${tabelName}.description, user.nickname,user.motto FROM ${tabelName} JOIN user ON ${tabelName}.authorid = user.id WHERE ${tabelName}.state>0 AND (${searchinfo} LIKE ?)`;
// var WHERE = [`%${req.body.txt}%`];
// DB.qww(SQL, WHERE, function (err, data) {
// if (err) {
// res.status(200).send([]);
// } else {
// res.status(200).send(data);
// }
// });
//});

//放在最后,确保路由时能先执行app.all=====================
//注册、登录等功能路由,含密码找回功能
Expand Down
11 changes: 7 additions & 4 deletions build/ejs/hand.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="https://npm.elemecdn.com/[email protected]/dist/jquery.min.js"></script>
<script async src="https://umami.192325.xyz/script.js" data-website-id="be8c7cd8-d471-4a0b-b5a7-819a6af35613"></script>
<div class="appbar mdui-appbar mdui-appbar-fixed webkit-app-region">
<div class="mdui-toolbar mdui-color-theme"> <button href="javascript:;"
<div class="mdui-toolbar mdui-color-white"> <button href="javascript:;"
class="mdui-btn mdui-btn-icon mdui-ripple webkit-app-region-no" id="toggle"
mdui-drawer="{target: '#drawer',swipe: true}"><i class="mdui-icon material-icons">menu</i></button> <a
class="webkit-app-region-no" href="/"><span class="mdui-typo-title">
Expand Down Expand Up @@ -48,7 +48,10 @@
class="mdui-icon material-icons" id="close" onclick="close1()">close</i></button>-->
</div>
</div>

<style>.mdui-color-white {
background-color: #ffffff!important;
color: rgba(0,0,0,.87)!important;
}</style>

<div class="mdui-drawer mdui-drawer-close" id="drawer">
<ul class="mdui-list"> <a class="mdui-list-item mdui-ripple" href="/"><i
Expand Down Expand Up @@ -115,7 +118,7 @@
<a href="/scratch/edit" class="mdui-ripple md3botton"><i class="mdui-icon material-icons">add</i>
<label>Scratch项目</label> </a> <a href="/python/edit" class="mdui-ripple md3botton"> <i
class="mdui-icon material-icons">add</i> <label>Python项目</label> </a>
</div> <button class="mdui-btn mdui-ripple md3botton" mdui-dialog-close>关闭</button>
</div> <button class="mdui-btn mdui-ripple md3botton mdui-text-color-theme-text" mdui-dialog-close>关闭</button>
</div>
</div>
<div class="mdui-dialog md3botton" id="search">
Expand All @@ -128,7 +131,7 @@
Discussions</label>
</a> <a href="/user/tuxiaochao" class="mdui-ripple md3botton"> <i class="mdui-icon material-icons">feedback</i>
<label>兔小巢</label>
</a> </div> <button class="mdui-btn mdui-ripple md3botton" mdui-dialog-close>关闭</button>
</a> </div> <button class="mdui-btn mdui-ripple md3botton mdui-text-color-theme-text" mdui-dialog-close>关闭</button>
</div>
</div>

Expand Down
Loading

0 comments on commit 522de00

Please sign in to comment.