修复偏移问题,修复代理问题

This commit is contained in:
2026-04-15 00:22:38 +08:00
parent f0f9d658eb
commit 6981553101
2 changed files with 20 additions and 4 deletions

View File

@@ -250,7 +250,12 @@ def download_gcode(file_id):
return redirect(url_for('main.files')) return redirect(url_for('main.files'))
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
filepath = os.path.join(gcode_dir, gcode_filename)
if not os.path.exists(filepath):
fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
if os.path.exists(fallback): filepath = fallback
if os.path.exists(filepath): if os.path.exists(filepath):
safe_name = print_file.original_filename.rsplit('.', 1)[0] + '.gcode' safe_name = print_file.original_filename.rsplit('.', 1)[0] + '.gcode'
@@ -266,7 +271,12 @@ def preview_gcode(file_id):
abort(403) abort(403)
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
filepath = os.path.join(gcode_dir, gcode_filename)
if not os.path.exists(filepath):
fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
if os.path.exists(fallback): filepath = fallback
content = "File not found or not ready." content = "File not found or not ready."
line_count = 0 line_count = 0
@@ -293,7 +303,11 @@ def delete_file(file_id):
stl_path = os.path.join(current_app.config['UPLOAD_FOLDER'], print_file.filename) stl_path = os.path.join(current_app.config['UPLOAD_FOLDER'], print_file.filename)
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
gcode_path = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
gcode_path = os.path.join(gcode_dir, gcode_filename)
fallback_gcode = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
proxy_path = stl_path + '.proxy.stl' proxy_path = stl_path + '.proxy.stl'
if os.path.exists(stl_path): if os.path.exists(stl_path):
@@ -302,6 +316,8 @@ def delete_file(file_id):
os.remove(proxy_path) os.remove(proxy_path)
if os.path.exists(gcode_path): if os.path.exists(gcode_path):
os.remove(gcode_path) os.remove(gcode_path)
if os.path.exists(fallback_gcode):
os.remove(fallback_gcode)
db.session.delete(print_file) db.session.delete(print_file)
db.session.commit() db.session.commit()

View File

@@ -866,7 +866,7 @@ function mergeAndSlice() {
if (m.userData.geomTrans) { if (m.userData.geomTrans) {
mat.multiply(m.userData.geomTrans); mat.multiply(m.userData.geomTrans);
} }
const translation = new THREE.Matrix4().makeTranslation((bedWidth / 2) + offsetX, (bedDepth / 2) + offsetY, 0); const translation = new THREE.Matrix4().makeTranslation(offsetX,offsetY, 0);
mat.premultiply(translation); mat.premultiply(translation);
return { return {
file_id: m.userData.fileId, file_id: m.userData.fileId,