Skip to content

Commit

Permalink
release v2.2.1
Browse files Browse the repository at this point in the history
fix: shici are not in order
fix: LaTeX doesn't have newlines
fix: not <hr> in ChangeLog
  • Loading branch information
LSCube7 committed Apr 24, 2024
1 parent 4d5a92b commit a40f34a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "henguren",
"version": "2.2.0",
"version": "2.2.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
8 changes: 8 additions & 0 deletions public/ChangeLog.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<h1 style="text-align: center;">更新日志</h1>
<h2>v2.2.1</h2>
<p>本次更新修复了少许Bug</p>
<h3>Bug修复</h3>
<p>实词重复并未按照拼音顺序排列</p>
<p>LaTeX增加换行</p>
<p>更新日志中无分割线</p>
<hr>
<h2>v2.2.0</h2>
<p>本次更新增加了一些功能,并修复了少许Bug和增加了一些特性</p>
<h3>增加内容</h3>
Expand All @@ -8,6 +15,7 @@ <h3>Bug修复</h3>
<p>义项偏左导致无法显示</p>
<h3>增加特性</h3>
<p>将单位部分改为rem</p>
<hr>
<h2>v2.1.0</h2>
<p>本次更新增加了一些功能,并增加了一些特性</p>
<h3>增加内容</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
return {
isChangeLogVisible: false,
isColorPickerVisible: false,
currentAppVersion: '2.2.0'
currentAppVersion: '2.2.1'
};
},
mounted() {
Expand Down
73 changes: 42 additions & 31 deletions src/ShiciFinder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div class="container">
<h1>寻找实词</h1>
<label for="textInput">输入古文:</label><br />
<textarea id="textInput" placeholder="请输入一段古文" v-model="inputText" @input="autoResize" autofocus @keydown.ctrl.enter.prevent="processText"></textarea>
<textarea id="textInput" placeholder="请输入一段古文" v-model="inputText" @input="autoResize" autofocus
@keydown.ctrl.enter.prevent="processText"></textarea>
<br />
<button @click="processText">开始寻找(Ctrl+Enter)</button>
<br />
Expand Down Expand Up @@ -47,6 +48,14 @@ export default {
const inputText = this.inputText;
let highlightedWords = [];
let latexLines = [];
let orderedWords = [];
// Filter words from the text according to the order in the definitions.json
for (let word of wordList) {
if (inputText.includes(word)) {
orderedWords.push(word);
}
}
this.highlightedText = inputText.replace(new RegExp('(' + wordList.join('|') + ')', 'g'), match => {
if (definitions[match]) {
Expand All @@ -57,8 +66,10 @@ export default {
return match;
});
this.highlightedWords = highlightedWords.join(' ');
this.wordCountInfo = `共含有实词 ${highlightedWords.length}`;
this.highlightedWords = orderedWords.join(' ');
this.wordCountInfo = `共含有实词 ${orderedWords.length}`;
this.latexContent = `\\begin{align*}\n${latexLines.join('\n')}\n\\end{align*}`;
},
Expand Down Expand Up @@ -104,33 +115,33 @@ export default {
this.highlightedWord = null;
},
copyDefinitions() {
let latexContent = "";
// 遍历highlightedWords中的每个词条和它的定义,转换为LaTeX格式
this.highlightedWords.split(' ').forEach(word => {
if (definitions[word]) {
// 开始构建每个实词的LaTeX表示
latexContent += `${word}\\left\\{\\begin{matrix}\n`;
// 将每个定义添加为矩阵的一行,确保特殊字符被正确转义
definitions[word].forEach((def, index) => {
def = def.replace(/&/g, '\\&'); // 转义特殊字符&
latexContent += def;
if (index < definitions[word].length - 1) {
latexContent += " \\\\\n"; // 不是最后一项则添加换行
}
});
// 结束这个实词的LaTeX表示
latexContent += `\\end{matrix}\\right.\n`;
}
});
// 使用 Clipboard API 复制到剪贴板
navigator.clipboard.writeText(latexContent).then(() => {
alert('义项已复制到剪贴板');
}).catch(err => {
console.error('无法复制到剪贴板', err);
alert('复制失败,请检查浏览器权限设置。');
});
}
let latexContent = "";
// 遍历highlightedWords中的每个词条和它的定义,转换为LaTeX格式
this.highlightedWords.split(' ').forEach(word => {
if (definitions[word]) {
// 开始构建每个实词的LaTeX表示
latexContent += `$$\n${word}\\left\\{\\begin{matrix}\n`;
// 将每个定义添加为矩阵的一行,确保特殊字符被正确转义
definitions[word].forEach((def, index) => {
def = def.replace(/&/g, '\\&'); // 转义特殊字符&
latexContent += def;
if (index < definitions[word].length - 1) {
latexContent += " \\\\\n"; // 不是最后一项则添加换行
}
});
// 结束这个实词的LaTeX表示
latexContent += `\\end{matrix}\\right.\n$$\n`;
}
});
// 使用 Clipboard API 复制到剪贴板
navigator.clipboard.writeText(latexContent).then(() => {
alert('义项已复制到剪贴板');
}).catch(err => {
console.error('无法复制到剪贴板', err);
alert('复制失败,请检查浏览器权限设置。');
});
}
},
Expand Down Expand Up @@ -181,7 +192,7 @@ button {
cursor: pointer;
font-size: 1.125rem;
font-weight: bold;
transition: transform 0.3s, box-shadow 0.3s;
}
Expand Down

0 comments on commit a40f34a

Please sign in to comment.