From 473f32ca29253a6478c3f13b3be6a2aa7c926464 Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Mon, 22 Dec 2025 15:23:47 +0800 Subject: [PATCH] =?UTF-8?q?chore(batchs):=20=E6=96=B0=E5=A2=9E=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E8=B5=84=E6=BA=90=E5=92=8C=E5=BA=94=E7=94=A8=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=9A=84=E7=BC=96=E8=AF=91=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/batchs/complie_rc.bat | 62 +++++++++++++++++++++++++++++++++ src/gui/batchs/complie_rc.sh | 64 +++++++++++++++++++++++++++++++++++ src/gui/batchs/complie_ui.bat | 33 ++++++++++++++++++ src/gui/batchs/complie_ui.sh | 30 ++++++++++++++++ src/gui/batchs/readme.md | 1 + 5 files changed, 190 insertions(+) create mode 100644 src/gui/batchs/complie_rc.bat create mode 100644 src/gui/batchs/complie_rc.sh create mode 100644 src/gui/batchs/complie_ui.bat create mode 100644 src/gui/batchs/complie_ui.sh create mode 100644 src/gui/batchs/readme.md diff --git a/src/gui/batchs/complie_rc.bat b/src/gui/batchs/complie_rc.bat new file mode 100644 index 0000000..83c2389 --- /dev/null +++ b/src/gui/batchs/complie_rc.bat @@ -0,0 +1,62 @@ +@echo off +chcp 65001 >nul +setlocal enabledelayedexpansion + +cd /d "%~dp0.." + +echo [AutoLibrary complie] 检查翻译文件... +if exist translators ( + cd translators + set ts_count=0 + for %%f in (*.ts) do set /a ts_count+=1 + + if !ts_count! gtr 0 ( + echo [AutoLibrary complie] 找到 !ts_count! 个 .ts 文件,开始编译翻译文件... + for %%f in (*.ts) do ( + set "qm_filename=%%~nf.qm" + echo [AutoLibrary complie] 正在编译翻译文件: "%%f" -> "!qm_filename!" + + pyside6-lrelease "%%f" + if !errorlevel! equ 0 ( + echo [AutoLibrary complie] 翻译文件 "%%f" ✓ 编译成功,输出文件: "!qm_filename!" + ) else ( + echo [AutoLibrary complie] 翻译文件 "%%f" ✗ 编译失败 + ) + ) + echo. + ) else ( + echo [AutoLibrary complie] 未找到任何 .ts 翻译文件 + ) + cd .. +) else ( + echo [AutoLibrary complie] 未找到 translators 目录 +) +echo. + +set count=0 +for %%f in (*.qrc) do set /a count+=1 + +if %count% equ 0 ( + echo [AutoLibrary complie] 错误: 未找到任何 .qrc 文件 + pause + exit /b 1 +) + +echo [AutoLibrary complie] 找到 %count% 个 .qrc 文件,开始编译... +echo. + +for %%f in (*.qrc) do ( + set "filename=%%~nf" + set "output_file=!filename!.py" + echo [AutoLibrary complie] 正在编译: "%%f" -> "!output_file!" + + pyside6-rcc "%%f" -o "!output_file!" + if !errorlevel! equ 0 ( + echo [AutoLibrary complie] 文件 "%%f" ✓ 编译成功,输出文件: "!output_file!" + ) else ( + echo [AutoLibrary complie] 文件 "%%f" ✗ 编译失败 + ) + echo. +) + +echo [AutoLibrary complie] 所有操作完成。 \ No newline at end of file diff --git a/src/gui/batchs/complie_rc.sh b/src/gui/batchs/complie_rc.sh new file mode 100644 index 0000000..8497951 --- /dev/null +++ b/src/gui/batchs/complie_rc.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PARENT_DIR="$(dirname "$SCRIPT_DIR")" +cd "$PARENT_DIR" + +echo "[AutoLibrary complie] 检查翻译文件..." +if [ -d "translators" ]; then + cd translators + ts_files=(*.ts) + ts_count=${#ts_files[@]} + + # 如果第一个元素是"*.ts"(表示没有匹配),则数量为0 + if [ "$ts_count" -eq 1 ] && [ "${ts_files[0]}" = "*.ts" ]; then + ts_count=0 + fi + + if [ $ts_count -gt 0 ]; then + echo "[AutoLibrary complie] 找到 $ts_count 个 .ts 文件,开始编译翻译文件..." + for file in *.ts; do + base_name=$(basename "$file" .ts) + qm_file="${base_name}.qm" + echo "[AutoLibrary complie] 正在编译翻译文件: \"$file\" -> \"$qm_file\"" + + if pyside6-lrelease "$file"; then + echo "[AutoLibrary complie] 翻译文件 \"$file\" ✓ 编译成功,输出文件: \"$qm_file\"" + else + echo "[AutoLibrary complie] 翻译文件 \"$file\" ✗ 编译失败" + fi + done + echo + else + echo "[AutoLibrary complie] 未找到任何 .ts 翻译文件" + fi + cd .. +else + echo "[AutoLibrary complie] 未找到 translators 目录" +fi +echo + +file_count=$(ls *.qrc 2>/dev/null | wc -l) + +if [ $file_count -eq 0 ]; then + echo "[AutoLibrary complie] 错误: 未找到任何 .qrc 文件" + exit 1 +fi + +echo "[AutoLibrary complie] 找到 $file_count 个 .qrc 文件,开始编译..." +echo + +for file in *.qrc; do + base_name=$(basename "$file" .qrc) + output_file="${base_name}.py" + echo "[AutoLibrary complie] 正在编译: \"$file\" -> \"$output_file\"" + + if pyside6-rcc "$file" -o "$output_file"; then + echo "[AutoLibrary complie] 文件 \"$file\" ✓ 编译成功,输出文件: \"$output_file\"" + else + echo "[AutoLibrary complie] 文件 \"$file\" ✗ 编译失败" + fi + echo +done + +echo "[AutoLibrary complie] 所有操作完成。" \ No newline at end of file diff --git a/src/gui/batchs/complie_ui.bat b/src/gui/batchs/complie_ui.bat new file mode 100644 index 0000000..0449ec5 --- /dev/null +++ b/src/gui/batchs/complie_ui.bat @@ -0,0 +1,33 @@ +@echo off +chcp 65001 >nul +setlocal enabledelayedexpansion + +cd /d "%~dp0.." + +set count=0 +for %%f in (*.ui) do set /a count+=1 + +if %count% equ 0 ( + echo [AutoLibrary complie] 错误: 未找到任何 .ui 文件 + pause + exit /b 1 +) + +echo [AutoLibrary complie] 找到 %count% 个 .ui 文件,开始编译... +echo. + +for %%f in (*.ui) do ( + set "filename=%%~nf" + set "output_file=Ui_!filename!.py" + echo [AutoLibrary complie] 正在编译: "%%f" -> "!output_file!" + + pyside6-uic "%%f" -o "!output_file!" + if !errorlevel! equ 0 ( + echo [AutoLibrary complie] 文件 "%%f" ✓ 编译成功,输出文件: "!output_file!" + ) else ( + echo [AutoLibrary complie] 文件 "%%f" ✗ 编译失败 + ) + echo. +) + +echo [AutoLibrary complie] 所有操作完成。 \ No newline at end of file diff --git a/src/gui/batchs/complie_ui.sh b/src/gui/batchs/complie_ui.sh new file mode 100644 index 0000000..0c4b70f --- /dev/null +++ b/src/gui/batchs/complie_ui.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PARENT_DIR="$(dirname "$SCRIPT_DIR")" +cd "$PARENT_DIR" + +file_count=$(ls *.ui 2>/dev/null | wc -l) + +if [ $file_count -eq 0 ]; then + echo "[AutoLibrary complie] 错误: 未找到任何 .ui 文件" + exit 1 +fi + +echo "[AutoLibrary complie] 找到 $file_count 个 .ui 文件,开始编译..." +echo + +for file in *.ui; do + base_name=$(basename "$file" .ui) + output_file="Ui_${base_name}.py" + echo "[AutoLibrary complie] 正在编译: \"$file\" -> \"$output_file\"" + + if pyside6-uic "$file" -o "$output_file"; then + echo "[AutoLibrary complie] 文件 \"$file\" ✓ 编译成功,输出文件: \"$output_file\"" + else + echo "[AutoLibrary complie] 文件 \"$file\" ✗ 编译失败" + fi + echo +done + +echo "[AutoLibrary complie] 所有操作完成。" \ No newline at end of file diff --git a/src/gui/batchs/readme.md b/src/gui/batchs/readme.md new file mode 100644 index 0000000..30f9189 --- /dev/null +++ b/src/gui/batchs/readme.md @@ -0,0 +1 @@ +this folder is used to store the batch scripts.