drawtools绘制标注

master
fanluyan 1 year ago
parent fae68126a5
commit 817c2ecd18

28
.gitignore vendored

@ -1,11 +1,23 @@
# ---> Vue
# gitignore template for Vue.js projects
#
# Recommended template: Node.gitignore
.DS_Store
node_modules
/dist
# TODO: where does this rule come from?
docs/_book
# TODO: where does this rule come from?
test/
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -1,2 +1,24 @@
# draw-tools
# vuetemplate
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

8861
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,53 @@
{
"name": "drawtools",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.6.2",
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"moment": "^2.29.4",
"vue": "^2.6.14",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"less": "^4.0.0",
"less-loader": "^7.0.1",
"postcss-loader": "^4.3.0",
"vue-template-compiler": "^2.6.14"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

@ -0,0 +1,55 @@
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "App",
};
</script>
<style lang="less">
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
overflow: hidden;
color: #fff;
}
a {
text-decoration: none;
color: #fff;
}
#app {
width: 100%;
height: 100%;
}
body {
font-family: "PingFang SC", "Helvetica Neue", Helvetica, "microsoft yahei",
arial, STHeiTi, sans-serif;
}
/* 整个滚动条 */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
/* 滚动条上的滚动滑块 */
::-webkit-scrollbar-thumb {
background-color: #ccc;
/* 关键代码 */
border-radius: 32px;
}
/* 滚动条轨道 */
::-webkit-scrollbar-track {
background-color: #f0f0f0;
border-radius: 32px;
}
</style>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

@ -0,0 +1,32 @@
<template>
<div class="wrapper">
<div class="content-box">
<router-view></router-view>
</div>
</div>
</template>
<script>
export default {
data() {
return {};
},
components: {},
computed: {},
created() {},
};
</script>
<style lang="less">
.wrapper {
//min-width: 1366px;
color: #333;
height: 100%;
.content-box {
width: 100%;
height: 100%;
//padding: 10px;
overflow-y: auto;
box-sizing: border-box;
}
}
</style>

@ -0,0 +1,25 @@
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import ElementUI from "element-ui";
// import "element-ui/lib/theme-chalk/index.css";
import "../src/assets/css/theme/index.css"; //主题
Vue.use(ElementUI, {
size: "small",
});
//引入日期// 注册全局 moment
import moment from "moment";
Vue.prototype.$moment = moment;
//挂载弹出信息
import { message } from "@/utils/resetMessage";
Vue.prototype.$message = message;
Vue.config.productionTip = false;
new Vue({
router,
render: (h) => h(App),
}).$mount("#app");

@ -0,0 +1,31 @@
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
const routes = [
{
path: "/",
redirect: "/home",
component: () => import("../components/Home.vue"),
children: [
{
path: "/home",
component: () => import("../views/home/index.vue"),
name: "home",
meta: {
title: "首页",
keepAlive: true,
},
},
],
},
];
const router = new VueRouter({
mode: "hash",
base: process.env.BASE_URL,
routes,
});
export default router;

