qiushang há 1 ano atrás
pai
commit
0f334c6034
7 ficheiros alterados com 130 adições e 21 exclusões
  1. BIN
      nsis/skin/bg1.png
  2. BIN
      nsis/skin/bg2.png
  3. BIN
      nsis/skin/bgtop.png
  4. 3 2
      package.json
  5. 1 1
      src/index.ejs
  6. 44 15
      src/renderer/components/home.vue
  7. 82 3
      yarn.lock

BIN
nsis/skin/bg1.png


BIN
nsis/skin/bg2.png


BIN
nsis/skin/bgtop.png


+ 3 - 2
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "XYPinyin",
-	"version": "1.3.0.0",
+	"version": "1.4.0.0",
 	"author": "苏州星优办公软件有限公司",
 	"description": "An electron-vue project",
 	"license": "pinyin",
@@ -9,7 +9,7 @@
 		"description": "这里是软件描述文档",
 		"downloadName": "YSPinyin",
 		"softMid": "Lfk5KXGSo9wC",
-		"softName": "星优拼音助手",
+		"softName": "星优汉字注音器",
 		"copyright": "苏州星优办公软件有限公司",
 		"popupAdvId": "8",
 		"linkId": "15",
@@ -38,6 +38,7 @@
 		"axios": "^0.18.0",
 		"element-ui": "^2.15.14",
 		"html-docx-js": "^0.3.1",
+		"mammoth": "^1.7.1",
 		"pinyin-pro": "^3.19.7",
 		"regedit": "^5.0.0",
 		"request": "^2.88.2",

+ 1 - 1
src/index.ejs

@@ -2,7 +2,7 @@
 <html>
   <head>
     <meta charset="utf-8">
