注册表桌面路径中文乱码问题

This commit is contained in:
2022-11-14 10:00:58 +08:00
parent c33a1aca8f
commit 887dce0a36
3 changed files with 17 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{
"name": "JUSTAR",
"version": "2.2.0",
"version": "2.2.1",
"description": "钜星科技便民问诊系统",
"main": "src/index.js",
"scripts": {
@ -18,8 +18,7 @@
"directories": {
"output": "build"
},
"extraResources":[
"extraResources": [
{
"from": "./static",
"to": "../static"
@ -62,10 +61,12 @@
]
}
],
"publish": [{
"provider": "generic",
"url": "http://192.168.1.158:8889/file"
}]
"publish": [
{
"provider": "generic",
"url": "http://192.168.1.158:8889/file"
}
]
},
"linux": {
"icon": "./static/images/justar.ico"
@ -79,7 +80,7 @@
"createDesktopShortcut": false,
"installerIcon": "./static/images/justar.ico",
"uninstallerIcon": "./static/images/justar.ico",
"include":"./installer.nsh"
"include": "./installer.nsh"
}
},
"dependencies": {
@ -89,6 +90,7 @@
"electron-log": "^4.4.1",
"electron-updater": "^4.3.9",
"fs": "^0.0.1-security",
"iconv-lite": "^0.6.3",
"jquery": "^3.6.0",
"node-fetch": "2.6.1",
"popper.js": "^1.16.1",

View File

@ -159,7 +159,7 @@ let main ={
}
},
{
label:'版本号:2.2.0',
label:'版本号:2.2.1',
icon: respath + path.sep+ "static"+ path.sep+"images"+ path.sep+"paste.png",
},]
});
@ -167,4 +167,4 @@ let main ={
}
module.exports=main
module.exports=main

View File

@ -95,17 +95,20 @@
const ws = require('windows-shortcuts');
const os=require('os');
const process = require('child_process');
const iconv = require('iconv-lite');
const encoding = 'cp936';
const binaryEncoding = 'binary';
const keyPath = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders';//选择要修改或者保存或者删除的路径(操作路径)
let desktop;
let ele = require('electron');
let ipcRenderer = ele.ipcRenderer;
window.$ = window.jquery = require('jquery');
let update_info = {};
process.exec(`REG QUERY "${keyPath}" /v Desktop`, function (error, stdout, stderr) {
process.exec(`REG QUERY "${keyPath}" /v Desktop`, {encoding: binaryEncoding}, function (error, stdout, stderr) {
if (error != null) {
console.log('获取注册表桌面路径失败,异常如下:' + error);
} else {
let value = stdout.split(" ");
let value = iconv.decode(new Buffer(stdout, binaryEncoding), encoding).split(" ");
desktop = value[value.length - 1].replace(/^\s*|\s*$/g, ""); //获取注册表实际值并去除首尾空格
}
});