@ -0,0 +1,62 @@
import request from "../request";
//查询图片树
export function getTreeApi(data) {
return request({
url: "/labelimg/getTree",
method: "get",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}
//保存标注
export function saveLabelsApi(data) {
return request({
url: "/labelimg/saveLabels",
method: "post",
data,
});
}
//获取类型
export function getTypesApi(data) {
return request({
url: "/labelimg/getTypes",
method: "get",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}
//查询标注
export function getLabelsApi(data) {
return request({
url: "/labelimg/getLabels",
method: "get",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}
//删除标注和图片
export function deleteApi(data) {
return request({
url: "/labelimg/delete",
method: "post",
data,
});
}
// export function loginJoggle(data) {
// return request({
// url: "api/login.php",
// method: "post",
// data,
// });
// }
// //获取line

@ -0,0 +1,4 @@
import Vue from 'vue'
const EventBus = new Vue()
export default EventBus

@ -0,0 +1,79 @@
import axios from "axios";
import { MessageBox, Message } from "element-ui";
import router from "../router/index";
const service = axios.create({
// process.env.NODE_ENV === 'development' 来判断是否开发环境
// easy-mock服务挂了暂时不使用了
// baseURL: '',
// timeout: 5000
baseURL: "/img-api", //把原来的项目地址改成api解决跨域问题
timeout: 30000,
});
// 添加请求拦截器一下内容是axios的拦截器可以不用写
service.interceptors.request.use(
function (config) {
// 在发送请求之前做些什么
return config;
},
function (error) {
// 对请求错误做些什么
return Promise.reject(error);
}
);
// 添加响应拦截器
service.interceptors.response.use(
function (response) {
// 对响应数据做点什么
return response.data;
},
function (error) {
// 对响应错误做点什么
return Promise.reject(error);
}
);
export default service;
// service.interceptors.request.use((config) => {
// if (localStorage.getItem("token")) {
// config.headers.sessionId = localStorage.getItem("token");
// }
// return config;
// });
// service.interceptors.response.use(
// (response) => {
// const res = response.data;
// if (res.code !== 200) {
// if (res.code === 401) {
// Message({ message: res.msg, type: "error", duration: 1500 });
// router.push("/login");
// }
// if (res.code === 400) {
// Message({ message: res.msg, type: "error", duration: 1500 });
// }
// if (res.code === 500) {
// Message({
// showClose: true,
// message: 服务器错误(500),
// type: "error",
// duration: 1500,
// });
// }
// return Promise.reject(new Error(res.msg || "Error"));
// } else {
// return res;
// }
// },
// (error) => {
// Message({
// message: error.message,
// showClose: true,
// type: "error",
// duration: 1500,
// });
// return Promise.reject(error);
// }
// );

@ -0,0 +1,28 @@
//resetMessage.js
/**重置message防止重复点击重复弹出message消息提示 */
import { Message } from "element-ui";
let messageInstance = null;
const resetMessage = (options) => {
if (messageInstance) {
messageInstance.close();
}
Message.closeAll(); //手动关闭所有消息提示实例
messageInstance = Message(options);
// console.log(Message(options));
};
["error", "success", "info", "warning"].forEach((type) => {
resetMessage[type] = (options) => {
if (typeof options === "string") {
options = {
message: options,
};
}
options.type = type;
return resetMessage(options);
};
});
export const message = resetMessage;

@ -0,0 +1,596 @@
<template>
<div class="drawPicBox">
<h3>这里是绘制图片</h3>
<div class="picCanvans">
<div class="wrap">
<img
@load="onImageLoad"
:src="
'http://192.168.50.200:88/images/' +
this.parentdata.name +
'/' +
currentNodeData.name
"
alt=""
class="img"
ref="imgDiv"
/>
<canvas
class="canvas_dom"
id="canvasDom"
:width="imgWidth"
:height="imgHeight"
@mousemove="moveFunction"
@mousedown="downFunction"
@mouseup="upFunction"
@mouseout="outFunction"
@contextmenu="contextMenuFunction"
>
</canvas>
</div>
</div>
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
export default {
components: {},
data() {
return {
currentNodeData: "",
parentdata: "",
imgWidth: 0,
imgHeight: 0,
//
recArrs: [],
curObj: {
isRightClick: false, //
radious: 4, //
recSize: 5, //
index: -1, // index
side: 0, //
resize: false, //
draw: false, //
drag: false, //
x: 0, // x
y: 0, // y
startX: 0, // x
startY: 0, // y
},
canvasWidth: this.imgWidth,
canvasHeight: this.imgHeight,
};
},
created() {
EventBus.$on("currentNodeData", (value) => {
//console.log(value); // value
this.currentNodeData = value;
});
EventBus.$on("perentNode", (value) => {
//console.log(value); // value
this.parentdata = value;
});
},
mounted() {},
computed: {},
methods: {
//
onImageLoad(event) {
this.imgWidth = event.target.width;
this.imgHeight = event.target.height;
},
// //
// move(e) {
// e.preventDefault();
// //
// var left = document.querySelector(".wrap");
// var img = document.querySelector(".img");
// var x = e.pageX - img.offsetLeft;
// var y = e.pageY - img.offsetTop;
// //
// left.addEventListener("mousemove", move);
// function move(e) {
// img.style.left = e.pageX - x + "px";
// img.style.top = e.pageY - y + "px";
// }
// //
// img.addEventListener("mouseup", function () {
// left.removeEventListener("mousemove", move);
// });
// //
// left.addEventListener("mouseout", function () {
// left.removeEventListener("mousemove", move);
// });
// },
// //
// rollImg() {
// /* zoom100%1 */
// var zoom = parseInt(this.$refs.imgDiv.style.zoom) || 100;
// /* event.wheelDelta zoom wheelDelta±120 */
// zoom += event.wheelDelta / 12;
// /* */
// if (zoom >= 100 && zoom < 400) {
// this.$refs.imgDiv.style.zoom = zoom + "%";
// }
// return false;
// },
//
contextMenuFunction(e) {
e.preventDefault();
return false;
},
//
outFunction(e) {
let canvasDom = document.getElementById("canvasDom");
let x = e.clientX;
let y = e.clientY;
let left = canvasDom.offsetLeft;
let top = canvasDom.offsetTop;
let width = canvasDom.offsetWidth;
let height = canvasDom.offsetHeight;
let limitX = left + width;
let limitY = top + height;
if (x < left || x > limitX || y < top || y > limitY) {
console.log("鼠标移出范围, 清除canvas重新绘制");
this.clearCanvas();
this.drawOldRect();
}
},
//
moveFunction(e) {
// console.log('', e);
// 线
this.clearCanvas();
// 线
this.drawRuler(e);
// 线
this.drawOldRect();
//
this.drawRect(e);
//
this.moveOrScale(e);
},
// /
moveOrScale(e) {
let index = this.getEventIndex(e.offsetX, e.offsetY);
let side = 0;
if (index > -1) {
side = this.getEventArea(index, e.offsetX, e.offsetY);
//
if (side > 0) {
this.drawLitRecs(index);
}
}
//
this.changeResizeCursor(side);
//
this.moveRec(e);
//
this.reSizeRec(e);
},
//
moveRec(e) {
if (this.curObj.drag && this.recArrs[this.curObj.index]) {
let x = this.curObj.startX + e.offsetX - this.curObj.x;
let y = this.curObj.startY + e.offsetY - this.curObj.y;
let minX = canvasDom.offsetLeft;
let maxX =
canvasDom.offsetLeft +
canvasDom.offsetWidth -
this.recArrs[this.curObj.index].w;
let minY = canvasDom.offsetTop;
let maxY =
canvasDom.offsetTop +
canvasDom.offsetHeight -
this.recArrs[this.curObj.index].h;
if (x < minX) {
x = minX;
}
if (x > maxX) {
x = maxX;
}
if (y < minY) {
y = minY;
}
if (y > maxY) {
y = maxY;
}
this.recArrs[this.curObj.index].x = x;
this.recArrs[this.curObj.index].y = y;
}
},
//
reSizeRec(e) {
const { side, index, recSize } = this.curObj;
const rec = this.recArrs[index];
if (this.curObj.resize && rec) {
const temX = rec.x;
const temY = rec.y;
const ex = e.offsetX;
const ey = e.offsetY;
if (side < 4 && temX + rec.w - ex > recSize) {
rec.x = ex;
}
if (
(side == 1 || side == 4 || side == 7) &&
temY + rec.h - ey > recSize
) {
rec.y = ey;
}
if (side < 4) {
if (temX + rec.w - ex > recSize) {
rec.w = temX + rec.w - ex;
}
} else if (side < 7) {
if (ex - temX > recSize) {
rec.w = ex - temX;
}
}
if (side == 1 || side == 4 || side == 7) {
if (temY + rec.h - ey > recSize) {
rec.h = temY + rec.h - ey;
}
} else if (side == 3 || side == 6 || side == 8) {
if (ey - temY > recSize) {
rec.h = ey - temY;
}
}
}
},
// 线
drawRuler(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
//
ctx2d.beginPath();
//
ctx2d.fillStyle = "rgba(0,0,0,0.3)";
ctx2d.strokeStyle = "red";
//
ctx2d.lineWidth = 1;
// x y 0线
ctx2d.moveTo(e.offsetX, 0);
// lineTo() 线
ctx2d.lineTo(e.offsetX, this.canvasHeight);
// (x: 0, y)线
ctx2d.moveTo(0, e.offsetY);
// lineTo() 线
ctx2d.lineTo(this.canvasWidth, e.offsetY);
ctx2d.stroke();
},
// canvas
clearCanvas() {
let ctx2d = canvasDom.getContext("2d");
ctx2d.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
},
//
drawRect(e) {
let ctx2d = canvasDom.getContext("2d");
if (this.curObj.draw) {
ctx2d.fillRect(
this.curObj.x,
this.curObj.y,
e.offsetX - this.curObj.x,
e.offsetY - this.curObj.y
);
}
},
//
drawOldRect() {
let ctx2d = canvasDom.getContext("2d");
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
ctx2d.beginPath();
ctx2d.lineWidth = 2; // 线
ctx2d.fillStyle = "rgba(0,0,0,0.3)";
ctx2d.strokeStyle = "rgb(255, 0, 0)"; // 线
ctx2d.fillRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
//
if (this.recArrs[i].text) {
ctx2d.fillStyle = "purple";
ctx2d.font = "14px 微软雅黑";
ctx2d.lineWidth = 1;
ctx2d.fillStyle = "rgba(0,0,0,0.3)";
ctx2d.strokeStyle = "rgb(255,0,0)";
ctx2d.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
},
//
downFunction(e) {
console.log("鼠标按下", e); // e.button 0 1 2
this.curObj.isRightClick = e.button > 1;
console.log("是否右键", this.curObj.isRightClick);
// x,y
this.curObj.x = e.offsetX;
this.curObj.y = e.offsetY;
//
//
this.curObj.index = this.getEventIndex(this.curObj.x, this.curObj.y);
console.log("落点矩形", this.curObj.index);
// TODO...
if (this.curObj.isRightClick) {
} else {
//
//
if (this.curObj.index === -1) {
this.curObj.draw = true;
} else {
//
//
this.curObj.startX = this.recArrs[this.curObj.index].x;
this.curObj.startY = this.recArrs[this.curObj.index].y;
//
this.curObj.side = this.getEventArea(
this.curObj.index,
this.curObj.x,
this.curObj.y
);
console.log("this.curObj.side", this.curObj.side);
if (this.curObj.side < 9) {
//
console.log("在缩放");
this.curObj.resize = true;
} else {
//
console.log("在拖动");
this.curObj.drag = true;
}
//
this.drawLitRecs(this.curObj.index);
}
}
//
this.changeResizeCursor(this.curObj.side);
},
//
changeResizeCursor(side) {
let canvasDom = document.getElementById("canvasDom");
switch (side) {
case 0:
canvasDom.style.cursor = "crosshair";
break;
case 1:
canvasDom.style.cursor = "se-resize";
break;
case 2:
canvasDom.style.cursor = "e-resize";
break;
case 3:
canvasDom.style.cursor = "ne-resize";
break;
case 4:
canvasDom.style.cursor = "sw-resize";
break;
case 5:
canvasDom.style.cursor = "w-resize";
break;
case 6:
canvasDom.style.cursor = "nw-resize";
break;
case 7:
canvasDom.style.cursor = "s-resize";
break;
case 8:
canvasDom.style.cursor = "n-resize";
break;
case 9:
canvasDom.style.cursor = "move";
break;
default:
canvasDom.style.cursor = "default";
}
},
//
getEventArea(index, x, y) {
const { radious } = this.curObj;
const data = this.recArrs[index];
console.log("this.recArrs", this.recArrs);
console.log("data", data);
if (x > data.x - radious && x < data.x + radious) {
if (y > data.y - radious && y < data.y + radious) {
return 1;
} else if (y > data.y + radious && y < data.y + data.h - radious) {
return 2;
} else if (
y > data.y + data.h - radious &&
y < data.y + data.h + radious
) {
return 3;
}
} else if (
x > data.x + data.w - radious &&
x < data.x + data.w + radious
) {
if (y > data.y - radious && y < data.y + radious) {
return 4;
} else if (y > data.y + radious && y < data.y + data.h - radious) {
return 5;
} else if (
y > data.y + data.h - radious &&
y < data.y + data.h + radious
) {
return 6;
}
} else {
if (
y > data.y - radious &&
y < data.y + radious &&
x > data.x + radious &&
x < data.x + data.w - radious
) {
return 7;
} else if (
y > data.y + data.h - radious &&
y < data.y + data.h + radious &&
x > data.x + radious &&
x < data.x + data.w - radious
) {
return 8;
} else {
return 9;
}
}
},
//8332
prepareLitRecs(index) {
const data = this.recArrs[index];
var li = [];
li[0] = [data.x, data.y];
li[1] = [data.x, data.y + data.h / 2];
li[2] = [data.x, data.y + data.h];
li[3] = [data.x + data.w, data.y];
li[4] = [data.x + data.w, data.y + data.h / 2];
li[5] = [data.x + data.w, data.y + data.h];
li[6] = [data.x + data.w / 2, data.y];
li[7] = [data.x + data.w / 2, data.y + data.h];
return li;
},
//,data9
drawLitRecs(index) {
let ctx2d = canvasDom.getContext("2d");
const data = this.prepareLitRecs(index);
const { recSize } = this.curObj;
for (var i = 0; i < data.length; i++) {
ctx2d.fillRect(
data[i][0] - recSize / 2,
data[i][1] - recSize / 2,
recSize,
recSize
);
}
},
// index, -1
getEventIndex(x, y) {
if (!this.recArrs.length) return -1;
for (var i = 0; i < this.recArrs.length; i++) {
const limitX = x > this.recArrs[i].x - this.curObj.radious;
const limitW =
x < this.recArrs[i].x + this.recArrs[i].w + this.curObj.radious;
const limitY = y > this.recArrs[i].y - this.curObj.radious;
const limitH =
y < this.recArrs[i].y + this.recArrs[i].h + this.curObj.radious;
// index
if (limitX && limitY && limitW && limitH) {
return i;
}
// -1
if (i == this.recArrs.length - 1) {
return -1;
}
}
},
//
upFunction(e) {
console.log("鼠标抬起", e);
if (this.curObj.isRightClick) {
if (this.curObj.index !== -1) {
//
this.recArrs.splice(this.curObj.index, 1);
this.clearCanvas();
this.drawOldRect();
}
this.curObj.isRightClick = false;
return;
}
this.curObj.resize = false;
this.curObj.drag = false;
//
if (this.curObj.draw) {
this.addToRecs(e);
this.curObj.draw = false;
}
console.log("鼠标抬起-当前矩形框", this.recArrs);
},
//
addToRecs(e) {
let rec = {
x: this.curObj.x > e.offsetX ? e.offsetX : this.curObj.x, // x
y: this.curObj.y > e.offsetY ? e.offsetY : this.curObj.y, // y
w: Math.abs(e.offsetX - this.curObj.x), //
h: Math.abs(e.offsetY - this.curObj.y), //
text: "矩形框" + this.recArrs.length, //
type: 1, //
// ...
};
//
if (rec.w > 2 && rec.h > 2) {
this.recArrs.push(rec);
console.log("recArrs", this.recArrs);
}
},
},
};
</script>
<style lang="less">
.drawPicBox {
width: 100%;
height: 100%;
h3 {
margin-bottom: 16px;
}
.picCanvans {
width: 100%;
height: calc(100% - 42px);
overflow: hidden;
.wrap {
width: 100%;
height: 100%;
position: relative;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
border: 1px solid #dcdfe6;
background: rgba(0, 0, 0, 0.3);
img {
position: absolute;
max-width: auto;
max-height: 800px;
cursor: move;
}
.canvas_dom {
//background-color: rgba(255, 0, 0, 0.2);
cursor: crosshair;
position: absolute;
}
}
}
}
</style>

@ -0,0 +1,851 @@
<template>
<div class="drawPicBox">
<div class="pointBox">
<h3>
标注数据
<el-button
type="danger"
icon="el-icon-delete"
@click="deletePic"
></el-button>
<el-button type="primary" @click="savePointer"></el-button>
</h3>
<div class="picRow">
<p v-for="(item, index) in recArrs" :key="index">
<span
>{{ item.text }}
<el-select
size="mini"
v-model="item.type"
placeholder="请选择标注名称"
>
<el-option
v-for="(label, value, index) in markOptions"
:key="value"
:label="label"
:value="index"
>
</el-option>
</el-select>
</span>
</p>
<!-- <span>图片的宽{{ imgWidth }}px</span>
<span>图片的高{{ imgHeight }}px</span>
<span>{{ (item.w / imgWidth).toFixed(2) }}</span>
<span>{{ (item.h / imgHeight).toFixed(2) }}</span>
<span>X{{ ((item.x + item.w) / 2 / imgWidth).toFixed(2) }}</span>
<span>Y{{ ((item.y + item.h) / 2 / imgHeight).toFixed(2) }}</span> -->
</div>
</div>
<div class="picCanvans">
<div class="wrap">
<img
@load="onImageLoad"
:src="
'http://192.168.50.200:88/images/' +
parentdata.name +
'/' +
currentNodeData.name
"
alt=""
class="img"
ref="imgDiv"
/>
<canvas
class="canvas_dom"
id="canvasDom"
:width="imgWidth"
:height="imgHeight"
@mousemove="moveFunction"
@mousedown="downFunction"
@mouseup="upFunction"
@mouseout="outFunction"
@contextmenu="contextMenuFunction"
>
</canvas>
</div>
</div>
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
import { getTypesApi, saveLabelsApi, deleteApi } from "@/utils/api/index";
export default {
components: {},
data() {
return {
markOptions: {}, //
currentNodeData: "",
parentdata: "",
imgWidth: 0,
imgHeight: 0,
typeMap: {
0: "挖掘机",
1: "塔吊",
2: "吊车",
3: "水泥泵车",
4: "山火",
5: "烟雾",
},
//
recArrs: [],
curObj: {
isRightClick: false, //
radious: 4, //
recSize: 5, //
index: -1, // index
side: 0, //
resize: false, //
draw: false, //
drag: false, //
x: 0, // x
y: 0, // y
startX: 0, // x
startY: 0, // y
centerX: 0, //x
centerY: 0, //y
},
//
labelMarkArrs: [],
};
},
created() {
EventBus.$on("currentNodeData", (value) => {
//console.log(value); // value
this.currentNodeData = value;
});
EventBus.$on("perentNode", (value) => {
//console.log(value); // value
this.parentdata = value;
});
EventBus.$on("labelMark", (value) => {
//console.log(value); // value
this.labelMarkArrs = value;
console.log(this.labelMarkArrs);
this.clearCanvas();
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].centerX * this.imgWidth -
(this.labelMarkArrs[i].width * this.imgWidth) / 2,
y:
this.labelMarkArrs[i].centerY * this.imgHeight -
(this.labelMarkArrs[i].height * this.imgHeight) / 2,
w: this.labelMarkArrs[i].width * this.imgWidth,
h: this.labelMarkArrs[i].height * this.imgHeight,
text: this.typeMap[this.labelMarkArrs[i].type],
type: this.labelMarkArrs[i].type,
});
}
console.log("aaaaaaaaaaaaaaaaa");
console.log(this.recArrs);
this.drawOldRect();
});
},
mounted() {
this.$nextTick(() => {
window.addEventListener("resize", this.updateImageSize);
});
this.getTypes();
},
beforeDestroy() {
window.removeEventListener("resize", this.updateImageSize);
},
computed: {},
methods: {
getTypes() {
getTypesApi()
.then((res) => {
console.log(res);
this.markOptions = res.data;
})
.catch((err) => {});
},
//
onImageLoad() {
this.updateImageSize();
},
updateImageSize() {
const img = this.$refs.imgDiv;
this.imgWidth = img.offsetWidth;
this.imgHeight = img.offsetHeight;
console.log(this.imgWidth, this.imgHeight);
this.clearCanvas();
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].centerX * this.imgWidth -
(this.labelMarkArrs[i].width * this.imgWidth) / 2,
y:
this.labelMarkArrs[i].centerY * this.imgHeight -
(this.labelMarkArrs[i].height * this.imgHeight) / 2,
w: this.labelMarkArrs[i].width * this.imgWidth,
h: this.labelMarkArrs[i].height * this.imgHeight,
text: this.typeMap[this.labelMarkArrs[i].type],
type: this.labelMarkArrs[i].type,
});
}
console.log("aaaaaaaaaaaaaaaaa");
console.log(this.recArrs);
this.drawOldRect();
},
// //
// move(e) {
// e.preventDefault();
// //
// var left = document.querySelector(".wrap");
// var img = document.querySelector(".img");
// var x = e.pageX - img.offsetLeft;
// var y = e.pageY - img.offsetTop;
// //
// left.addEventListener("mousemove", move);
// function move(e) {
// img.style.left = e.pageX - x + "px";
// img.style.top = e.pageY - y + "px";
// }
// //
// img.addEventListener("mouseup", function () {
// left.removeEventListener("mousemove", move);
// });
// //
// left.addEventListener("mouseout", function () {
// left.removeEventListener("mousemove", move);
// });
// },
// //
// rollImg() {
// /* zoom100%1 */
// var zoom = parseInt(this.$refs.imgDiv.style.zoom) || 100;
// /* event.wheelDelta zoom wheelDelta±120 */
// zoom += event.wheelDelta / 12;
// /* */
// if (zoom >= 100 && zoom < 400) {
// this.$refs.imgDiv.style.zoom = zoom + "%";
// }
// return false;
// },
//
contextMenuFunction(e) {
e.preventDefault();
return false;
},
//
moveFunction(e) {
// console.log('', e);
// 线
this.clearCanvas();
// 线
this.drawRuler(e);
// // 线
this.drawOldRect();
//
this.drawRect(e);
// //
this.moveOrScale(e);
},
// /
moveOrScale(e) {
let index = this.getEventIndex(e.offsetX, e.offsetY);
let side = 0;
if (index > -1) {
side = this.getEventArea(index, e.offsetX, e.offsetY);
//
if (side > 0) {
this.drawLitRecs(index);
}
}
//
this.changeResizeCursor(side);
//
this.moveRec(e);
//
this.reSizeRec(e);
},
//
moveRec(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
if (this.curObj.drag && this.recArrs[this.curObj.index]) {
let x = this.curObj.startX + e.offsetX - this.curObj.x;
let y = this.curObj.startY + e.offsetY - this.curObj.y;
let minX = canvasDom.offsetLeft;
let maxX =
canvasDom.offsetLeft +
canvasDom.offsetWidth -
this.recArrs[this.curObj.index].w;
let minY = canvasDom.offsetTop;
let maxY =
canvasDom.offsetTop +
canvasDom.offsetHeight -
this.recArrs[this.curObj.index].h;
if (x < minX) {
x = minX;
}
if (x > maxX) {
x = maxX;
}
if (y < minY) {
y = minY;
}
if (y > maxY) {
y = maxY;
}
this.recArrs[this.curObj.index].x = x;
this.recArrs[this.curObj.index].y = y;
}
},
//
reSizeRec(e) {
const { side, index, recSize } = this.curObj;
const rec = this.recArrs[index];
if (this.curObj.resize && rec) {
const temX = rec.x;
const temY = rec.y;
const ex = e.offsetX;
const ey = e.offsetY;
if (side < 4 && temX + rec.w - ex > recSize) {
rec.x = ex;
}
if (
(side == 1 || side == 4 || side == 7) &&
temY + rec.h - ey > recSize
) {
rec.y = ey;
}
if (side < 4) {
if (temX + rec.w - ex > recSize) {
rec.w = temX + rec.w - ex;
}
} else if (side < 7) {
if (ex - temX > recSize) {
rec.w = ex - temX;
}
}
if (side == 1 || side == 4 || side == 7) {
if (temY + rec.h - ey > recSize) {
rec.h = temY + rec.h - ey;
}
} else if (side == 3 || side == 6 || side == 8) {
if (ey - temY > recSize) {
rec.h = ey - temY;
}
}
}
},
//
outFunction(e) {
let canvasDom = document.getElementById("canvasDom");
let x = e.clientX;
let y = e.clientY;
let left = canvasDom.offsetLeft;
let top = canvasDom.offsetTop;
let width = canvasDom.offsetWidth;
let height = canvasDom.offsetHeight;
let limitX = left + width;
let limitY = top + height;
if (x < left || x > limitX || y < top || y > limitY) {
console.log("鼠标移出范围, 清除canvas重新绘制");
this.clearCanvas();
this.drawOldRect();
}
},
// 线
drawRuler(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.offsetWidth;
const canvasWidth = canvasDom.offsetWidth;
//console.log(canvasDom);
//
ctx2d.beginPath();
//
ctx2d.strokeStyle = "red";
//
ctx2d.lineWidth = 1;
// x y 0线
ctx2d.moveTo(e.offsetX, 0);
// lineTo() 线
ctx2d.lineTo(e.offsetX, canvasHeight);
// (x: 0, y)线
ctx2d.moveTo(0, e.offsetY);
// lineTo() 线
ctx2d.lineTo(canvasWidth, e.offsetY);
ctx2d.stroke();
},
// canvas
clearCanvas() {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.width;
const canvasWidth = canvasDom.height;
ctx2d.clearRect(0, 0, canvasHeight, canvasWidth);
},
//
drawRect(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
if (this.curObj.draw) {
ctx2d.strokeRect(
this.curObj.x,
this.curObj.y,
e.offsetX - this.curObj.x,
e.offsetY - this.curObj.y
);
}
},
//
drawOldRect() {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.width;
const canvasWidth = canvasDom.height;
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
ctx2d.beginPath();
ctx2d.lineWidth = 2; // 线
ctx2d.strokeStyle = "rgb(255, 0, 0)"; // 线
//
ctx2d.fillStyle = "rgba(22, 158, 140, 0.4)"; //
ctx2d.strokeRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
ctx2d.fillRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
//
if (this.recArrs[i].text) {
ctx2d.font = "100 18px 微软雅黑";
ctx2d.lineWidth = 1;
ctx2d.strokeStyle = "rgb(255,0,0)";
ctx2d.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
},
writeMarkHandle() {
this.dialogFormVisible = false;
this.drawRect();
},
//
downFunction(e) {
console.log("鼠标按下", e); // e.button 0 1 2
this.curObj.isRightClick = e.button > 1;
console.log("是否右键", this.curObj.isRightClick);
// x,y
this.curObj.x = e.offsetX;
this.curObj.y = e.offsetY;
//
//
this.curObj.index = this.getEventIndex(this.curObj.x, this.curObj.y);
console.log("落点矩形", this.curObj.index);
// TODO...
if (this.curObj.isRightClick) {
} else {
//
//
if (this.curObj.index === -1) {
this.curObj.draw = true;
} else {
//
//
this.curObj.startX = this.recArrs[this.curObj.index].x;
this.curObj.startY = this.recArrs[this.curObj.index].y;
//
this.curObj.side = this.getEventArea(
this.curObj.index,
this.curObj.x,
this.curObj.y
);
console.log("this.curObj.side", this.curObj.side);
if (this.curObj.side < 9) {
//
console.log("在缩放");
this.curObj.resize = true;
} else {
//
console.log("在拖动");
this.curObj.drag = true;
}
//
this.drawLitRecs(this.curObj.index);
}
}
//
this.changeResizeCursor(this.curObj.side);
},
//,data9
drawLitRecs(index) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const data = this.prepareLitRecs(index);
const { recSize } = this.curObj;
for (var i = 0; i < data.length; i++) {
ctx2d.strokeRect(
data[i][0] - recSize / 2,
data[i][1] - recSize / 2,
recSize,
recSize
);
}
},
//8332
prepareLitRecs(index) {
const data = this.recArrs[index];
var li = [];
li[0] = [data.x, data.y];
li[1] = [data.x, data.y + data.h / 2];
li[2] = [data.x, data.y + data.h];
li[3] = [data.x + data.w, data.y];
li[4] = [data.x + data.w, data.y + data.h / 2];
li[5] = [data.x + data.w, data.y + data.h];
li[6] = [data.x + data.w / 2, data.y];
li[7] = [data.x + data.w / 2, data.y + data.h];
return li;
},
//
changeResizeCursor(side) {
let canvasDom = document.getElementById("canvasDom");
switch (side) {
case 0:
canvasDom.style.cursor = "crosshair";
break;
case 1:
canvasDom.style.cursor = "se-resize";
break;
case 2:
canvasDom.style.cursor = "e-resize";
break;
case 3:
canvasDom.style.cursor = "ne-resize";
break;
case 4:
canvasDom.style.cursor = "sw-resize";
break;
case 5:
canvasDom.style.cursor = "w-resize";
break;
case 6:
canvasDom.style.cursor = "nw-resize";
break;
case 7:
canvasDom.style.cursor = "s-resize";
break;
case 8:
canvasDom.style.cursor = "n-resize";
break;
case 9:
canvasDom.style.cursor = "move";
break;
default:
canvasDom.style.cursor = "default";
}
},
//
getEventArea(index, x, y) {
const data = this.recArrs[index];
// console.log("this.recArrs", this.recArrs);
// console.log("data", data);
if (
x > data.x - this.curObj.radious &&
x < data.x + this.curObj.radious
) {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious
) {
return 1;
} else if (
y > data.y + this.curObj.radious &&
y < data.y + data.h - this.curObj.radious
) {
return 2;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious
) {
return 3;
}
} else if (
x > data.x + data.w - this.curObj.radious &&
x < data.x + data.w + this.curObj.radious
) {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious
) {
return 4;
} else if (
y > data.y + this.curObj.radious &&
y < data.y + data.h - this.curObj.radious
) {
return 5;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious
) {
return 6;
}
} else {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious &&
x > data.x + this.curObj.radious &&
x < data.x + data.w - this.curObj.radious
) {
return 7;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious &&
x > data.x + this.curObj.radious &&
x < data.x + data.w - this.curObj.radious
) {
return 8;
} else {
return 9;
}
}
},
// index, -1
getEventIndex(x, y) {
if (!this.recArrs.length) return -1;
for (var i = 0; i < this.recArrs.length; i++) {
const limitX = x > this.recArrs[i].x - this.curObj.radious;
const limitW =
x < this.recArrs[i].x + this.recArrs[i].w + this.curObj.radious;
const limitY = y > this.recArrs[i].y - this.curObj.radious;
const limitH =
y < this.recArrs[i].y + this.recArrs[i].h + this.curObj.radious;
// index
if (limitX && limitY && limitW && limitH) {
return i;
}
// -1
if (i == this.recArrs.length - 1) {
return -1;
}
}
},
//
upFunction(e) {
console.log("鼠标抬起", e);
if (this.curObj.isRightClick) {
if (this.curObj.index !== -1) {
//
this.recArrs.splice(this.curObj.index, 1);
this.clearCanvas();
this.drawOldRect();
}
this.curObj.isRightClick = false;
return;
}
this.curObj.resize = false;
this.curObj.drag = false;
//
if (this.curObj.draw) {
this.addToRecs(e);
this.curObj.draw = false;
}
console.log("鼠标抬起-当前矩形框", this.recArrs);
},
//
addToRecs(e) {
let rec = {
x: this.curObj.x > e.offsetX ? e.offsetX : this.curObj.x, // x
y: this.curObj.y > e.offsetY ? e.offsetY : this.curObj.y, // y
w: Math.abs(e.offsetX - this.curObj.x), //
h: Math.abs(e.offsetY - this.curObj.y), //
text: "矩形框" + this.recArrs.length, //
type: 0, //
// ...
};
//
if (rec.w > 2 && rec.h > 2) {
this.recArrs.push(rec);
console.log("recArrs", this.recArrs);
}
},
//
savePointer() {
let params = {
labels: [],
path: this.parentdata.name + "/" + this.currentNodeData.name,
};
for (var i = 0; i < this.recArrs.length; i++) {
params.labels.push({
centerX: (this.recArrs[i].x + this.recArrs[i].w / 2) / this.imgWidth,
centerY: (this.recArrs[i].y + this.recArrs[i].h / 2) / this.imgHeight,
width: this.recArrs[i].w / this.imgWidth,
height: this.recArrs[i].h / this.imgHeight,
type: this.recArrs[i].type,
});
}
console.log(params);
saveLabelsApi(params)
.then((res) => {
console.log(res);
if (res.success) {
this.$message({
showClose: true,
duration: 1500,
message: res.data,
type: "success",
});
EventBus.$emit("treeHandleNode", this.currentNodeData);
EventBus.$emit("treelist");
this.recArrs = [];
this.clearCanvas();
this.drawOldRect();
} else {
this.$message({
showClose: true,
duration: 1500,
message: "保存失败",
type: "error",
});
}
})
.catch((err) => {});
},
//
deletePic() {
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
deleteApi({
path: this.parentdata.name + "/" + this.currentNodeData.name,
})
.then((res) => {
console.log(res);
this.$message({
type: "success",
message: "删除成功!",
});
EventBus.$emit("treelist");
localStorage.removeItem("currentData");
})
.catch((err) => {});
})
.catch(() => {});
},
},
};
</script>
<style lang="less">
.drawPicBox {
width: 100%;
height: 100%;
position: relative;
.pointBox {
//background: #fcc;
right: 14px;
border-radius: 4px;
//border: 1px solid #dcdfe6;
z-index: 22;
margin-bottom: 12px;
h3 {
margin-bottom: 12px;
font-size: 14px;
line-height: 24px;
align-items: center;
display: flex;
.el-button--danger {
padding: 4px 8px;
margin-left: 14px;
}
}
.picRow {
display: flex;
align-items: center;
//height: 32px;
p {
line-height: 32px;
// height: 32px;
margin-bottom: 8px;
font-size: 14px;
margin-right: 12px;
span {
margin-right: 8px;
}
}
.el-select {
width: 140px;
.el-input--suffix .el-input__inner {
padding-right: 12px;
}
}
}
}
.picCanvans {
width: 100%;
height: calc(100% - 142px);
overflow: hidden;
h3 {
margin-bottom: 12px;
font-size: 14px;
}
.wrap {
width: 100%;
height: 100%;
position: relative;
//border: 1px solid #dcdfe6;
// background: rgba(0, 0, 0, 0.3);
img {
position: absolute;
max-width: 100%;
max-height: 800px;
cursor: move;
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}
.canvas_dom {
position: absolute;
}
}
}
}
</style>

