Skip to content

Commit

Permalink
fix: ping encoding(#2)
Browse files Browse the repository at this point in the history
fixed #2
  • Loading branch information
geminate committed Sep 10, 2018
1 parent 4553e90 commit cc48c52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d-tools",
"version": "0.1.2",
"version": "0.1.3",
"author": "liuhuihao <1061036802@qq.com>",
"description": "d-tools is a toolbox for developers.Formatter, Base64, Regex test,Host manager and so on.",
"license": "MIT",
Expand Down
7 changes: 3 additions & 4 deletions src/renderer/pages/hostEdit/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
import readline from 'readline';
import {Loading} from 'element-ui';
import {exec} from 'child_process';
import iconv from 'iconv-lite';
import kill from 'tree-kill';
import {copyToClipboard} from '@/utils';
Expand Down Expand Up @@ -123,12 +122,12 @@
this.pingStatus = true;
if (this.pingIp.trim() != "") {
if (process.platform === 'darwin' || process.platform === 'linux') {
this.pingProcess = exec(`ping ${this.pingIp}`, {encoding: 'binary'});
this.pingProcess = exec(`ping ${this.pingIp}`, {encoding: 'UTF-8'});
} else {
this.pingProcess = exec(`ping ${this.pingIp} -t`, {encoding: 'binary'});
this.pingProcess = exec(`@chcp 65001 >nul & ping ${this.pingIp} -t`, {encoding: 'UTF-8'});
}
this.pingProcess.stdout.on('data', (data) => {
this.pingResult += `${iconv.decode(new Buffer(data, 'binary'), 'cp936')}\n`;
this.pingResult += data;
});
this.pingProcess.on('close', (code) => {
this.pingStatus = false;
Expand Down

0 comments on commit cc48c52

Please sign in to comment.