From 32f6a6ae91851a911ae58170a0bb6196ddaa9271 Mon Sep 17 00:00:00 2001 From: skimrme Date: Sun, 8 Feb 2026 16:18:34 +0800 Subject: [PATCH] =?UTF-8?q?mac=E5=AE=8C=E6=88=90=E6=89=93=E5=8C=85?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=85=A8=E6=B2=A1=E9=97=AE=E9=A2=98=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mac/build.py | 63 +++++++++++++++++++++++++++++++++++++++++ mac/command/Download.py | 8 ++++++ mac/command/help.py | 2 ++ mac/command/main.py | 18 ++++++++++++ mac/command/version.py | 2 ++ 5 files changed, 93 insertions(+) create mode 100644 mac/build.py create mode 100644 mac/command/Download.py create mode 100644 mac/command/help.py create mode 100644 mac/command/main.py create mode 100644 mac/command/version.py diff --git a/mac/build.py b/mac/build.py new file mode 100644 index 0000000..2f7dc5b --- /dev/null +++ b/mac/build.py @@ -0,0 +1,63 @@ +#打包脚本 +import subprocess, os, sys + +# 建立venv虚拟环境 +print("建立venv虚拟环境") +subprocess.run("python3 -m venv venv", shell=True) + +# 安装requirements.txt中的库 +print("安装requirements.txt中的库") +subprocess.run("venv/bin/pip3 install -r ../requirements.txt", shell=True) + +# 列出pip安装的库 +print("列出pip安装的库") +subprocess.run("venv/bin/pip3 list", shell=True) + +# pyinstaller打包程序 +print("pyinstaller打包中") +print("打包main.py") +subprocess.run("venv/bin/pyinstaller --onefile command/main.py", shell=True) +print("打包help.py") +subprocess.run("venv/bin/pyinstaller --onefile command/help.py", shell=True) +print("打包Download.py") +subprocess.run("venv/bin/pyinstaller --onefile command/Download.py", shell=True) +print("打包version.py") +subprocess.run("venv/bin/pyinstaller --onefile command/version.py", shell=True) + +# 清理build和*.spec文件 +print("清理build和*.spec文件") +subprocess.run("rm -rf build/", shell=True) +print("正在清理*.spec文件") +subprocess.run("rm -rf main.spec version.spec Download.spec help.spec", shell=True) + + +# 重命名dist为jm_ +print("重命名dist为jm_") +dir_path = os.path.dirname(os.path.abspath(__file__)) +print("当前路径: " , f"{dir_path}") +pass +os.rename(f"{dir_path}/dist", "jm_") + + +# 测试程序 +print("测试程序") +print("建立测试脚本,test.sh") +subprocess.run(""" +cat <> test.sh +#!/bin/sh +cd ./jm_/ +./main +./main help +./main version +EOF +""", shell=True) +print("赋予test.sh可执行权限") +subprocess.run("chmod +x test.sh", shell=True) +print("运行test.sh测试脚本") +subprocess.run("/bin/sh test.sh", shell=True) + +# 测试完毕,删除test.sh脚本 +print("测试完毕,删除test.sh脚本") +subprocess.run("rm -rf test.sh", shell=True) + +print("大功告成~感谢您的使用") \ No newline at end of file diff --git a/mac/command/Download.py b/mac/command/Download.py new file mode 100644 index 0000000..ddb05fe --- /dev/null +++ b/mac/command/Download.py @@ -0,0 +1,8 @@ +import jmcomic as jm +import os, sys + +print(f'请输入 jmcomic 车号') + +car_id = input() + +jm.download_album(car_id) diff --git a/mac/command/help.py b/mac/command/help.py new file mode 100644 index 0000000..e3cf51a --- /dev/null +++ b/mac/command/help.py @@ -0,0 +1,2 @@ +print("jm", "{:12}选择你需要下载的漫画".format(" ")) +print("version", "{:7}查看当前版本".format(" ")) \ No newline at end of file diff --git a/mac/command/main.py b/mac/command/main.py new file mode 100644 index 0000000..275967c --- /dev/null +++ b/mac/command/main.py @@ -0,0 +1,18 @@ +import sys, subprocess + +# 设定 +if len(sys.argv) == 1: + # 如果什么都没输入就输出 + subprocess.run("./help", check=True) + +if len(sys.argv) > 1: + command = sys.argv[1] + + if command == "help": + subprocess.run("./help", check=True) + elif command == "jm": + subprocess.run("./Download", check=True) + elif command == "version": + subprocess.run("./version", check=True) + else: + print(f"未知的命令: {command}") \ No newline at end of file diff --git a/mac/command/version.py b/mac/command/version.py new file mode 100644 index 0000000..8e04244 --- /dev/null +++ b/mac/command/version.py @@ -0,0 +1,2 @@ +print("jm_download_python") +print("2026-02-04", "(v0.02)") \ No newline at end of file