@ -0,0 +1,198 @@
<template>
<div class="picTree">
<el-tree
ref="tree"
:data="piclist"
:props="defaultProps"
node-key="name"
accordion
:default-expanded-keys="defaultExpandedKeys"
highlight-current
:current-node-key="currentNodekey"
:expand-on-click-node="true"
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="node.level === 1">
<span>{{ node.label }}</span>
</span>
<span v-else-if="node.level === 2">
<i v-if="data.marked" class="el-icon-s-flag"></i>
<span>{{ node.label }}</span>
</span>
</span>
</el-tree>
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
import { getTreeApi, getLabelsApi } from "@/utils/api/index";
export default {
components: {},
props: [],
data() {
return {
piclist: [],
currentNodeData: [], //
defaultExpandedKeys: [],
currentNodekey: "", //
defaultProps: {
children: "children",
label: "name",
},
pathParams: "",
labelsPoint: "",
};
},
computed: {},
created() {
EventBus.$on("treeHandleNode", this.handleNodeClick);
EventBus.$on("treelist", this.getTreeList);
},
mounted() {
this.getTreeList();
},
methods: {
//linelist 线
getTreeList() {
getTreeApi()
.then((res) => {
console.log(res);
this.piclist = res.data;
console.log(this.piclist);
console.log(this.defaultExpandedKeys);
console.log(this.currentNodekey);
//this.currentNodeData = this.piclist[0].children[0];
this.currentNodeData = JSON.parse(
localStorage.getItem("currentData")
);
console.log(this.currentNodeData);
if (
this.currentNodeData !== null &&
Object.keys(this.currentNodeData).length !== 0
) {
this.currentNodekey = this.currentNodeData.name;
//this.defaultExpandedKeys = [this.piclist[0].name];
console.log("aaaaaaaaaaaaaaaaa");
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodekey); //
this.handleNodeClick(this.currentNodeData);
this.scrollView();
});
} else {
console.log("bbbbbbbbbbbbbbbbbbbbb");
this.defaultExpandedKeys = [this.piclist[0].name];
this.currentNodekey = this.piclist[0].children[0].name;
this.currentNodeData = this.piclist[0].children[0];
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodekey); //
this.handleNodeClick(this.currentNodeData);
this.scrollView();
});
}
})
.catch((err) => {});
},
handleNodeClick(node) {
//
if (node.children?.length) {
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodeKey);
});
return;
}
this.currentNodeKey = node.name;
console.log(node); //
const parentNode = this.$refs.tree.getNode(node).parent.data;
console.log(parentNode); //
EventBus.$emit("currentNodeData", node);
EventBus.$emit("perentNode", parentNode);
this.defaultExpandedKeys = [parentNode.name];
this.pathParams = parentNode.name + "/" + node.name;
console.log(this.pathParams);
this.getlabels();
localStorage.setItem("currentData", JSON.stringify(node));
},
getlabels() {
getLabelsApi({
path: this.pathParams,
})
.then((res) => {
console.log(res);
this.labelsPoint = res.data;
EventBus.$emit("labelMark", this.labelsPoint);
})
.catch((err) => {});
},
scrollView() {
if (this.currentNodeData) {
this.$nextTick(() => {
let treeComponent = this.$refs.tree.$el;
let node = treeComponent.querySelector(".is-current");
console.log(node);
if (node) {
node.scrollIntoView({ behavior: "smooth" });
}
});
}
},
},
beforeDestroy() {
//
EventBus.$off("treeHandleNode", this.handleNodeClick);
},
};
</script>
<style lang="less">
.picTree {
width: 300px;
padding: 10px;
border: 1px solid #dcdfe6;
border-radius: 4px;
.el-tree {
overflow-y: auto;
height: calc(100% - 0px);
.el-tree-node__content {
height: 32px;
font-size: 14px;
position: relative;
}
.custom-tree-node {
color: #333;
overflow: hidden;
span {
display: flex;
display: inline-table;
overflow: hidden;
align-items: center;
}
}
}
.el-tree--highlight-current
.el-tree-node.is-current
> .el-tree-node__content {
//
color: #fff;
background: #169e8c;
.custom-tree-node {
color: #fff;
//overflow: hidden;
span {
display: flex;
//overflow: hidden;
align-items: center;
}
}
}
.el-icon-s-flag {
position: absolute;
left: 18px;
top: 10px;
}
}
</style>

