第六次提交

解决各页面查询问题
完善判题逻辑
完善后端管理界面登录功能
完善后端管理界面文章预览功能
完善博客功能
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
- 组件库 [Element-plus](https://element-plus.org/zh-CN/component/overview.html)
- 文本编辑器 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 java.util.List;
import java.util.stream.Collectors;
/**
* @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")
public W getPage(@RequestParam("page") Integer page,
@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);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) {
@ -83,7 +98,7 @@ public class ArticleController {
* @param article
* @return
*/
@PostMapping("")
@PostMapping("/add")
public R addArticle(Article article) {
article.setTime(Time.CurrentTime());
return R.success(articleService.save(article));
@ -95,8 +110,9 @@ public class ArticleController {
* @param article
* @return
*/
@PutMapping("")
@PutMapping("/modify")
public R updateArticle(Article article) {
System.out.println(article);
return R.success(articleService.updateById(article));
}
@ -106,7 +122,7 @@ public class ArticleController {
* @param
* @return
*/
@DeleteMapping("/{id}")
@DeleteMapping("/delete/{id}")
public R deleteArticle(@PathVariable("id") Integer id) {
return R.success(articleService.removeById(id), "删除成功");
}

View File

@ -1,6 +1,9 @@
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.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.weiyuexin.pojo.Evaluation;
@ -13,6 +16,7 @@ import top.weiyuexin.service.ProblemService;
import top.weiyuexin.service.UserService;
import java.util.List;
import java.util.stream.Collectors;
/**
* @PackageName: top.weiyuexin.controller
@ -42,27 +46,48 @@ public class EvaluationController {
@GetMapping("/list")
public W getPage(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit,
Evaluation evaluation) {
IPage<Evaluation> Ipage = evaluationService.getPage(page, limit, evaluation);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) {
Ipage = evaluationService.getPage(page, limit, evaluation);
}
List<Evaluation> evaluations = Ipage.getRecords();
//查询用户名和题目名称
for (int i = 0; i < evaluations.size(); i++) {
User user = userService.getById(evaluations.get(i).getUserId());
@RequestParam(value = "search", required = false) String search) {
// IPage<Evaluation> Ipage = evaluationService.getPage(page, limit, evaluation);
// //如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
// if (page > Ipage.getPages()) {
// Ipage = evaluationService.getPage(page, limit, evaluation);
// }
// List<Evaluation> evaluations = Ipage.getRecords();
// //查询用户名和题目名称
// for (int i = 0; i < evaluations.size(); i++) {
// 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) {
evaluations.get(i).setUserName(user.getUsername());
}
Problem problem = problemService.getById(evaluations.get(i).getProblemId());
if (problem != null) {
evaluations.get(i).setProblemName(problem.getTitle());
}
}
x.setUserName(user.getUsername());
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;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.jsonwebtoken.lang.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.weiyuexin.pojo.Problem;
@ -41,13 +43,21 @@ public class ProblemController {
*
* @param page
* @param limit
* @param problem
* @return
*/
@GetMapping("/list")
public W getPage(@RequestParam("page") Integer page,
@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);
//如果当前页码值大于当前页码值那么重新执行查询操作使用最大页码值作为当前页码值
if (page > Ipage.getPages()) {

View File

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

View File

@ -35,9 +35,8 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
@Override
public IPage<Article> getPage(Integer currentPage, Integer pageSize, Article article) {
LambdaQueryWrapper<Article> lqw = new LambdaQueryWrapper<>();
lqw.like(Strings.isNotEmpty(article.getTitle()),Article::getTitle, article.getTitle());
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);
articleMapper.selectPage(page, lqw);
return page;

View File

@ -10,6 +10,7 @@ import top.weiyuexin.service.CodeService;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* @PackageName: top.weiyuexin.service.impl
@ -220,7 +221,11 @@ public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements Co
Process p = null;
try {
//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();
// 开一个线程,读标准错误流
@ -440,24 +445,29 @@ public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements Co
String inputData = testCase.getInput();
String outputData = "";
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("")) {
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
bout.write(inputData);
bout.flush();
bout.close();
}
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK")));
int i = process.waitFor();
Thread.sleep(100);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
StringBuffer b = new StringBuffer();
while ((line = br.readLine()) != null) {
//b.append(line + "\n");
b.append(line);
}
br.close();
outputData = b.toString();
} catch (IOException e) {
e.printStackTrace();
return R.error("JavaScript程序执行时发送错误");
} catch (InterruptedException e) {
e.printStackTrace();
}
return R.success(outputData, "JavaScript程序执行成功");
}

View File

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

View File

@ -73,18 +73,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
*
* @param currentPage
* @param pageSize
* @param user
* @return
*/
@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<>();
lqw.orderByDesc(User::getSolvedNum);
//如果username不为空则查询
lqw.like(Strings.isNotEmpty(user.getUsername()), User::getUsername, user.getUsername());
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);
lqw.like(Strings.isNotEmpty(search), User::getUsername, search);
IPage<User> page = new Page<>(currentPage, pageSize);
userMapper.selectPage(page, lqw);
return page;

View File

@ -245,7 +245,7 @@
});
} 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: 400px;
height: 100%;
}
</style>

