Skip to content

Commit

Permalink
release 2.4.0
Browse files Browse the repository at this point in the history
add: save definitions as tex file
fix: wrong in the definitions of “行”
  • Loading branch information
LSCube7 committed May 19, 2024
1 parent 1c8fcbe commit 5fa9ec8
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "henguren",
"version": "2.3.0",
"version": "2.4.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -11,6 +11,7 @@
"@vercel/analytics": "^1.2.2",
"@vercel/speed-insights": "^1.0.10",
"core-js": "^3.8.3",
"file-saver": "^2.0.5",
"register-service-worker": "^1.7.2",
"sass": "^1.75.0",
"sass-loader": "^14.2.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

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

6 changes: 6 additions & 0 deletions public/ChangeLog.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<h1 style="text-align: center;">更新日志</h1>
<h2>v2.4.0</h2>
<p>本次更新增加了一些功能,并修复了少许Bug</p>
<h3>增加内容</h3>
<p>增加保存义项为tex文件的选项</p>
<h2>Bug修复</h2>
<p>修复"行"的第一个义项有误</p>
<h2>v2.3.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 @@ -39,7 +39,7 @@ export default {
return {
isChangeLogVisible: false,
isColorPickerVisible: false,
currentAppVersion: '2.3.0'
currentAppVersion: '2.4.0'
};
},
mounted() {
Expand Down
32 changes: 30 additions & 2 deletions src/ShiciFinder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
<textarea id="wordCount" class="wordCount" v-model="wordCountInfo" readonly></textarea>
<br />
<button @click="copyDefinitions">复制义项(LaTeX格式)</button>
<br />
<button @click="saveDefinitions">下载义项tex文件</button>
</div>
</template>

<script>
import definitions from '@/assets/js/shici/definitions.json';
import FileSaver from 'file-saver';
export default {
data() {
Expand Down Expand Up @@ -120,7 +124,7 @@ export default {
this.highlightedWords.split(' ').forEach(word => {
if (definitions[word]) {
// 开始构建每个实词的LaTeX表示
latexContent += `$$\n${word}\\left\\{\\begin{matrix}\n`;
latexContent += `$$\n${word}\\left\\{\\begin{array}{l}\n`;
// 将每个定义添加为矩阵的一行,确保特殊字符被正确转义
definitions[word].forEach((def, index) => {
def = def.replace(/&/g, '\\&'); // 转义特殊字符&
Expand All @@ -130,7 +134,7 @@ export default {
}
});
// 结束这个实词的LaTeX表示
latexContent += `\\end{matrix}\\right.\n$$\n`;
latexContent += `\\end{array}\\right.\n$$\n`;
}
});
Expand All @@ -141,7 +145,31 @@ export default {
console.error('无法复制到剪贴板', err);
alert('复制失败,请检查浏览器权限设置。');
});
},
saveDefinitions() {
let latexContent = "";
// 遍历highlightedWords中的每个词条和它的定义,转换为LaTeX格式
this.highlightedWords.split(' ').forEach(word => {
if (definitions[word]) {
// 开始构建每个实词的LaTeX表示
latexContent += `$$\n${word}\\left\\{\\begin{array}{l}\n`;
// 将每个定义添加为矩阵的一行,确保特殊字符被正确转义
definitions[word].forEach((def, index) => {
def = def.replace(/&/g, '\\&'); // 转义特殊字符&
latexContent += def;
if (index < definitions[word].length - 1) {
latexContent += " \\\\\n"; // 不是最后一项则添加换行
}
});
// 结束这个实词的LaTeX表示
latexContent += `\\end{array}\\right.\n$$\n`;
}
});
let latexFileContent = "%!Tex Program = xelatex\n\\documentclass[twocolumn]{article}\n\\usepackage[fleqn]{amsmath}\n\\usepackage[UTF8]{ctex}\n\\setCJKmainfont{楷体}\n\\xeCJKsetup{CJKmath=true}\n\\begin{document}" + latexContent + "\\end{document}";
const latexBlob = new Blob([latexFileContent], {type: "text/x-tex;charset=utf-8"});
FileSaver.saveAs(latexBlob, "definitions.tex")
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/shici/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"谢": ["问候", "道歉"],
"信": ["信用,诚信(讲信用)", "(实情)", "相信,信任"],
"行": [
"行动",
"行走",
"(行动)",
"(爬行)",
"(通行,出行)",
Expand Down

0 comments on commit 5fa9ec8

Please sign in to comment.