Skip to content

Commit

Permalink
构建说明更新
Browse files Browse the repository at this point in the history
  • Loading branch information
NaiboWang committed Jul 2, 2023
1 parent c7ddd19 commit 246cb14
Show file tree
Hide file tree
Showing 20 changed files with 9,576 additions and 12,959 deletions.
2 changes: 1 addition & 1 deletion .temp_to_pub/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def compress_folder_to_7z_split(folder_path, output_file):
# 压缩文件夹
subprocess.call(["7z", "a", "-v95m", output_file, folder_path])

easyspider_version = "0.3.3"
easyspider_version = "0.3.5"

if __name__ == "__main__":

Expand Down
1 change: 1 addition & 0 deletions ElectronJS/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Chrome/
execution_instances/*
.DS_Store
npminstall-debug.log
package-lock.json
Binary file modified ElectronJS/EasySpider_en.crx
Binary file not shown.
Binary file modified ElectronJS/EasySpider_zh.crx
Binary file not shown.
140 changes: 121 additions & 19 deletions ElectronJS/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,73 @@
## Note
# 环境编译说明/Environment Compilation Instructions

EasySpider分三部分:

1. 主程序:在`ElectronJS`文件夹下。
2. 浏览器扩展:在`Extension`文件夹下,为浏览器的“操作控制台”的代码,打包后的扩展在此目录下的`EasySpider_zh.crx`文件。
3. 执行阶段程序:在`ExecuteStage`文件夹下。

此部分为`主程序`的编译说明。

-----

EasySpider is divided into three parts:

1. Main program: Located in the ElectronJS folder.
2. Browser extension: Located in the Extension folder, i.e., the `EasySpider_en.crx` file in this folder.
3. Execution stage program: Located in the ExecuteStage folder.

This section covers the compilation instructions for the `main program`.

## 注意事项/Note

请记住,每当EasySpider扩展程序和执行程序更新时,都要更新`EasySpider.crx``easyspider_executestage`文件。

Remember to update EasySpider.crx everytime the extension updates.

## Prerequisite
## 环境构建/Environment Setup

以下以Windows x64版本为例。

Taking the example of Windows x64 version.

### 浏览器和驱动/Browser and Driver

实在搞不定本节的情况下,下载一个直接能用的EasySpider,并把文件夹内的`EasySpider\resources\app\chrome_win64`文件夹拷贝到此`ElectronJS`文件夹下即可。

If you're unable to handle the tasks in this section, you can download a ready-to-use EasySpider. Simply copy the EasySpider\resources\app\chrome_win64 folder from the downloaded files and paste it into the ElectronJS folder.

------

在自己的机器环境已经安装了Chrome的情况下,直接执行`python3 update_chrome.py`也可以完成本节下面写的一系列的操作,注意设置文件中的chrome大版本号为本机chrome的版本号。

If you already have Chrome installed on your local machine, you can directly execute python3 update_chrome.py to perform the operations mentioned in the following section. Make sure to set the Chrome major version in the configuration file to match the version of Chrome installed on your machine.

------

下载一个Chrome:[https://www.google.com/chrome/](https://www.google.com/chrome/),然后找到Chrome安装后的文件夹,如`C:\Program Files\Google\Chrome\Application`,把这个文件夹拷贝到此`ElectronJS`文件夹内,并按照以下格式更名:

```
chrome_win32/ # for windows x86
chrome_win64/ # for windows x64
chrome_linux64/ # for linux x64
chrome_mac64/ # for mac x64
```

然后,从下面的页面下载和**自己安装的Chrome版本一致**的Chromedriver:https://chromedriver.chromium.org/downloads,把chromedriver放入刚刚的chrome文件夹内,并更名为下面的格式:

```
chromedriver_win32.exe # for windows x86
chromedriver_win64.exe # for windows x64
chromedriver_linux64 # for linux x64
chromedriver_mac64 # for mac x64
```

例如,如果您想在Windows x64平台上构建此软件,那么您首先需要下载适用于Windows x64的Chrome浏览器,并将整个`chrome`文件夹复制到`ElectronJS`文件夹中,然后将文件夹重命名为`chrome_win64`。假设您下载的Chrome版本是110。接下来,下载一个适用于Windows x64的110版本的ChromeDriver,并将其放入`chrome_win64`文件夹中,然后将其重命名为`chromedriver_win64.exe`

Download a chrome from the Internet: https://www.google.com/chrome/, and then put them into this folder, with name format of the following:
最后,把此文件夹内的`stealth.min.js``execute.bat`文件拷贝入`chrome`文件夹内。


Download a Chrome from the Internet: https://www.google.com/chrome/, and then put them into this folder, with name format of the following:

```
chrome_win32/ # for windows x86
Expand All @@ -13,7 +76,7 @@ chrome_linux64/ # for linux x64
chrome_mac64/ # for mac x64
```

Then, download the corresponding chromedriver from the Internet on this page: https://chromedriver.chromium.org/downloads, note the **chromedriver version must match your chrome version**!!! And put them into corresponding chrome folder, with name format of the following:
Then, download the corresponding chromedriver from the Internet on this page: https://chromedriver.chromium.org/downloads, note the **chromedriver version must match your chrome version!!!** And put them into corresponding chrome folder, with name format of the following:

```
chromedriver_win32.exe # for windows x86
Expand All @@ -22,57 +85,96 @@ chromedriver_linux64 # for linux x64
chromedriver_mac64 # for mac x64
```

For example, if you want to build this software on Windows x64 platform, then you should first download a chrome for windows x64, then copy the whole `chrome` folder to this `ElectronJS` folder and rename the folder to `chrome_win64`, assume the chrome version you downloaded is 110; then, download a `chromedriver.exe` with version 110 for windows x64, and put it into the `chrome_win64` folder, then rename it to `chromedriver_win64.exe`.
For example, if you want to build this software on Windows x64 platform, then you should first download a chrome for Windows x64, then copy the whole `chrome` folder to this `ElectronJS` folder and rename the folder to `chrome_win64`, assume the chrome version you downloaded is 110; then, download a `chromedriver.exe` with version 110 for Windows x64, and put it into the `chrome_win64` folder, then rename it to `chromedriver_win64.exe`.

Finally, copy the `stealth.min.js` and `execute.bat` (for Windows x64) file in this folder to these `chrome` folders.

Finally, copy the `stealth.min.js` and `execute.bat` (for windows x64) file in this folder to these `chrome` folders.
### NodeJS环境/NodeJS Environment

## Run Instruction
1. Windows环境下需要先安装`VS Build Tools 2017` (https://aka.ms/vs/15/release/vs_buildtools.exe)的`Visual C++ Build Tools`组件,不然下面的命令无法执行,其他系统不需要。
2. 安装`NodeJS`https://nodejs.org/zh-cn/download/
3. 运行下面的命令来安装依赖:

```
npm install
npm install @electron-forge/cli -g
```

On Windows, you need to install `VS Build Tools 2017` (https://aka.ms/vs/15/release/vs_buildtools.exe, select and install the `Visual Studio Build Tools 2017` component) first for node-gyp to install `node-windows-manager`.
如果上面的命令运行速度很慢可以参考NodeJS换源说明:https://blog.csdn.net/qq_23211463/article/details/123769061

-----

1. On Windows, you need to install `VS Build Tools 2017` (https://aka.ms/vs/15/release/vs_buildtools.exe, select and install the `Visual C++ Build Tools` component) first for node-gyp to install `node-windows-manager` (No need for other OS).
2. Install `NodeJS`: https://nodejs.org/en/download/
3. Run the following commands to install NodeJS packages:

```
npm install
npm install @electron-forge/cli -g
```

Then run the software in developing mode:
## 运行说明/Run Instruction

在当前文件夹执行以下命令即可运行程序:

```sh
npm run start_direct
```

但到此为止只能设计任务,不能执行任务,想要执行任务还需要完成`ExecuteStage`文件夹下的执行任务程序的编译说明才可以执行。

-----

Run the software in developing mode:

```sh
npm run start_direct
```

## Package Instruction
But so far can only design the task, can not execute the task, want to execute the task also need to complete the 'ExecuteStage' folder of the execution of the task program compilation instructions can be executed.

## 打包发布说明/Package Instruction

After finish developing, package software by the following command:
打包发布前,确保执行阶段程序`easyspider_executestage(.exe)`已放入`chrome(_win64)`文件夹内,且浏览器插件`EasySpider_zh.crx`已经是最新版本。

执行下面的命令即可打包:

```
npx electron-forge import
npm run package
```

optional:
-----

Before packaging and releasing, make sure that the task execution program `easyspider_executestage(.exe)` is placed inside the `chrome(_win64)` folder and that the browser extension `EasySpider_en.crx` is the latest version.

After finishing developing, package software by the following command:

```
npm run make
npx electron-forge import
npm run package
```

#### For windows x64
### For windows x64

依次执行下面两个cmd即可打包并发布,无需执行上面的npm命令
依次执行下面两个cmd即可打包并发布,无需执行上面的npm命令,其他系统同理。

```
package_win64.cmd
clean_and_release_win64.cmd
```

#### For Windows x86
-----

依次执行下面两个cmd即可打包并发布,无需执行上面的npm命令
Execute the following two CMD commands sequentially to package and publish the program. There is no need to execute the previous npm command. The process is similar for other systems.

```
package_win32.cmd
clean_and_release_win32.cmd
package_win64.cmd
clean_and_release_win64.cmd
```

### (可选)编译成安装包/(Optional) Compile to an installation package

```
npm run make
```
14 changes: 10 additions & 4 deletions ElectronJS/change_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
import sys

# 读取JSON文件


def read_json_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
return data

# 保存为JSON文件


def save_json_file(data, file_path):
with open(file_path, 'w', encoding='utf-8') as file:
json.dump(data, file, indent=4, ensure_ascii=False)


def update_file_version(file_path, new_version, key="当前版本/Current Version: v"):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
Expand All @@ -24,7 +29,8 @@ def update_file_version(file_path, new_version, key="当前版本/Current Versio
line = re.sub(pattern, r'\g<1>'+new_version, line)
file.write(line)

version = "0.3.3"

version = "0.3.5"

# py html js

Expand All @@ -38,7 +44,7 @@ def update_file_version(file_path, new_version, key="当前版本/Current Versio

file_path = "./src/taskGrid/logic_CN.js"
update_file_version(file_path, version, key='"version": "')

file_path = "../ExecuteStage/easyspider_executestage.py"
update_file_version(file_path, version, key='"version": "')

Expand Down Expand Up @@ -72,7 +78,7 @@ def update_file_version(file_path, new_version, key="当前版本/Current Versio

# 保存为JSON文件
save_json_file(electron_config, file_path)

file_path = "../Extension/manifest_v3/src/manifest.json"

# 读取JSON文件
Expand All @@ -83,4 +89,4 @@ def update_file_version(file_path, new_version, key="当前版本/Current Versio
electron_config["version"] = version

# 保存为JSON文件
save_json_file(electron_config, file_path)
save_json_file(electron_config, file_path)
Loading

0 comments on commit 246cb14

Please sign in to comment.