Bug fix for OS Version

This commit is contained in:
naibo 2024-04-24 23:12:03 +08:00
parent a2bd496e8e
commit b1632459ef
2 changed files with 43 additions and 15 deletions

View File

@ -91,7 +91,7 @@
value="about:blank"></input> value="about:blank"></input>
<label><a href="https://github.com/NaiboWang/EasySpider/wiki/Argument-Instruction" <label><a href="https://github.com/NaiboWang/EasySpider/wiki/Argument-Instruction"
target="_blank">{{`Click Here~点击这里` | lang}}</a> {{`Here to see argument instruction.~这里查看参数配置说明。` | lang}}</label> target="_blank">{{`Click Here~点击这里` | lang}}</a> {{`Here to see argument instruction.~这里查看参数配置说明。` | lang}}</label>
<label v-if="OS=='darwin'">{{`对于MacOS系统EasySpider提供了两个不同的执行程序分别为easyspider_executestage和easyspider_executestage_full前者执行时加载速度较快并提供了除OCR识别和数据去重以外的全部功能后者则提供了包括OCR识别和数据去重在内的全部功能但运行时加载速度较慢需要等待2-10分钟才能执行程序请根据自己的需求选择执行哪个程序。~For MacOS system, EasySpider provides two different execution programs, 'easyspider_executestage' and 'easyspider_executestage_full', the former loads faster when executing, and provides all functions except OCR recognition and data deduplication; the latter provides all functions including OCR recognition and data deduplication, but the loading speed is slower when running, and it takes 2-10 minutes to wait for the program to execute, please choose which program to execute according to your needs.` | lang}}</label> <label v-if="OS=='MacOS'">{{`对于MacOS系统EasySpider提供了两个不同的执行程序分别为easyspider_executestage和easyspider_executestage_full前者执行时加载速度较快并提供了除OCR识别和数据去重以外的全部功能后者则提供了包括OCR识别和数据去重在内的全部功能但运行时加载速度较慢需要等待2-10分钟才能执行程序请根据自己的需求选择执行哪个程序。~For MacOS system, EasySpider provides two different execution programs, 'easyspider_executestage' and 'easyspider_executestage_full', the former loads faster when executing, and provides all functions except OCR recognition and data deduplication; the latter provides all functions including OCR recognition and data deduplication, but the loading speed is slower when running, and it takes 2-10 minutes to wait for the program to execute, please choose which program to execute according to your needs.` | lang}}</label>
<label>{{ `Please open a terminal (For Windows, please use PowerShell instead of CMD), go to EasySpider's folder, and then copy (Command/Ctrl + c) the following command to run the task (EasySpider can quit when executing command for ease of timed execution, and you can set --read_type to "remote" for remote execution):~请在EasySpider目录下打开命令行工具Terminal Windows请使用PowerShell而不是CMD然后复制Command/Ctrl + c和运行以下命令以执行任务执行命令时可以退出EasySpider以方便定时执行如需要远程调用则需要将--read_type设置为remote并设置远程地址` | lang }}</label> <label>{{ `Please open a terminal (For Windows, please use PowerShell instead of CMD), go to EasySpider's folder, and then copy (Command/Ctrl + c) the following command to run the task (EasySpider can quit when executing command for ease of timed execution, and you can set --read_type to "remote" for remote execution):~请在EasySpider目录下打开命令行工具Terminal Windows请使用PowerShell而不是CMD然后复制Command/Ctrl + c和运行以下命令以执行任务执行命令时可以退出EasySpider以方便定时执行如需要远程调用则需要将--read_type设置为remote并设置远程地址` | lang }}</label>
<textarea class="form-control" style="height:150px">cd {{easyspider_location}} <textarea class="form-control" style="height:150px">cd {{easyspider_location}}
{{command}} --config_folder "{{config_folder}}" --headless 0 --read_type local --config_file_name config.json --saved_file_name </textarea> {{command}} --config_folder "{{config_folder}}" --headless 0 --read_type local --config_file_name config.json --saved_file_name </textarea>
@ -348,7 +348,7 @@
config_folder: "", config_folder: "",
easyspider_location: "", easyspider_location: "",
mysql_config_path: "", mysql_config_path: "",
OS: "win32", OS: "Windows",
}, mounted() { }, mounted() {
$.get(this.backEndAddressServiceWrapper + "/getConfig", function (result) { $.get(this.backEndAddressServiceWrapper + "/getConfig", function (result) {
app.$data.user_data_folder = result.user_data_folder; app.$data.user_data_folder = result.user_data_folder;
@ -559,12 +559,14 @@
}; };
app.$data.ID = result; app.$data.ID = result;
ws.send(JSON.stringify(message)); ws.send(JSON.stringify(message));
$.get(app.$data.backEndAddressServiceWrapper + "/queryOSVersion", function (OSInfo) { // 使用函数并打印结果
if (OSInfo.version == 'darwin') { const systemInfo = detectOperatingSystemAndArch();
// $.get(app.$data.backEndAddressServiceWrapper + "/queryOSVersion", function (OSInfo) {
if (systemInfo.OS == 'MacOS') {
changeCommand(); changeCommand();
$('#myModal').modal('show'); $('#myModal').modal('show');
} }
}); // });
}); });
// } // }
}, },
@ -574,15 +576,17 @@
}); });
function changeCommand() { function changeCommand() {
$.get(app.$data.backEndAddressServiceWrapper + "/queryOSVersion", function (OSInfo) { // $.get(app.$data.backEndAddressServiceWrapper + "/queryOSVersion", function (OSInfo) {
app.$data.OS = OSInfo.version; // app.$data.OS = systemInfo.OS;
if (OSInfo.version == 'win32' && OSInfo.bit == 'x64') { const systemInfo = detectOperatingSystemAndArch();
app.$data.OS = systemInfo.OS;
if (systemInfo.OS == 'Windows' && systemInfo.architecture == 'x64') {
app.$data.command = "./EasySpider/resources/app/chrome_win64/easyspider_executestage.exe --ids [" + app.$data.ID.toString() + "] --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper; app.$data.command = "./EasySpider/resources/app/chrome_win64/easyspider_executestage.exe --ids [" + app.$data.ID.toString() + "] --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper;
} else if (OSInfo.version == 'win32' && OSInfo.bit == 'ia32') { } else if (systemInfo.OS == 'Windows' && systemInfo.architecture == 'ia32') {
app.$data.command = "./EasySpider/resources/app/chrome_win32/easyspider_executestage.exe --ids [" + app.$data.ID.toString() + "] --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper; app.$data.command = "./EasySpider/resources/app/chrome_win32/easyspider_executestage.exe --ids [" + app.$data.ID.toString() + "] --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper;
} else if (OSInfo.version == 'linux') { } else if (systemInfo.OS == 'Linux') {
app.$data.command = "./EasySpider/resources/app/chrome_linux64/easyspider_executestage --ids '[" + app.$data.ID.toString() + "]' --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper; app.$data.command = "./EasySpider/resources/app/chrome_linux64/easyspider_executestage --ids '[" + app.$data.ID.toString() + "]' --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper;
} else if (OSInfo.version == 'darwin') { } else if (systemInfo.OS == 'MacOS') {
if (getUrlParam("lang") == "zh") { if (getUrlParam("lang") == "zh") {
app.$data.easyspider_location = "你的EasySpider文件夹cd /Users/" + app.$data.config_folder.split("/")[2] + "/Downloads/EasySpider_MacOS"; app.$data.easyspider_location = "你的EasySpider文件夹cd /Users/" + app.$data.config_folder.split("/")[2] + "/Downloads/EasySpider_MacOS";
} else { } else {
@ -590,7 +594,7 @@
} }
app.$data.command = "./easyspider_executestage --ids '[" + app.$data.ID.toString() + "]' --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper; app.$data.command = "./easyspider_executestage --ids '[" + app.$data.ID.toString() + "]' --user_data " + (app.$data.with_user_data ? "1" : "0") + " --server_address " + app.$data.backEndAddressServiceWrapper;
} }
}); // });
} }
$.get(app.$data.backEndAddressServiceWrapper + "/queryTask?id=" + sId, function (result) { $.get(app.$data.backEndAddressServiceWrapper + "/queryTask?id=" + sId, function (result) {

View File

@ -127,3 +127,27 @@ document.onkeydown = function (e) {
} }
} }
} }
function detectOperatingSystemAndArch() {
const platform = navigator.platform.toLowerCase();
const userAgent = navigator.userAgent.toLowerCase();
let OS = 'Unknown';
let architecture = 'Unknown';
// 判断操作系统类型
if (platform.includes('win')) {
OS = 'Windows';
} else if (platform.includes('mac')) {
OS = 'MacOS';
} else if (platform.includes('linux')) {
OS = 'Linux';
}
// 判断操作系统位数
if (userAgent.includes('wow64') || userAgent.includes('win64') || platform.includes('x86_64') || platform.includes('amd64')) {
architecture = 'x64';
} else {
architecture = 'ia32';
}
return { OS, architecture };
}