完成java的nicad代码重复度检测

This commit is contained in:
p71924506 2022-07-20 18:50:33 +08:00
parent 7b43e448e6
commit d86dbc6f30
7 changed files with 254 additions and 34 deletions

View File

@ -8,3 +8,10 @@ export const fetchData = query => {
});
};
export const nicadCheckDo = (data) => {
return request({
url: '/api/nicad/check',
method: 'post',
data:data
});
};

View File

@ -1,31 +1,35 @@
.header{
background-color: #0037af;
}
.login-wrap{
background: #d5d5d5;
}
.plugins-tips{
background: #eef1f6;
}
.plugins-tips a{
color: #20a0ff;
}
.el-upload--text em {
color: #20a0ff;
}
.pure-button{
background: #20a0ff;
}
.tags-li.active {
border: 1px solid #409EFF;
background-color: #409EFF;
}
.message-title{
color: #20a0ff;
}
.collapse-btn:hover{
background: #124dcb;
.header{
background-color: #0037af;
}
.login-wrap{
background: #d5d5d5;
}
.plugins-tips{
background: #eef1f6;
}
.plugins-tips-success{
background: #c9ffca;
}
.plugins-tips a{
color: #20a0ff;
}
.el-upload--text em {
color: #20a0ff;
}
.pure-button{
background: #20a0ff;
}
.tags-li.active {
border: 1px solid #409EFF;
background-color: #409EFF;
}
.message-title{
color: #20a0ff;
}
.collapse-btn:hover{
background: #124dcb;
}

View File

@ -69,6 +69,10 @@ a {
padding: 20px 10px;
margin-bottom: 20px;
}
.plugins-tips-success{
padding: 20px 10px;
margin-bottom: 20px;
}
.el-button+.el-tooltip {
margin-left: 10px;

View File

@ -10,9 +10,22 @@
</div>
<div class="container">
<div class="content-title">Nicad代码重复度检测工具</div>
<div class="plugins-tips">
<div class="plugins-tips" v-if="!checkStatus">
请您上传您的代码并选择语言类型进行检测
</div>
<div class="plugins-tips-success" v-else>
检测成功<b @click="openDialog" style="cursor: pointer">点击查看</b>您的检测报告
</div>
<el-dialog
v-model="dialogVisible"
title="检测报告"
width="80%"
>
<iframe :src="reportHtml" style="width: 100%; height: 800px">
</iframe>
</el-dialog>
<el-select v-model="value" placeholder="请选择项目语言" style="margin-bottom: 15px">
<el-option
v-for="item in options"
@ -51,6 +64,7 @@ import VueCropper from "vue-cropperjs";
import "cropperjs/dist/cropper.css";
import { ElMessage } from 'element-plus'
import defaultSrc from "../assets/img/img.jpg";
import { nicadCheckDo} from "../api";
export default {
name: "upload",
@ -88,6 +102,21 @@ export default {
//
if (uploadStatus.value == true) {
//
var nicadInfo = {
fileName : fileName.value,
language : value.value
}
nicadCheckDo(nicadInfo).then((res)=>{
console.log(res)
if (res.status == 0) {
//
//
ElMessage.success("检测成功")
checkStatus.value = true
reportHtml.value = res.html
}
})
}
}else {
//
@ -105,7 +134,6 @@ export default {
ElMessage.success("上传成功")
uploadStatus.value = true
fileName.value = response.fileName
}else {
ElMessage.error("上传失败")
}
@ -118,6 +146,16 @@ export default {
const uploadStatus = ref(false)
//
const fileName = ref('')
const checkStatus = ref(false)
const reportHtml = ref('')
const dialogVisible = ref(false)
function openDialog(){
dialogVisible.value = true
}
return {
//
@ -130,7 +168,12 @@ export default {
fileData,
uploadSuccess,
uploadStatus,
fileName
fileName,
//
checkStatus,
reportHtml,
dialogVisible,
openDialog
};
},
};

154
src/page/nicadResult.vue Normal file
View File

@ -0,0 +1,154 @@
<template>
<div>
<div class="crumbs">
<el-breadcrumb separator="/">
<el-breadcrumb-item>
<i class="el-icon-files"></i> Nicad代码重复度检测工具
</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="container">
<div class="content-title">Nicad检测结果</div>
<div>
<el-tag class="mx-1" size="large">检测ID: 11111111</el-tag>
<!-- <el-tag class="mx-1" size="large">克隆对数: 69</el-tag>-->
<el-tag class="mx-1" size="large" style="margin-left: 10px">克隆次数: 7</el-tag>
</div>
<div>
<!-- <el-card class="box-card" style="margin-top: 26px; width: 100%">-->
<!-- <template #header>-->
<!-- <div class="card-header">-->
<!-- <span>Class 1: 5 fragments, nominal size 12 lines, similarity 77%</span>-->
<!--&lt;!&ndash; <el-button class="button" text>Operation button</el-button>&ndash;&gt;-->
<!-- </div>-->
<!-- </template>-->
<!-- <div >-->
<!-- <div class="card">-->
<!-- <div class="code-title">osredm/osredmcompbackend/controller/UserController.java: 36-46</div>-->
<!-- <div class="code-content">{{code}}</div>-->
<!-- </div>-->
<!-- <div class="card">22</div>-->
<!-- </div>-->
<!-- </el-card>-->
<iframe style="width: 100%;height: 100vh" src="/api/files/1658305620421_functions-blind-clones/1658305620421_functions-blind-clones-0.30-classes-withsource.html">
</iframe>
</div>
</div>
</div>
</template>
<script>
import {reactive, ref} from "vue";
import VueCropper from "vue-cropperjs";
import "cropperjs/dist/cropper.css";
import { ElMessage } from 'element-plus'
import defaultSrc from "../assets/img/img.jpg";
export default {
name: "upload",
components: {
VueCropper,
},
setup() {
const code = ref('private HashMap<String,Object getUserRoleByToken(String token){ HashMap<String Object> map = new HashMap<>( String userRole = userService.getUserRole(token); if (userRole != null) { map.put(\\"status\\",SUCCESS); map.put(\\"data\\",userRole); }else { map.put(\\"status\\", FAIL); } return map; }",\n')
return {
code
};
},
};
</script>
<style scoped>
.code-title{
margin: 15px;
}
/* 卡片内容 */
.card {
display:inline-block;
border-radius: 10px;
margin: 0 10px;
min-height: 200px;
width: 400px;
background-color: #ecf5ff;
}
:deep .el-upload-dragger {
width: 100%;
}
:deep .el-upload--text {
width: 100%;
}
.content-title {
font-weight: 400;
line-height: 50px;
margin: 10px 0;
font-size: 22px;
color: #1f2f3d;
}
.pre-img {
width: 100px;
height: 100px;
background: #f8f8f8;
border: 1px solid #eee;
border-radius: 5px;
}
.crop-demo {
display: flex;
align-items: flex-end;
}
.crop-demo-btn {
position: relative;
width: 100px;
height: 40px;
line-height: 40px;
padding: 0 20px;
margin-left: 30px;
background-color: #409eff;
color: #fff;
font-size: 14px;
border-radius: 4px;
box-sizing: border-box;
}
.crop-input {
position: absolute;
width: 100px;
height: 40px;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
.box-card {
width: 480px;
}
</style>

View File

@ -10,6 +10,14 @@ const routes = [
name: "Home",
component: Home,
children: [
{
path: "/nicadResult",
name: "nicadResult",
meta: {
title: 'Nicad检测结果'
},
component: () => import ( /* webpackChunkName: "dashboard" */ "../page/nicadResult.vue")
},
{
path: "/nicad",
name: "nicad",

View File

@ -9,7 +9,7 @@ export default {
server:{
proxy: {
'/api': {
target: 'http://localhost:8011',
target: 'http://114.116.228.69:8011',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
// rewrite: (path) => path.replace(/^/api, '')