From 71435a451ab6fdcbb7e3f61604c35443e965770b Mon Sep 17 00:00:00 2001
From: maxmon <541182180@qq.com>
Date: Thu, 7 Apr 2022 20:58:51 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=94=A8=E6=89=8B?=
=?UTF-8?q?=E6=9C=BA=E6=A0=87=E6=B3=A8ner?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
fe/README.md | 2 +-
fe/config/index.js | 2 +-
fe/dist/index.html | 2 +-
fe/index.html | 7 +++-
fe/src/components/NER/index.vue | 70 +++++++++++++++++++++++++++++---
fe/src/components/home/index.vue | 1 +
6 files changed, 74 insertions(+), 10 deletions(-)
diff --git a/fe/README.md b/fe/README.md
index a7f5ed1..a238c22 100644
--- a/fe/README.md
+++ b/fe/README.md
@@ -1,4 +1,4 @@
-# dw-tool-ner
+# whale-anno
> Datawhale's ner tool.
diff --git a/fe/config/index.js b/fe/config/index.js
index 7405d54..07c68be 100644
--- a/fe/config/index.js
+++ b/fe/config/index.js
@@ -17,7 +17,7 @@ module.exports = {
},
// Various Dev Server settings
- host: 'localhost', // can be overwritten by process.env.HOST
+ host: '0.0.0.0', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
diff --git a/fe/dist/index.html b/fe/dist/index.html
index 53c4c66..0d6f3b8 100644
--- a/fe/dist/index.html
+++ b/fe/dist/index.html
@@ -1,4 +1,4 @@
-
dw-tool-ner
diff --git a/fe/src/components/NER/index.vue b/fe/src/components/NER/index.vue
index 9df946a..ba5c3d0 100644
--- a/fe/src/components/NER/index.vue
+++ b/fe/src/components/NER/index.vue
@@ -43,7 +43,24 @@
-
+
+
@@ -77,7 +94,7 @@
-
{{ word }}
@@ -90,8 +107,8 @@
-
-
+
+
@@ -316,7 +333,10 @@ export default {
})
}
},
- changeIdx: function (d) {
+ changeIdx: function (d, event) {
+ if (event) {
+ event.preventDefault() // 防止手机双击放大屏幕
+ }
const nowIdx = this.files.indexOf(this.nowFile)
let newIdx = nowIdx + d
if (newIdx < 0) newIdx = 0
@@ -328,6 +348,7 @@ export default {
* @param idx 点击文字的定位
*/
pointWord: function (idx, config = {}) {
+ console.log(this.mode, idx, config)
if (this.mode === 'select') {
if (!this.nowType) {
alert('请先选择标签')
@@ -342,6 +363,14 @@ export default {
return idx
}
},
+ pointWordByTouch: function (event) {
+ event.preventDefault() // 防止触发页面下拉
+ let {pageX, pageY} = event.touches[0]
+ let dom = document.elementFromPoint(pageX, pageY)
+ if (dom && dom.id) {
+ this.pointWord(dom.id)
+ }
+ },
/**
* 配置标注类型
* @param 类型
@@ -457,7 +486,19 @@ export default {
},
startSelect: function (idx, event) {
if (this.projectType !== '命名实体识别') return
+ let isNeedDel = false
+ if (event.touches) {
+ // 手机双击删除
+ if (this.startSelectTouchTs && Date.now() - this.startSelectTouchTs < 300) {
+ isNeedDel = true
+ }
+ this.startSelectTouchTs = Date.now()
+ }
if (event.which === 3) {
+ // 电脑右键删除
+ isNeedDel = true
+ }
+ if (isNeedDel) {
event.preventDefault()
// 右键删除对应的图标
const ners = this.ners
@@ -494,6 +535,7 @@ export default {
}
const isRepeat = this.checkIsRepeat(this.nowNer)
if (!isRepeat && this.nowNer.isMove) {
+ console.log(this.nowNer)
delete this.nowNer.isMove
this.ners.push(this.nowNer)
this.$set(this, 'ners', this.ners.sort((a, b) => {
@@ -963,4 +1005,22 @@ export default {
top: -9px;
right: -9px;
}
+@media only screen and (max-width: 800px) {
+ .out-title {
+ text-align: right !important;
+ }
+}
+@media only screen and (max-width: 600px) {
+ .out-title {
+ font-size: 0;
+ }
+}
+@media only screen and (max-width: 800px) {
+ .result-box {
+ display: none;
+ }
+ .left {
+ display: none;
+ }
+}
diff --git a/fe/src/components/home/index.vue b/fe/src/components/home/index.vue
index 724fd1f..26f5832 100644
--- a/fe/src/components/home/index.vue
+++ b/fe/src/components/home/index.vue
@@ -290,6 +290,7 @@ export default {
display: flex;
flex: 1 1;
flex-direction: row;
+ margin: 0 10px;
/* height: calc(100% - 92px); */
}
.button {