准备重大更新代码生成

This commit is contained in:
2025-08-04 19:19:32 +08:00
parent 254328ddc8
commit fe82822d58
12 changed files with 1572 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class AIWorker(QThread):
self.prompt = prompt
def run(self):
url = "http://154.37.215.220:11434/api/generate"
url = "http://qutrobot.top:11434/api/generate"
payload = {
"model": "qwen3:0.6b",
"prompt": self.prompt

View File

@@ -5,6 +5,8 @@ from qfluentwidgets import TitleLabel, BodyLabel, PushButton, FluentIcon
from .function_fit_interface import FunctionFitInterface
from .ai_interface import AIInterface
from qfluentwidgets import InfoBar
from .tools.update_code import update_code
class CodeConfigurationInterface(QWidget):
def __init__(self, parent=None):
@@ -64,8 +66,24 @@ class CodeConfigurationInterface(QWidget):
self.tabBar.tabCloseRequested.connect(self.onCloseTab)
# 你可以在此处连接按钮的槽函数
# self.choose_btn.clicked.connect(self.choose_project_folder)
# self.update_template_btn.clicked.connect(self.update_user_template)
self.update_template_btn.clicked.connect(self.on_update_template)
def on_update_template(self):
def info(parent):
InfoBar.success(
title="更新成功",
content="用户模板已更新到最新版本!",
parent=parent,
duration=2000
)
def error(parent, msg):
InfoBar.error(
title="更新失败",
content=f"用户模板更新失败: {msg}",
parent=parent,
duration=3000
)
update_code(parent=self, info_callback=info, error_callback=error)
def addSubInterface(self, widget: QWidget, objectName: str, text: str):
widget.setObjectName(objectName)

View File

@@ -8,7 +8,7 @@ from .tools.part_download import DownloadThread # 新增导入
from urllib.parse import quote
class PartLibraryInterface(QWidget):
SERVER_URL = "http://154.37.215.220:5000"
SERVER_URL = "http://qutrobot.top:5000"
SECRET_KEY = "MRobot_Download"
LOCAL_LIB_DIR = "assets/mech_lib"

33
app/tools/update_code.py Normal file
View File

@@ -0,0 +1,33 @@
import os
import requests
import zipfile
import io
import shutil
def update_code(parent=None, info_callback=None, error_callback=None):
url = "http://gitea.qutrobot.top/robofish/MRobot/archive/User_code.zip"
local_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../assets/User_code")
try:
resp = requests.get(url, timeout=30)
resp.raise_for_status()
z = zipfile.ZipFile(io.BytesIO(resp.content))
if os.path.exists(local_dir):
shutil.rmtree(local_dir)
for member in z.namelist():
rel_path = os.path.relpath(member, z.namelist()[0])
if rel_path == ".":
continue
target_path = os.path.join(local_dir, rel_path)
if member.endswith('/'):
os.makedirs(target_path, exist_ok=True)
else:
os.makedirs(os.path.dirname(target_path), exist_ok=True)
with open(target_path, "wb") as f:
f.write(z.read(member))
if info_callback:
info_callback(parent)
return True
except Exception as e:
if error_callback:
error_callback(parent, str(e))
return False