-    <title>星优注音助手</title>
+    <title>星优汉字注音器</title>
     <% if (htmlWebpackPlugin.options.nodeModules) { %>
       <!-- Add `node_modules/` to global paths so `require` works properly in development -->
       <script>

+ 44 - 15
src/renderer/components/home.vue

@@ -52,7 +52,7 @@
 								<i class="el-icon-notebook-2"></i>
 								文件列表
 								<span style="color: #F22C40; float: right;cursor: pointer;"
-								 @click="$message({message:'超长文本结构注音时,分割成每30万字导出一份文档', type:'warning'})">{{ loadingTips }}</span>
+								 @click="$message({message:'超长文本结构注音时,分割成每10万字导出一份文档', type:'warning'})">{{ loadingTips }}</span>
 							</p>
 							<div class="table-scroll" id="drag-table">
 								<vxe-table
@@ -178,6 +178,7 @@
 	import pjson from '/package.json'
 	import { pinyin, html } from 'pinyin-pro';
 	import htmlDocx from 'html-docx-js/dist/html-docx';
+	import mammoth from 'mammoth';
 
 	let separator = '';
 	if (os.platform == 'linux') {
@@ -216,7 +217,7 @@
 				popupAdvList: [],
 
 				loading: false,
-				loadingTips: '长度超30万字,点击查看注意事项',
+				loadingTips: '长度超10万字,点击查看注意事项',
 				tempPath: '',
 				procMap: {},
 				execLimit: 2,
@@ -351,7 +352,7 @@
 			},
 			async pickFile() {
 				const spinLoad = this.$loading();
-				await electronApi.call('pickFile', ['txt', true]).then(async (files) => {
+				await electronApi.call('pickFile', ['txt,docx', true]).then(async (files) => {
 					this.pushFileToList(files);
 					spinLoad.close();
 				});
@@ -397,7 +398,7 @@
 						this.$message({message: '不是有效的文件! - ' + file, type: 'warning'});
 					} else {
 						let flag = true;
-						let format = "TXT";
+						let format = ["TXT", "DOCX"];
 						if (format.indexOf(fileInfo.type.toUpperCase()) == -1) {
 							this.$message({message: '不支持该文件格式! - ' + file, type: 'warning'});
 						} else {
@@ -603,12 +604,24 @@
 				
 				return true;
 			},
-			// 处理文件
-			dealFile(index, item, newPath) {
-				return new Promise((resolve, reject) => {
-					let path = item.path;
-					this.showPercent(10, index, item);
-					fs.readFile(path, 'utf8', async(err, data) => {
+			dealFile(index, item, newPath){ // 开始注音
+				let path = item.path;
+				this.showPercent(10, index, item);
+				if(item.type.toUpperCase() == 'DOCX'){ // word文档
+					mammoth.extractRawText({path: path}).then((result) =>{
+						let data = result.value;
+						return this.pinFile(index, item, newPath, data)
+					}).catch((error) => {
+						console.error(error);
+						this.$notify.error({
+							title: '错误',
+							message: "出现错误,请重试!" + filePath
+						});
+						reject(false);
+						
+					});
+				}else{
+					fs.readFile(path, 'utf8', (err, data) => {
 						if (err) {
 							console.error(err);
 							this.$notify.error({
@@ -617,6 +630,22 @@
 							});
 							reject(false);
 						}
+						return this.pinFile(index, item, newPath, data);
+					});
+				}
+			},
+			// 文件注音
+			pinFile(index, item, newPath, data) {
+				return new Promise(async(resolve, reject) => {
+					// fs.readFile(path, 'utf8', async(err, data) => {
+					// 	if (err) {
+					// 		console.error(err);
+					// 		this.$notify.error({
+					// 			title: '错误',
+					// 			message: "出现错误,请重试!" + filePath
+					// 		});
+					// 		reject(false);
+					// 	}
 						
 						if (!this.$refs.headerRef.authority.isAuthority) {
 							if(data.length > 20){
@@ -625,12 +654,12 @@
 						}
 						
 						let textLength = data.length;
-						let blockLength = Math.ceil(textLength / 300000);
+						let blockLength = Math.ceil(textLength / 100000);
 						let textArr = [];
-						if(textLength > 300000 && this.pinBuild != 3){ // 文字长度大于30万字且是结构输出,分块处理
+						if(textLength > 100000 && this.pinBuild != 3){ // 文字长度大于10万字且是结构输出,分块处理
 							for(let i=0; i<blockLength; i++){
-								let startIndex = i * 300000;
-								let endIndex = (i+1) * 300000;
+								let startIndex = i * 100000;
+								let endIndex = (i+1) * 100000;
 								textArr.push(data.slice(startIndex ,endIndex));
 							}
 							let result = await this.blockFile(index, item, textArr);
@@ -687,7 +716,7 @@
 							});
 						}
 						
-					});
+					// });
 				});
 			},
 			

+ 82 - 3
yarn.lock

@@ -337,7 +337,7 @@
     "@webassemblyjs/wast-parser" "1.9.0"
     "@xtuc/long" "4.2.2"
 
-"@xmldom/xmldom@^0.8.8":
+"@xmldom/xmldom@^0.8.6", "@xmldom/xmldom@^0.8.8":
   version "0.8.10"
   resolved "https://registry.npmmirror.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz#a1337ca426aa61cef9fe15b5b28e340a72f6fa99"
   integrity sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==
@@ -542,7 +542,7 @@ are-we-there-yet@~1.1.2:
     delegates "^1.0.0"
     readable-stream "^2.0.6"
 
-argparse@^1.0.7:
+argparse@^1.0.7, argparse@~1.0.3:
   version "1.0.10"
   resolved "https://registry.npmmirror.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
   integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
@@ -1814,6 +1814,11 @@ bluebird@^3.1.1, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.5:
   resolved "https://registry.npmmirror.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
   integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
 
+bluebird@~3.4.0:
+  version "3.4.7"
+  resolved "https://registry.npmmirror.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3"
+  integrity sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==
+
 bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9:
   version "4.12.0"
   resolved "https://registry.npmmirror.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88"
@@ -3260,6 +3265,11 @@ diffie-hellman@^5.0.0:
     miller-rabin "^4.0.0"
     randombytes "^2.0.0"
 
+dingbat-to-unicode@^1.0.1:
+  version "1.0.1"
+  resolved "https://registry.npmmirror.com/dingbat-to-unicode/-/dingbat-to-unicode-1.0.1.tgz#5091dd673241453e6b5865e26e5a4452cdef5c83"
+  integrity sha512-98l0sW87ZT58pU4i61wa2OHwxbiYSbuxsCBozaVnYX2iCnr3bLM3fIes1/ej7h1YdOKuKt/MLs706TVnALA65w==
+
 dir-compare@^2.4.0:
   version "2.4.0"
   resolved "https://registry.npmmirror.com/dir-compare/-/dir-compare-2.4.0.tgz#785c41dc5f645b34343a4eafc50b79bac7f11631"
@@ -3403,6 +3413,13 @@ dotenv@^9.0.2:
   resolved "https://registry.npmmirror.com/dotenv/-/dotenv-9.0.2.tgz#dacc20160935a37dea6364aa1bef819fb9b6ab05"
   integrity sha512-I9OvvrHp4pIARv4+x9iuewrWycX6CcZtoAu1XrzPxc5UygMJXJZYmBsynku8IkrJwgypE5DGNjDPmPRhDCptUg==
 
+duck@^0.1.12:
+  version "0.1.12"
+  resolved "https://registry.npmmirror.com/duck/-/duck-0.1.12.tgz#de7adf758421230b6d7aee799ce42670586b9efa"
+  integrity sha512-wkctla1O6VfP89gQ+J/yDesM0S7B7XLXjKGzXxMDVFg7uEn706niAtyYovKbyq1oT9YwDcly721/iUWoc8MVRg==
+  dependencies:
+    underscore "^1.13.1"
+
 duplexer3@^0.1.4:
   version "0.1.5"
   resolved "https://registry.npmmirror.com/duplexer3/-/duplexer3-0.1.5.tgz#0b5e4d7bad5de8901ea4440624c8e1d20099217e"
@@ -5032,6 +5049,11 @@ ignore@^3.3.5:
   resolved "https://registry.npmmirror.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
   integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==
 
+immediate@~3.0.5:
+  version "3.0.6"
+  resolved "https://registry.npmmirror.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
+  integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==
+
 import-lazy@^2.1.0:
   version "2.1.0"
   resolved "https://registry.npmmirror.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"
@@ -5712,6 +5734,16 @@ jszip@^2.3.0:
   dependencies:
     pako "~1.0.2"
 
+jszip@^3.7.1:
+  version "3.10.1"
+  resolved "https://registry.npmmirror.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2"
+  integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==
+  dependencies:
+    lie "~3.3.0"
+    pako "~1.0.2"
+    readable-stream "~2.3.6"
+    setimmediate "^1.0.5"
+
 keyboardevent-from-electron-accelerator@^2.0.0:
   version "2.0.0"
   resolved "https://registry.npmmirror.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz#ace21b1aa4e47148815d160057f9edb66567c50c"
@@ -5777,6 +5809,13 @@ lazy-val@^1.0.4, lazy-val@^1.0.5:
   resolved "https://registry.npmmirror.com/lazy-val/-/lazy-val-1.0.5.tgz#6cf3b9f5bc31cee7ee3e369c0832b7583dcd923d"
   integrity sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==
 
+lie@~3.3.0:
+  version "3.3.0"
+  resolved "https://registry.npmmirror.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
+  integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==
+  dependencies:
+    immediate "~3.0.5"
+
 load-json-file@^1.0.0:
   version "1.1.0"
   resolved "https://registry.npmmirror.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
@@ -6053,6 +6092,15 @@ loose-envify@^1.0.0:
   dependencies:
     js-tokens "^3.0.0 || ^4.0.0"
 
+lop@^0.4.1:
+  version "0.4.1"
+  resolved "https://registry.npmmirror.com/lop/-/lop-0.4.1.tgz#744f1696ef480e68ce1947fe557b09db5af2a738"
+  integrity sha512-9xyho9why2A2tzm5aIcMWKvzqKsnxrf9B5I+8O30olh6lQU8PH978LqZoI4++37RBgS1Em5i54v1TFs/3wnmXQ==
+  dependencies:
+    duck "^0.1.12"
+    option "~0.2.1"
+    underscore "^1.13.1"
+
 loud-rejection@^1.0.0:
   version "1.6.0"
   resolved "https://registry.npmmirror.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
@@ -6127,6 +6175,22 @@ make-dir@^3.0.0:
   dependencies:
     semver "^6.0.0"
 
+mammoth@^1.7.1:
+  version "1.7.1"
+  resolved "https://registry.npmmirror.com/mammoth/-/mammoth-1.7.1.tgz#8e0b19ba2ce6a0c364e3ea7afa0ecfe67b7f33d3"
+  integrity sha512-ckxfvNH5sUaJh+SbYbxpvB7urZTGS02jA91rFCNiL928CgE9FXXMyXxcJBY0n+CpmKE/eWh7qaV0+v+Dbwun3Q==
+  dependencies:
+    "@xmldom/xmldom" "^0.8.6"
+    argparse "~1.0.3"
+    base64-js "^1.5.1"
+    bluebird "~3.4.0"
+    dingbat-to-unicode "^1.0.1"
+    jszip "^3.7.1"
+    lop "^0.4.1"
+    path-is-absolute "^1.0.0"
+    underscore "^1.13.1"
+    xmlbuilder "^10.0.0"
+
 map-cache@^0.2.2:
   version "0.2.2"
   resolved "https://registry.npmmirror.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
@@ -6773,6 +6837,11 @@ opn@^5.5.0:
   dependencies:
     is-wsl "^1.1.0"
 
+option@~0.2.1:
+  version "0.2.4"
+  resolved "https://registry.npmmirror.com/option/-/option-0.2.4.tgz#fd475cdf98dcabb3cb397a3ba5284feb45edbfe4"
+  integrity sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==
+
 os-browserify@^0.3.0:
   version "0.3.0"
   resolved "https://registry.npmmirror.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27"
@@ -8304,7 +8373,7 @@ set-value@^2.0.0, set-value@^2.0.1:
     is-plain-object "^2.0.3"
     split-string "^3.0.1"
 
-setimmediate@^1.0.4:
+setimmediate@^1.0.4, setimmediate@^1.0.5:
   version "1.0.5"
   resolved "https://registry.npmmirror.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
   integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
@@ -9231,6 +9300,11 @@ unbox-primitive@^1.0.2:
     has-symbols "^1.0.3"
     which-boxed-primitive "^1.0.2"
 
+underscore@^1.13.1:
+  version "1.13.6"
+  resolved "https://registry.npmmirror.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441"
+  integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==
+
 undici-types@~5.26.4:
   version "5.26.5"
   resolved "https://registry.npmmirror.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
@@ -9897,6 +9971,11 @@ xmlbuilder@>=11.0.1, xmlbuilder@^15.1.1:
   resolved "https://registry.npmmirror.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5"
   integrity sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==
 
+xmlbuilder@^10.0.0:
+  version "10.1.1"
+  resolved "https://registry.npmmirror.com/xmlbuilder/-/xmlbuilder-10.1.1.tgz#8cae6688cc9b38d850b7c8d3c0a4161dcaf475b0"
+  integrity sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==
+
 "xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1:
   version "4.0.2"
   resolved "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"