Skip to content

Commit

Permalink
新增词的时候提示已存在的词条
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBing committed May 18, 2023
1 parent 8b469e1 commit 5275323
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

## v1.19 `2023-05-18`
- 新增词的时候提示已存在的词条

## v1.18 `2023-02-06`
- 线上请求地址写成配置项

Expand Down
48 changes: 48 additions & 0 deletions assets/scss/_searchbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,51 @@ select{

}
}


.word-redundancy-list{
position: absolute;
z-index: 9999;
top: 30px;
width: 400px;
left: 0;
background-color: white;
@include border-radius($radius);
overflow: hidden;
//border: 1px solid $border-color-panel;
padding: 5px 0 ;
@include box-shadow(2px 2px 5px transparentize(black, 0.8));
&-item{
display: flex;
justify-content: flex-start;
cursor: pointer;
padding: 0 10px;
white-space: nowrap;
.word{
margin-right: 20px;
color: $text-main;
}
.code{
margin-right: 20px;
color: $text-comment;
}
.origin{
&.blue{
color: $color-primary;
}
color: $color-success;
}
&:hover{
background-color: $bg-highlight;
.word{
color: white;
}
.code{
color: white;
}
.origin{
color: white;
}
}
}
}
50 changes: 50 additions & 0 deletions assets/scss/wubi.css
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,56 @@ select option {
padding: 10px;
}

.word-redundancy-list {
position: absolute;
z-index: 9999;
top: 30px;
width: 400px;
left: 0;
background-color: white;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
overflow: hidden;
padding: 5px 0;
-webkit-box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}
.word-redundancy-list-item {
display: flex;
justify-content: flex-start;
cursor: pointer;
padding: 0 10px;
white-space: nowrap;
}
.word-redundancy-list-item .word {
margin-right: 20px;
color: #000;
}
.word-redundancy-list-item .code {
margin-right: 20px;
color: #c2c2c2;
}
.word-redundancy-list-item .origin {
color: #67C23A;
}
.word-redundancy-list-item .origin.blue {
color: #409EFF;
}
.word-redundancy-list-item:hover {
background-color: rgba(255, 45, 112, 0.8);
}
.word-redundancy-list-item:hover .word {
color: white;
}
.word-redundancy-list-item:hover .code {
color: white;
}
.word-redundancy-list-item:hover .origin {
color: white;
}

.footer {
background-color: #f3f3f3;
width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions js/Global.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// const IS_IN_DEVELOP = false // 生产
const IS_IN_DEVELOP = true // 开发
const IS_IN_DEVELOP = false // 生产
// const IS_IN_DEVELOP = true // 开发

const DEFAULT_BASE_URL = 'https://kylebing.cn/portal/'
// const BASE_URL = 'http://localhost:3000/'
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "wubi-dict-editor",
"version": "1.1.8",
"version": "1.1.9",
"private": true,
"author": {
"name": "KyleBing",
"email": "[email protected]"
},
"date": "2023-02-06",
"date": "2023-05-18",
"dateInit": "2021-07-24",
"description": "五笔码表管理工具",
"main": "main.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"config": {
"forge": {
"packagerConfig": {
"appVersion": "1.1.8",
"appVersion": "1.1.9",
"name": "五笔码表助手",
"appCopyright": "[email protected]",
"icon": "./assets/img/appIcon/appicon",
Expand Down
31 changes: 29 additions & 2 deletions view/index/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const app = {
priority: '', // 优先级
note: '', // 备注

// 编码重复的词条
wordsRedundancy: [],

activeGroupId: -1, // 组 index
keywordUnwatch: null, // keyword watch 方法的撤消方法
labelOfSaveBtn: '保存', // 保存按钮的文本
Expand Down Expand Up @@ -65,6 +68,7 @@ const app = {
selectedCategoryId: 10, // 线上的 [ 通用词库 ]
dictBackupInfo: null, // 当前词库在线上的备份信息
isDeleteAfterUpload: false, // 上传词条后是否在本地删除对应的词条

}
},
mounted() {
Expand Down Expand Up @@ -255,7 +259,7 @@ const app = {
"sync_count": 2
}*/
if (this.dictBackupInfo){
console.log(this.dictBackupInfo)
// console.log(this.dictBackupInfo)
this.$set(this.dictBackupInfo,'date_init_string', dateFormatter(new Date(this.dictBackupInfo.date_init)))
this.$set(this.dictBackupInfo,'date_update_string', dateFormatter(new Date(this.dictBackupInfo.date_update)))
}
Expand Down Expand Up @@ -1074,7 +1078,30 @@ const app = {
},
code(newValue){
this.code = newValue.replaceAll(/[^A-Za-z ]/g, '') // input.code 只允许输入字母
console.log(this.dictMain.wordsOrigin.filter(item => item.code === newValue))
// 主码表中的词
let wordsMainDictRedundancy = this.dictMain.wordsOrigin.filter(item => item.code === newValue)
wordsMainDictRedundancy = wordsMainDictRedundancy.map(item => {
item.origin = '主码表' // 标记主码表来源
return item
})

// 用户词库中的词
let wordsCurrentDictRedundancy = []
if (this.dict.isGroupMode){
this.dict.wordsOrigin.forEach(wordGroup => {
wordsCurrentDictRedundancy.push(...wordGroup.dict.filter(item => item.code === newValue))
})
} else {
wordsCurrentDictRedundancy = this.dict.wordsOrigin.filter(item => item.code === newValue)
}

wordsCurrentDictRedundancy = wordsCurrentDictRedundancy.map(item => {
item.origin = '当前码表' // 标记主码表来源
return item
})


this.wordsRedundancy = wordsMainDictRedundancy.concat(wordsCurrentDictRedundancy)
},
word(newValue, oldValue){
if (/[a-z]/i.test(newValue)){
Expand Down
9 changes: 9 additions & 0 deletions view/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
<div @click="word = ''" v-show="word" class="btn-clear">
<img src="../../assets/img/delete_white.svg" alt="clear">
</div>

<div class="word-redundancy-list" v-if="wordsRedundancy.length > 0">
<div class="word-redundancy-list-item" v-for="word in wordsRedundancy" :key="word.id">
<div class="word">{{ word.word }}</div>
<div class="code">{{ word.code }}</div>
<div class="origin" v-if="word.origin === '当前码表'">{{ word.origin }}</div>
<div class="origin blue" v-else>{{ word.origin }}</div>
</div>
</div>
</div>
<div class="input-item">
<input class="code" ref="domInputCode" @keyup.enter="enterKeyPressed" v-model="code" type="text" placeholder="编码">
Expand Down

0 comments on commit 5275323

Please sign in to comment.