View File

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

View File

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

View File

@ -7,6 +7,8 @@
<el-col :span="24" class="msg">作者{{ article.authorName }} &nbsp;&nbsp;
发布时间{{ article.time }}&nbsp;&nbsp;
阅读量{{ 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 :span="24" class="content" v-html="article.content">
</el-col>
@ -21,7 +23,9 @@
import NavBar from "@/components/oj/common/NavBar.vue";
import Footer from "@/components/oj/common/Footer";
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 {
// eslint-disable-next-line vue/multi-word-component-names
@ -29,7 +33,8 @@ export default {
data() {
return {
articleId: 0,
article: {}
article: {},
user: {}
};
},
components: {
@ -39,8 +44,51 @@ export default {
mounted() {
this.articleId = this.$route.params.id
this.getArticle()
if (Cookies.get('user')!==undefined && Cookies.get('user')!==null){
this.user=JSON.parse(Cookies.get('user'));
console.log(this.user)
}
},
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() {
console.log(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 qs from "qs";
import Cookies from "js-cookie";
import router from "@/router";
export default {
name: "EditArticle",
data() {
return {
articleId: 0,
title: '',
content: "",
user: {}
@ -57,9 +59,18 @@ export default {
mounted() {
const user = Cookies.get('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: {
submit() {
add(){
this.content = this.valueHtml
ElMessageBox.confirm(
'确定发布吗?',
@ -84,10 +95,10 @@ export default {
//
window.setTimeout(function () {
location.href = "/";
}, 2000);
}, 200);
return
}
axios.post("/api/article/", postData)
axios.post("/api/article/add", postData)
.then(response => {
console.log(response.data)
if (response.data.code === 200) {
@ -95,6 +106,7 @@ export default {
message: '发布成功',
type: 'success',
})
router.push("/blog")
} else {
ElMessage({
message: response.data.msg,
@ -117,6 +129,82 @@ export default {
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: {
@ -139,7 +227,7 @@ export default {
// });
const toolbarConfig = {};
const editorConfig = {placeholder: '请输入内容...',MENU_CONF:{}};
const editorConfig = {placeholder: '请输入内容...', MENU_CONF: {}};
editorConfig.MENU_CONF['uploadImage'] = {
server: '/api/cos/upload',
}

View File

@ -15,7 +15,11 @@
size="medium"
placeholder="请输入关键字搜索"
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-col>
</el-row>
@ -98,10 +102,23 @@ export default {
this.getPage()
},
goToSearch() {
alert("搜索")
this.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) {
this.articles = response.data.data
this.total = response.data.count

View File

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

View File

@ -3,8 +3,8 @@
<el-scrollbar height="710px">
<NavBar :active="`/problems`"></NavBar>
<div class="content">
<el-row>
<el-col :span="18" class="container">
<el-col class="container">
<el-row>
<el-col :span="24" class="title">
<el-row>
@ -92,10 +92,7 @@
</el-col>
</el-row>
</el-col>
<el-col :span="6">
</el-col>
</el-row>
</div>
<Footer></Footer>
</el-scrollbar>
@ -139,10 +136,16 @@ export default {
this.getPage()
},
goToSearch() {
alert("搜索")
this.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) {
this.problems = response.data.data
this.total = response.data.count
@ -161,9 +164,10 @@ export default {
<style scoped>
.content {
padding: 20px 40px;
margin-left: 40px;
margin-right: 40px;
padding-top: 30px;
}
.el-link.el-link--primary {
color: #000 !important;
}
@ -186,6 +190,7 @@ export default {
.container {
padding-top: 20px;
border-radius: 10px;
}
.container .title {

View File

@ -125,7 +125,13 @@ export default {
this.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) {
this.rank = response.data.data
this.total = response.data.count
@ -139,14 +145,7 @@ export default {
})
},
goToSearch() {
if (this.keyword === "") {
ElMessage({
message: '请输入关键字',
type: 'warning',
})
} else {
//
}
this.getPage()
}
}
}

View File

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