This commit is contained in:
2025-08-25 14:03:04 +08:00
parent 5e531d565b
commit 456be765ab
5 changed files with 5 additions and 10 deletions

View File

@@ -1,9 +1,8 @@
import os
import logging
import requests
import json import json
import time import logging
from pathlib import Path import os
import requests
from Config import Config from Config import Config
@@ -13,10 +12,6 @@ logger = logging.getLogger('MjCommon')
class MjCommon: class MjCommon:
# 获取项目根目录路径
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", ".."))
# 拼接相对路径
base_path = os.path.join(project_root, "src", "main", "python", "com", "dsideal", "aiSupport", "Util", "Midjourney", "Example")
ak = Config.GPTNB_API_KEY ak = Config.GPTNB_API_KEY
BASE_URL = Config.GPTNB_BASE_URL BASE_URL = Config.GPTNB_BASE_URL

View File

@@ -141,7 +141,7 @@ class Txt2Img(MjCommon):
# 生成文件名使用时间戳和任务ID # 生成文件名使用时间戳和任务ID
file_name = f"mj_{int(time.time() * 1000)}_{task_id}.png" file_name = f"mj_{int(time.time() * 1000)}_{task_id}.png"
# 完整保存路径 # 完整保存路径
save_path = os.path.join(MjCommon.base_path, file_name) save_path = os.path.join("d:/", file_name)
# 下载图片 # 下载图片
MjCommon.download_file(image_url, save_path) MjCommon.download_file(image_url, save_path)
except Exception as e: except Exception as e: