Compare commits
No commits in common. "2c649b8c7c7d8c7d949bc0f60f22997ff0888305" and "a4d1218d2106dfd2e8f6e2e9e72f829355f8dd8e" have entirely different histories.
2c649b8c7c
...
a4d1218d21
91
.github/workflows/build.yml
vendored
91
.github/workflows/build.yml
vendored
@ -1,91 +0,0 @@
|
|||||||
name: 构建安装包
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: 安装 Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.11"
|
|
||||||
|
|
||||||
- name: 安装 Node 依赖
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: 安装 Python 依赖并打包
|
|
||||||
run: |
|
|
||||||
cd python
|
|
||||||
python -m venv .venv
|
|
||||||
.venv\Scripts\pip install -r requirements.txt pyinstaller
|
|
||||||
.venv\Scripts\pyinstaller --onefile --name main --distpath dist --workpath build --specpath . --hidden-import xl_parser --hidden-import generator --collect-all openpyxl --collect-all et_xmlfile --collect-all PIL main.py
|
|
||||||
shell: cmd
|
|
||||||
|
|
||||||
- name: 构建 Renderer
|
|
||||||
run: cd renderer && npx vite build --config vite.config.mjs
|
|
||||||
|
|
||||||
- name: 打包 Electron(Windows)
|
|
||||||
run: npx electron-builder --win
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: 上传 Windows 安装包
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: windows-installer
|
|
||||||
path: dist/*.exe
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
build-mac:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: 安装 Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.11"
|
|
||||||
|
|
||||||
- name: 安装 Node 依赖
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: 安装 Python 依赖并打包
|
|
||||||
run: |
|
|
||||||
cd python
|
|
||||||
python3 -m venv .venv
|
|
||||||
.venv/bin/pip install -r requirements.txt pyinstaller
|
|
||||||
.venv/bin/pyinstaller --onefile --name main --distpath dist --workpath build --specpath . --hidden-import xl_parser --hidden-import generator --collect-all openpyxl --collect-all et_xmlfile --collect-all PIL main.py
|
|
||||||
|
|
||||||
- name: 构建 Renderer
|
|
||||||
run: cd renderer && npx vite build --config vite.config.mjs
|
|
||||||
|
|
||||||
- name: 打包 Electron(macOS)
|
|
||||||
run: npx electron-builder --mac
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
CSC_IDENTITY_AUTO_DISCOVERY: false
|
|
||||||
|
|
||||||
- name: 上传 macOS 安装包
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: mac-installer
|
|
||||||
path: dist/*.dmg
|
|
||||||
retention-days: 30
|
|
||||||
@ -18,19 +18,16 @@ const PYTHON_BIN = app.isPackaged
|
|||||||
function callPython(payload) {
|
function callPython(payload) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const isPackaged = app.isPackaged;
|
const isPackaged = app.isPackaged;
|
||||||
// PYTHONUTF8=1 确保 Windows 上 Python 使用 UTF-8 编码
|
|
||||||
const spawnEnv = { ...process.env, PYTHONUTF8: "1" };
|
|
||||||
const proc = isPackaged
|
const proc = isPackaged
|
||||||
? spawn(PYTHON_BIN, [], { env: spawnEnv })
|
? spawn(PYTHON_BIN)
|
||||||
: spawn(process.env.PYTHON_PATH || "python3", [PYTHON_BIN], { env: spawnEnv });
|
: spawn(process.env.PYTHON_PATH || "python3", [PYTHON_BIN]);
|
||||||
|
|
||||||
const chunks = [];
|
let stdout = "";
|
||||||
proc.stdout.on("data", (d) => chunks.push(d));
|
proc.stdout.on("data", (d) => (stdout += d));
|
||||||
proc.stderr.on("data", (d) => console.error("[python]", d.toString("utf8")));
|
proc.stderr.on("data", (d) => console.error("[python]", d.toString()));
|
||||||
proc.on("close", () => {
|
proc.on("close", () => {
|
||||||
const stdout = Buffer.concat(chunks).toString("utf8").trim();
|
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(stdout));
|
resolve(JSON.parse(stdout.trim()));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(new Error("Python 返回了无效 JSON: " + stdout));
|
reject(new Error("Python 返回了无效 JSON: " + stdout));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import io
|
|
||||||
|
|
||||||
# Windows 默认编码不是 UTF-8,强制设置
|
|
||||||
sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding="utf-8")
|
|
||||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", line_buffering=True)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user