第六次提交

解决各页面查询问题
完善判题逻辑
完善后端管理界面登录功能
完善后端管理界面文章预览功能
完善博客功能
This commit is contained in:
陈佳彬 2024-09-23 18:19:04 +08:00
parent 8e25e7ec1e
commit 31ac90019b
22 changed files with 2400 additions and 143 deletions

View File

@ -167,6 +167,3 @@ System Error系统错误。在进行代码测评时测评机器发送错
- Vue - Vue
- 组件库 [Element-plus](https://element-plus.org/zh-CN/component/overview.html) - 组件库 [Element-plus](https://element-plus.org/zh-CN/component/overview.html)
- 文本编辑器 TODO - 文本编辑器 TODO

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ import top.weiyuexin.utils.OutHtml;
import top.weiyuexin.utils.Time; import top.weiyuexin.utils.Time;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @PackageName: top.weiyuexin.controller * @PackageName: top.weiyuexin.controller
@ -47,10 +48,24 @@ public class ArticleController {
} }
@GetMapping("manager/{id}")
public String managerGetById(@PathVariable("id") Integer id) {
Article article = articleService.getById(id);
article.setReadNum(article.getReadNum() + 1);
articleService.updateById(article);
User user = userService.getById(article.getAuthorId());
article.setAuthorName(user.getUsername());
return article.getContent();
}
@GetMapping("/list") @GetMapping("/list")
public W getPage(@RequestParam("page") Integer page, public W getPage(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, @RequestParam("limit") Integer limit,
Article article) { @RequestParam(value = "title", required = false) String title) {
Article article = new Article();
article.setTitle(title);
System.out.println(article.getTitle());
IPage<Article> Ipage = articleService.getPage(page, limit, article); IPage<Article> Ipage = articleService.getPage(page, limit, article);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值 //如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) { if (page > Ipage.getPages()) {
@ -83,7 +98,7 @@ public class ArticleController {
* @param article * @param article
* @return * @return
*/ */
@PostMapping("") @PostMapping("/add")
public R addArticle(Article article) { public R addArticle(Article article) {
article.setTime(Time.CurrentTime()); article.setTime(Time.CurrentTime());
return R.success(articleService.save(article)); return R.success(articleService.save(article));
@ -95,8 +110,9 @@ public class ArticleController {
* @param article * @param article
* @return * @return
*/ */
@PutMapping("") @PutMapping("/modify")
public R updateArticle(Article article) { public R updateArticle(Article article) {
System.out.println(article);
return R.success(articleService.updateById(article)); return R.success(articleService.updateById(article));
} }
@ -106,7 +122,7 @@ public class ArticleController {
* @param * @param
* @return * @return
*/ */
@DeleteMapping("/{id}") @DeleteMapping("/delete/{id}")
public R deleteArticle(@PathVariable("id") Integer id) { public R deleteArticle(@PathVariable("id") Integer id) {
return R.success(articleService.removeById(id), "删除成功"); return R.success(articleService.removeById(id), "删除成功");
} }

View File

@ -1,6 +1,9 @@
package top.weiyuexin.controller; package top.weiyuexin.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import top.weiyuexin.pojo.Evaluation; import top.weiyuexin.pojo.Evaluation;
@ -13,6 +16,7 @@ import top.weiyuexin.service.ProblemService;
import top.weiyuexin.service.UserService; import top.weiyuexin.service.UserService;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @PackageName: top.weiyuexin.controller * @PackageName: top.weiyuexin.controller
@ -42,27 +46,48 @@ public class EvaluationController {
@GetMapping("/list") @GetMapping("/list")
public W getPage(@RequestParam("page") Integer page, public W getPage(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, @RequestParam("limit") Integer limit,
Evaluation evaluation) { @RequestParam(value = "search", required = false) String search) {
IPage<Evaluation> Ipage = evaluationService.getPage(page, limit, evaluation); // IPage<Evaluation> Ipage = evaluationService.getPage(page, limit, evaluation);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值 // //如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) { // if (page > Ipage.getPages()) {
Ipage = evaluationService.getPage(page, limit, evaluation); // Ipage = evaluationService.getPage(page, limit, evaluation);
} // }
List<Evaluation> evaluations = Ipage.getRecords(); // List<Evaluation> evaluations = Ipage.getRecords();
//查询用户名和题目名称 // //查询用户名和题目名称
for (int i = 0; i < evaluations.size(); i++) { // for (int i = 0; i < evaluations.size(); i++) {
User user = userService.getById(evaluations.get(i).getUserId()); // User user = userService.getById(evaluations.get(i).getUserId());
// if (user != null) {
// evaluations.get(i).setUserName(user.getUsername());
// }
// Problem problem = problemService.getById(evaluations.get(i).getProblemId());
// if (problem != null) {
// evaluations.get(i).setProblemName(problem.getTitle());
// }
// }
// Ipage.setRecords(evaluations);
List<Evaluation> list = evaluationService.list(new LambdaQueryWrapper<Evaluation>().orderByDesc(Evaluation::getId));
List<Evaluation> collect = list.stream().filter(x -> {
Integer userId = x.getUserId();
User user = userService.getById(userId);
if (user != null) { if (user != null) {
evaluations.get(i).setUserName(user.getUsername()); x.setUserName(user.getUsername());
}
Problem problem = problemService.getById(evaluations.get(i).getProblemId());
if (problem != null) {
evaluations.get(i).setProblemName(problem.getTitle());
}
}
Ipage.setRecords(evaluations); }
return new W(0, (int) Ipage.getTotal(), Ipage.getRecords()); Problem problem = problemService.getById(x.getProblemId());
if (problem != null) {
x.setProblemName(problem.getTitle());
}
return (user != null && x.getUserName().contains(search)) || (problem != null && x.getProblemName().contains(search) || x.getLanguage().contains(search));
}).collect(Collectors.toList());
// 获取分页参数
int currentPage = page - 1; // Java下标从0开始所以需要减1
int pageSize = limit;
// 计算起始位置
int start = currentPage * pageSize;
List<Evaluation> result = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList());
return new W(0, collect.size(), result);
} }
/** /**

View File

@ -1,6 +1,8 @@
package top.weiyuexin.controller; package top.weiyuexin.controller;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import io.jsonwebtoken.lang.Strings;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import top.weiyuexin.pojo.Problem; import top.weiyuexin.pojo.Problem;
@ -41,13 +43,21 @@ public class ProblemController {
* *
* @param page * @param page
* @param limit * @param limit
* @param problem
* @return * @return
*/ */
@GetMapping("/list") @GetMapping("/list")
public W getPage(@RequestParam("page") Integer page, public W getPage(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, @RequestParam("limit") Integer limit,
Problem problem) { @RequestParam(value = "search",required = false) String condition) {
Problem problem = new Problem();
if (Strings.hasText(condition)){
problem.setTitle(condition);
problem.setDifficulty(condition);
if (StringUtils.isNumber(condition)){
problem.setId(Integer.parseInt(condition));
}
}
IPage<Problem> Ipage = problemService.getPage(page, limit, problem); IPage<Problem> Ipage = problemService.getPage(page, limit, problem);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值 //如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) { if (page > Ipage.getPages()) {

View File

@ -80,15 +80,8 @@ public class UserController {
@GetMapping("/rank") @GetMapping("/rank")
public W rank(@RequestParam("page") Integer page, public W rank(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, @RequestParam("limit") Integer limit,
User user) { @RequestParam(value = "search",required = false) String search) {
IPage<User> Ipage = userService.rank(page, limit, user); IPage<User> Ipage = userService.rank(page, limit, search);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) {
Ipage = userService.getPage(page, limit, user);
}
List<User> users = Ipage.getRecords();
Ipage.setRecords(users);
return new W(0, (int) Ipage.getTotal(), Ipage.getRecords()); return new W(0, (int) Ipage.getTotal(), Ipage.getRecords());
} }

View File

@ -24,7 +24,7 @@ public interface UserService extends IService<User> {
IPage<User> getPage(Integer currentPage, Integer pageSize, User user); IPage<User> getPage(Integer currentPage, Integer pageSize, User user);
IPage<User> rank(Integer currentPage, Integer pageSize, User user); IPage<User> rank(Integer currentPage, Integer pageSize, String search);
List<User> indexRank(Integer num); List<User> indexRank(Integer num);
} }

View File

@ -35,9 +35,8 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
@Override @Override
public IPage<Article> getPage(Integer currentPage, Integer pageSize, Article article) { public IPage<Article> getPage(Integer currentPage, Integer pageSize, Article article) {
LambdaQueryWrapper<Article> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Article> lqw = new LambdaQueryWrapper<>();
lqw.like(Strings.isNotEmpty(article.getTitle()),Article::getTitle, article.getTitle());
lqw.orderByDesc(Article::getTime); lqw.orderByDesc(Article::getTime);
lqw.like(article.getAuthorId() != null, Article::getAuthorId, article.getAuthorId());
lqw.like(Strings.isNotEmpty(article.getTitle()), Article::getTitle, article.getTitle());
IPage<Article> page = new Page<>(currentPage, pageSize); IPage<Article> page = new Page<>(currentPage, pageSize);
articleMapper.selectPage(page, lqw); articleMapper.selectPage(page, lqw);
return page; return page;

View File

@ -10,6 +10,7 @@ import top.weiyuexin.service.CodeService;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/** /**
* @PackageName: top.weiyuexin.service.impl * @PackageName: top.weiyuexin.service.impl
@ -220,7 +221,11 @@ public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements Co
Process p = null; Process p = null;
try { try {
//1.编译c文件 //1.编译c文件
p = Runtime.getRuntime().exec("g++ main.cpp" + " -o " + "main", null, new File(code.getCodePath())); // try {
p = Runtime.getRuntime().exec("g++ "+new File(code.getCodePath()).getAbsolutePath()+"/main.cpp" + " -o " + "main");
// } catch (IOException e) {
// e.printStackTrace();
// }
// 获取进程的错误流 // 获取进程的错误流
final InputStream is = p.getErrorStream(); final InputStream is = p.getErrorStream();
// 开一个线程,读标准错误流 // 开一个线程,读标准错误流
@ -440,24 +445,29 @@ public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements Co
String inputData = testCase.getInput(); String inputData = testCase.getInput();
String outputData = ""; String outputData = "";
try { try {
Process process = Runtime.getRuntime().exec("node main.js", null, new File(code.getCodePath())); Process process = Runtime.getRuntime().exec("node main.js" ,null,new File(code.getCodePath()));
if (!inputData.equals("")) { if (!inputData.equals("")) {
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
bout.write(inputData); bout.write(inputData);
bout.flush();
bout.close(); bout.close();
} }
int i = process.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK"))); Thread.sleep(100);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null; String line = null;
StringBuffer b = new StringBuffer(); StringBuffer b = new StringBuffer();
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
//b.append(line + "\n"); //b.append(line + "\n");
b.append(line); b.append(line);
} }
br.close();
outputData = b.toString(); outputData = b.toString();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return R.error("JavaScript程序执行时发送错误"); return R.error("JavaScript程序执行时发送错误");
} catch (InterruptedException e) {
e.printStackTrace();
} }
return R.success(outputData, "JavaScript程序执行成功"); return R.success(outputData, "JavaScript程序执行成功");
} }

View File

@ -29,11 +29,10 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
@Override @Override
public IPage<Problem> getPage(Integer currentPage, Integer pageSize, Problem problem) { public IPage<Problem> getPage(Integer currentPage, Integer pageSize, Problem problem) {
LambdaQueryWrapper<Problem> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Problem> lqw = new LambdaQueryWrapper<>();
lqw.orderByDesc(Problem::getId);
//如果不为空则查询 //如果不为空则查询
lqw.like(Strings.isNotEmpty(problem.getTitle()), Problem::getTitle, problem.getTitle()); lqw.like(Strings.isNotEmpty(problem.getTitle()), Problem::getTitle, problem.getTitle()).or().
lqw.like(Strings.isNotEmpty(problem.getDescription()), Problem::getDescription, problem.getDescription()); like(problem.getId()!=null,Problem::getId, problem.getId()).or().like(Strings.isNotEmpty(problem.getDifficulty()),Problem::getDifficulty, problem.getDifficulty());
lqw.like(Strings.isNotEmpty(problem.getDifficulty()), Problem::getDifficulty, problem.getDifficulty()); lqw.orderByDesc(Problem::getId);
IPage<Problem> page = new Page<>(currentPage, pageSize); IPage<Problem> page = new Page<>(currentPage, pageSize);
problemMapper.selectPage(page, lqw); problemMapper.selectPage(page, lqw);
return page; return page;

View File

@ -73,18 +73,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
* *
* @param currentPage * @param currentPage
* @param pageSize * @param pageSize
* @param user
* @return * @return
*/ */
@Override @Override
public IPage<User> rank(Integer currentPage, Integer pageSize, User user) { public IPage<User> rank(Integer currentPage, Integer pageSize, String search) {
LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
lqw.orderByDesc(User::getSolvedNum); lqw.orderByDesc(User::getSolvedNum);
//如果username不为空则查询 //如果username不为空则查询
lqw.like(Strings.isNotEmpty(user.getUsername()), User::getUsername, user.getUsername()); lqw.like(Strings.isNotEmpty(search), User::getUsername, search);
lqw.like(Strings.isNotEmpty(user.getEmail()), User::getEmail, user.getEmail());
lqw.like(Strings.isNotEmpty(user.getSex()), User::getSex, user.getSex());
lqw.eq(User::getIsAdmin, 0);
IPage<User> page = new Page<>(currentPage, pageSize); IPage<User> page = new Page<>(currentPage, pageSize);
userMapper.selectPage(page, lqw); userMapper.selectPage(page, lqw);
return page; return page;

View File

@ -245,7 +245,7 @@
}); });
} else if (obj.event === 'view') { } else if (obj.event === 'view') {
window.open("http://pns.weiyuexin.top/article/" + obj.data.id); window.open("http://localhost:8080/article/manager/" + obj.data.id);
} }
}); });

View File

@ -54,7 +54,7 @@ export default {
/* 非必须 */ /* 非必须 */
.height-300 { .height-300 {
height: 400px; height: 100%;
} }
</style> </style>

View File

@ -15,12 +15,12 @@
</el-icon> </el-icon>
题目 题目
</el-menu-item> </el-menu-item>
<el-menu-item index="/contest"> <!-- <el-menu-item index="/contest">-->
<el-icon> <!-- <el-icon>-->
<TrophyBase/> <!-- <TrophyBase/>-->
</el-icon> <!-- </el-icon>-->
竞赛 <!-- 竞赛-->
</el-menu-item> <!-- </el-menu-item>-->
<el-menu-item index="/status"> <el-menu-item index="/status">
<el-icon> <el-icon>
<TrendCharts/> <TrendCharts/>
@ -190,7 +190,7 @@ export default {
padding-top: 15px; padding-top: 15px;
height: 59px !important; height: 59px !important;
float: right !important; float: right !important;
margin-left: 400px; margin-left: 50%;
} }
.logo img { .logo img {

View File

@ -108,6 +108,13 @@ const routes = [
title: "编辑文章 - Online Judge - Henu" title: "编辑文章 - Online Judge - Henu"
} }
}, },
{
path: "/article/modify/:id",
component: EditArticle,
meta: {
title: "编辑文章 - Online Judge - Henu"
}
},
{ {
path: "/article/:id", path: "/article/:id",
name: "article", name: "article",

View File

@ -7,6 +7,8 @@
<el-col :span="24" class="msg">作者{{ article.authorName }} &nbsp;&nbsp; <el-col :span="24" class="msg">作者{{ article.authorName }} &nbsp;&nbsp;
发布时间{{ article.time }}&nbsp;&nbsp; 发布时间{{ article.time }}&nbsp;&nbsp;
阅读量{{ article.readNum }} 阅读量{{ article.readNum }}
<el-button type="danger" size="small" style="float: right" v-if="user.username===article.authorName" @click="deleteArticle">删除</el-button>
<el-button type="primary" size="small" style="float: right;margin-right: 10px;" v-if="user.username===article.authorName" @click="goToModify">编辑</el-button>
</el-col> </el-col>
<el-col :span="24" class="content" v-html="article.content"> <el-col :span="24" class="content" v-html="article.content">
</el-col> </el-col>
@ -21,7 +23,9 @@
import NavBar from "@/components/oj/common/NavBar.vue"; import NavBar from "@/components/oj/common/NavBar.vue";
import Footer from "@/components/oj/common/Footer"; import Footer from "@/components/oj/common/Footer";
import axios from "axios"; import axios from "axios";
import {ElMessage} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
import Cookies from "js-cookie";
import router from "@/router";
export default { export default {
// eslint-disable-next-line vue/multi-word-component-names // eslint-disable-next-line vue/multi-word-component-names
@ -29,7 +33,8 @@ export default {
data() { data() {
return { return {
articleId: 0, articleId: 0,
article: {} article: {},
user: {}
}; };
}, },
components: { components: {
@ -39,8 +44,51 @@ export default {
mounted() { mounted() {
this.articleId = this.$route.params.id this.articleId = this.$route.params.id
this.getArticle() this.getArticle()
if (Cookies.get('user')!==undefined && Cookies.get('user')!==null){
this.user=JSON.parse(Cookies.get('user'));
console.log(this.user)
}
}, },
methods: { methods: {
deleteArticle(){
ElMessageBox.confirm(
'确定删除吗?',
'Warning',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
).then(()=>{
axios.delete("/api/article/delete/"+this.articleId)
.then(response=>{
if (response.data.code===200){
ElMessage({
message: '删除成功',
type: 'success',
})
router.push("/blog")
}else{
ElMessage({
message: '删除失败',
type: 'warning',
})
}
})
.catch(()=>{
ElMessage({
message: '删除失败',
type: 'warning',
})
})
})
},
goToModify(){
router.push("/article/modify/"+this.articleId)
},
getArticle() { getArticle() {
console.log(this.articleId) console.log(this.articleId)
axios.get("/api/article/" + this.articleId) axios.get("/api/article/" + this.articleId)

View File

@ -44,11 +44,13 @@ import {ElMessage, ElMessageBox} from 'element-plus'
import axios from "axios"; import axios from "axios";
import qs from "qs"; import qs from "qs";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import router from "@/router";
export default { export default {
name: "EditArticle", name: "EditArticle",
data() { data() {
return { return {
articleId: 0,
title: '', title: '',
content: "", content: "",
user: {} user: {}
@ -57,9 +59,18 @@ export default {
mounted() { mounted() {
const user = Cookies.get('user') const user = Cookies.get('user')
this.user = JSON.parse(user) this.user = JSON.parse(user)
if (window.location.pathname.startsWith("/article/modify/")){
this.articleId = this.$route.params.id
axios.get("/api/article/" + this.articleId).then(response => {
if (response.data.code === 200) {
this.title = response.data.data.title
this.valueHtml = response.data.data.content
}
})
}
}, },
methods: { methods: {
submit() { add(){
this.content = this.valueHtml this.content = this.valueHtml
ElMessageBox.confirm( ElMessageBox.confirm(
'确定发布吗?', '确定发布吗?',
@ -84,10 +95,10 @@ export default {
// //
window.setTimeout(function () { window.setTimeout(function () {
location.href = "/"; location.href = "/";
}, 2000); }, 200);
return return
} }
axios.post("/api/article/", postData) axios.post("/api/article/add", postData)
.then(response => { .then(response => {
console.log(response.data) console.log(response.data)
if (response.data.code === 200) { if (response.data.code === 200) {
@ -95,6 +106,7 @@ export default {
message: '发布成功', message: '发布成功',
type: 'success', type: 'success',
}) })
router.push("/blog")
} else { } else {
ElMessage({ ElMessage({
message: response.data.msg, message: response.data.msg,
@ -117,6 +129,82 @@ export default {
message: '取消发布', message: '取消发布',
}) })
}) })
},
modify(){
this.content = this.valueHtml
ElMessageBox.confirm(
'确定修改吗?',
'Warning',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
let postData = qs.stringify({
id: this.articleId,
title: this.title,
content: this.content,
authorId: this.user.id
})
if (JSON.stringify(this.user) === '{}') {
ElMessage({
type: 'info',
message: '请先登录',
})
//
window.setTimeout(function () {
location.href = "/";
}, 200);
return
}
axios.put("/api/article/modify", postData)
.then(response => {
console.log(response.data)
if (response.data.code === 200) {
ElMessage({
message: '修改成功',
type: 'success',
})
router.push("/blog")
} else {
ElMessage({
message: response.data.msg,
type: 'error',
})
}
})
.catch(error => {
ElMessage({
message: '修改失败',
type: 'warning',
})
console.log(error);
})
})
.catch(() => {
ElMessage({
type: 'info',
message: '取消修改',
})
})
},
submit() {
if (this.title === '') {
ElMessage({
message: '请输入文章标题',
type: 'warning',
})
return
}
if (window.location.pathname.startsWith("/article/modify/")){
this.modify()
}else{
this.add()
}
} }
}, },
components: { components: {
@ -139,7 +227,7 @@ export default {
// }); // });
const toolbarConfig = {}; const toolbarConfig = {};
const editorConfig = {placeholder: '请输入内容...',MENU_CONF:{}}; const editorConfig = {placeholder: '请输入内容...', MENU_CONF: {}};
editorConfig.MENU_CONF['uploadImage'] = { editorConfig.MENU_CONF['uploadImage'] = {
server: '/api/cos/upload', server: '/api/cos/upload',
} }

View File

@ -15,7 +15,11 @@
size="medium" size="medium"
placeholder="请输入关键字搜索" placeholder="请输入关键字搜索"
v-model="search"> v-model="search">
<i @click="goToSearch" class="el-input__icon el-icon-search"></i> <template #suffix>
<el-icon @click="goToSearch" class="el-input__icon">
<Search/>
</el-icon>
</template>
</el-input> </el-input>
</el-col> </el-col>
</el-row> </el-row>
@ -98,10 +102,23 @@ export default {
this.getPage() this.getPage()
}, },
goToSearch() { goToSearch() {
alert("搜索") this.getPage();
}, },
getPage() { getPage() {
axios.get("/api/article/list?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { let condition = {
title: this.search
}
if (condition.title==="" || condition.title===undefined || condition.title===null){
condition={}
}
axios.get("/api/article/list"
,{
params: {
limit: this.pageSize,
page: this.currentPage,
...condition
}
}).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.articles = response.data.data this.articles = response.data.data
this.total = response.data.count this.total = response.data.count

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="split"> <div class="split">
<el-scrollbar height="710px"> <el-scrollbar height="1000px">
<NavBar :active="`/problems`"></NavBar> <NavBar :active="`/problems`"></NavBar>
<div class="my-split"> <div class="my-split">
<Split v-model="split1"> <Split v-model="split1">
@ -63,15 +63,29 @@
</el-row> </el-row>
</el-header> </el-header>
<el-main class="code-main"> <el-main class="code-main">
<prism-editor <div v-if="theme==='暗夜'">
class="my-editor height-300" <prism-editor
v-model="code" class="my-editor-black height-300"
aria-disabled v-model="code"
:highlight="highlighter" aria-disabled
line-numbers :highlight="highlighter"
:readonly="false" :line-numbers="true"
:tabSize="4" :readonly="false"
></prism-editor> :tabSize="4"
></prism-editor>
</div>
<div v-else>
<prism-editor
class="my-editor-white height-300"
v-model="code"
aria-disabled
:highlight="highlighter"
:line-numbers="true"
:readonly="false"
:tabSize="4"
></prism-editor>
</div>
</el-main> </el-main>
</el-container> </el-container>
</div> </div>
@ -92,6 +106,7 @@
</template> </template>
</Split> </Split>
</div> </div>
<Footer></Footer>
</el-scrollbar> </el-scrollbar>
</div> </div>
</template> </template>
@ -109,6 +124,7 @@ import "prismjs/themes/prism-tomorrow.css";
import axios from "axios"; import axios from "axios";
import qs from "qs"; import qs from "qs";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import Footer from "@/components/oj/common/Footer";
export default { export default {
// eslint-disable-next-line vue/multi-word-component-names // eslint-disable-next-line vue/multi-word-component-names
@ -164,6 +180,7 @@ export default {
}; };
}, },
components: { components: {
Footer,
NavBar, NavBar,
PrismEditor PrismEditor
}, },
@ -489,20 +506,40 @@ export default {
height: 100%; height: 100%;
} }
.my-editor { .my-editor-black {
background: #2d2d2d; background: #2d2d2d;
color: #ccc; color: #ccc;
font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace; font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
font-size: 14px; font-size: 16px;
line-height: 1.5; line-height: 1.5;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.my-editor-white {
background: #f5f5f5;
color: #000000;
font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
font-size: 16px;
line-height: 1.5;
padding: 10px;
width: 100%;
height: 100%;
}
.ivu-split-wrapper{
height: 100%;
}
.prism-editor__textarea:focus { .prism-editor__textarea:focus {
outline: none; outline: none;
} }
.prism-editor__editor{
padding:2px;
}
/* 非必须 */ /* 非必须 */
.height-300 { .height-300 {
height: 460px; height: 460px;

View File

@ -3,8 +3,8 @@
<el-scrollbar height="710px"> <el-scrollbar height="710px">
<NavBar :active="`/problems`"></NavBar> <NavBar :active="`/problems`"></NavBar>
<div class="content"> <div class="content">
<el-row>
<el-col :span="18" class="container"> <el-col class="container">
<el-row> <el-row>
<el-col :span="24" class="title"> <el-col :span="24" class="title">
<el-row> <el-row>
@ -92,10 +92,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="6">
</el-col>
</el-row>
</div> </div>
<Footer></Footer> <Footer></Footer>
</el-scrollbar> </el-scrollbar>
@ -139,10 +136,16 @@ export default {
this.getPage() this.getPage()
}, },
goToSearch() { goToSearch() {
alert("搜索") this.getPage()
}, },
getPage(){ getPage(){
axios.get("/api/problem/list?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { axios.get("/api/problem/list", {
params: {
search: this.search,
limit: this.pageSize,
page: this.currentPage,
}
}).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.problems = response.data.data this.problems = response.data.data
this.total = response.data.count this.total = response.data.count
@ -161,9 +164,10 @@ export default {
<style scoped> <style scoped>
.content { .content {
padding: 20px 40px; margin-left: 40px;
margin-right: 40px;
padding-top: 30px;
} }
.el-link.el-link--primary { .el-link.el-link--primary {
color: #000 !important; color: #000 !important;
} }
@ -186,6 +190,7 @@ export default {
.container { .container {
padding-top: 20px; padding-top: 20px;
border-radius: 10px;
} }
.container .title { .container .title {

View File

@ -125,7 +125,13 @@ export default {
this.getPage() this.getPage()
}, },
getPage() { getPage() {
axios.get("/api/user/rank?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { axios.get("/api/user/rank", {
params:{
limit: this.pageSize,
page: this.currentPage,
search: this.keyword
}
}).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.rank = response.data.data this.rank = response.data.data
this.total = response.data.count this.total = response.data.count
@ -139,14 +145,7 @@ export default {
}) })
}, },
goToSearch() { goToSearch() {
if (this.keyword === "") { this.getPage()
ElMessage({
message: '请输入关键字',
type: 'warning',
})
} else {
//
}
} }
} }
} }

View File

@ -13,19 +13,7 @@
<el-col :span="4" class="search"> <el-col :span="4" class="search">
<el-input <el-input
size="large" size="large"
placeholder="请输入题目ID以搜索" placeholder="请输入题目或用户名以搜索"
v-model="search">
<template #suffix>
<el-icon @click="goToSearch" class="el-input__icon">
<Search/>
</el-icon>
</template>
</el-input>
</el-col>
<el-col :span="4" class="search">
<el-input
size="large"
placeholder="请输入用户名以搜索"
v-model="search"> v-model="search">
<template #suffix> <template #suffix>
<el-icon @click="goToSearch" class="el-input__icon"> <el-icon @click="goToSearch" class="el-input__icon">
@ -118,23 +106,17 @@ export default {
Footer Footer
}, },
mounted() { mounted() {
axios.get("/api/evaluation/list?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { this.getPage()
if (response.data.code === 0) {
this.problems = response.data.data
this.total = response.data.count
}
}).catch(error => {
ElMessage({
message: '后端接口错误',
type: 'warning',
})
console.log(error);
})
}, },
methods: { methods: {
handleSizeChange(val) { getPage(){
this.pageSize = val; axios.get("/api/evaluation/list", {
axios.get("/api/evaluation/list?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { params:{
limit: this.pageSize,
page: this.currentPage,
search: this.search
}
}).then(response => {
if (response.data.code === 0) { if (response.data.code === 0) {
this.problems = response.data.data this.problems = response.data.data
this.total = response.data.count this.total = response.data.count
@ -147,23 +129,16 @@ export default {
console.log(error); console.log(error);
}) })
}, },
handleSizeChange(val) {
this.pageSize = val;
this.getPage();
},
handleCurrentChange(val) { handleCurrentChange(val) {
this.currentPage = val; this.currentPage = val;
axios.get("/api/evaluation/list?limit=" + this.pageSize + "&page=" + this.currentPage, {}).then(response => { this.getPage()
if (response.data.code === 0) {
this.problems = response.data.data
this.total = response.data.count
}
}).catch(error => {
ElMessage({
message: '后端接口错误',
type: 'warning',
})
console.log(error);
})
}, },
goToSearch() { goToSearch() {
alert("搜索") this.getPage()
} }
} }
} }