Skip to content

Commit

Permalink
取消 \r\n \n 的判断,直接替换并分隔
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBing committed Nov 24, 2023
1 parent 75d15a3 commit 92d9a05
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- fix 扩展词库类别有重复的问题
- 添加全局快捷键调起程序 ctrl + shift + alt + i
- 文件目录按备注的字母顺序排序
- 拆分词组不再受 `\r\n` `\n` 的影响,将 `\r\n` 替换成 `\n`,最终全部以 `\n` 拆分

## v1.20 `2023-07-01`
- 网络请求中添加 Diary-Uid
Expand Down
1 change: 1 addition & 0 deletions assets/evil-icons.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions assets/evil-icons.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions assets/scss/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ $btns: (
overflow: hidden;
}
.btn{
display: flex;
justify-content: flex-start;
align-items: center;
text-align: center;
font-size: $fz-button;
color: inherit;
Expand All @@ -51,6 +54,9 @@ $btns: (
padding: $btn-padding-tb $btn-padding-lr ;
background-color: white;
@extend .unselectable;
.icon{
margin-right: 5px;
}
&:active{
@include transform(translateY(2px));
@include box-shadow(inset 0 1px 2px rgba(0,0,0,0.1));
Expand Down
6 changes: 6 additions & 0 deletions assets/scss/wubi.css
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@
}

.btn {
display: flex;
justify-content: flex-start;
align-items: center;
text-align: center;
font-size: 12px;
color: inherit;
Expand All @@ -704,6 +707,9 @@
-o-transition: all 0.3s;
transition: all 0.3s;
}
.btn .icon {
margin-right: 5px;
}
.btn:active {
-webkit-transform: translateY(2px);
-moz-transform: translateY(2px);
Expand Down
16 changes: 4 additions & 12 deletions js/Dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class Dict {
// 返回所有 word
getDictWordsInNormalMode(fileContent){
let startPoint = new Date().getTime()
let EOL = this.getFileEOLFrom(fileContent)
fileContent = fileContent.replace('/\r\n/g','\n')
let EOL = '\n'
let lines = fileContent.split(EOL) // 拆分词条与编码成单行
this.lastIndex = lines.length
let linesValid = lines.filter(item => item.indexOf('\t') > -1) // 选取包含 \t 的行
Expand All @@ -63,7 +64,8 @@ class Dict {
// 返回 word 分组
getDictWordsInGroupMode(fileContent){
let startPoint = new Date().getTime()
let EOL = this.getFileEOLFrom(fileContent)
fileContent = fileContent.replace('/\r\n/g','\n')
let EOL = '\n'
let lines = fileContent.split(EOL) // 拆分词条与编码成单行
let wordsGroup = [] // 总分组
let temp = null // 第一个分组
Expand Down Expand Up @@ -109,16 +111,6 @@ class Dict {
return [] // 文件内容为空时
}
}
// 判断码表文件的换行符是 \r\n 还是 \n
getFileEOLFrom(fileContent){
if(fileContent.indexOf('\r\n') > -1){
console.log('文件换行符为: \\r\\n')
return '\r\n'
} else {
console.log('文件换行符为: \\n')
return '\n'
}
}

// 排序
sort(groupIndex){
Expand Down
14 changes: 2 additions & 12 deletions js/DictMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class DictMap {
}
// 处理词条
let startPoint = new Date().getTime()
let EOL = this.getFileEOLFrom(fileContent)
fileContent = fileContent.replace('/\r\n/g','\n')
let EOL = '\n'
let lines = fileContent.split(EOL) // 拆分词条与编码成单行
this.lastIndex = lines.length + 1
let linesValid = lines.filter(item => item.indexOf(this.seperator) > -1) // 选取包含分隔符的行
Expand Down Expand Up @@ -117,17 +118,6 @@ class DictMap {
return [new Word(this.lastIndex++, code, word)]
}
}

// 判断码表文件的换行符是 \r\n 还是 \n
getFileEOLFrom(fileContent){
if(fileContent.indexOf('\r\n') > -1){
console.log('文件换行符为: \\r\\n')
return '\r\n'
} else {
console.log('文件换行符为: \\n')
return '\n'
}
}
}

module.exports = DictMap
13 changes: 2 additions & 11 deletions js/DictOther.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class DictOther {
// 返回所有 word
getDictWordsInNormalMode(fileContent){
let startPoint = new Date().getTime()
let EOL = this.getFileEOLFrom(fileContent)
fileContent = fileContent.replace('/\r\n/g','\n')
let EOL = '\n'
let lines = fileContent.split(EOL) // 拆分词条与编码成单行
this.lastIndex = lines.length + 1
// 如果为纯词模式,就使用所有的行,否则就根据分隔符进行筛选
Expand Down Expand Up @@ -155,16 +156,6 @@ class DictOther {
this.wordsOrigin.splice(insetPosition, 0, wordInsert)
}

// 判断码表文件的换行符是 \r\n 还是 \n
getFileEOLFrom(fileContent){
if(fileContent.indexOf('\r\n') > -1){
console.log('文件换行符为: \\r\\n')
return '\r\n'
} else {
console.log('文件换行符为: \\n')
return '\n'
}
}


// 删除词条
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
1 change: 1 addition & 0 deletions view/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<!--搜索框-->
<div class="search-bar" v-if="dict">
<div class="btn btn-primary" @click="applyRime">部署</div>
<div class="btn btn-primary" @click="reloadCurrentDict">刷新</div>
<div
:class="[
'btn',
Expand Down

0 comments on commit 92d9a05

Please sign in to comment.