@ -0,0 +1,42 @@
<template>
<div class="drawBox">
<picTree ref="pictree"></picTree>
<div class="picContain">
<drawpic></drawpic>
</div>
</div>
</template>
<script>
import picTree from "./components/picTree";
import drawpic from "./components/drawpic";
export default {
components: {
picTree,
drawpic,
},
data() {
return {};
},
created() {},
mounted() {},
computed: {},
methods: {},
};
</script>
<style lang="less">
.drawBox {
width: calc(100% - 20px);
height: calc(100% - 20px);
//background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
display: flex;
.picContain {
min-width: 0;
flex: 1;
border: 1px solid #dcdfe6;
border-radius: 4px;
padding: 10px;
}
}
</style>

@ -0,0 +1,31 @@
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
//打包清除console
chainWebpack(config) {
config.optimization.minimizer("terser").tap((args) => {
args[0].terserOptions.compress.drop_console = true;
return args;
});
},
productionSourceMap: false, // 生产环境是否要生成 sourceMap
publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : "./", // 部署应用包时的基本 URL
// assetsPublicPath: process.env.NODE_ENV === "production" ? "" : "/",
outputDir: "dist", // 打包时输出的文件目录
assetsDir: "static", // 放置静态文件夹目录
transpileDependencies: true,
lintOnSave: false,
devServer: {
port: 8888, // 端口号的配置
proxy: {
"/img-api": {
//表示拦截以/api开头的请求路径
target: "http://192.168.50.200:88", //
changOrigin: true, //是否开启跨域
pathRewrite: {
"^/api": "/img-api", //重写api把api变成空字符因为我们真正请求的路径是没有api的
},
},
},
},
});
Loading…
Cancel
Save