mirror of
http://10.0.2.1:3031/sauer/bfa-dryer-design.git
synced 2026-06-30 15:56:42 +10:00
Load V1 layout as initial GrapesJS content — no more blank canvas
This commit is contained in:
parent
e544da537a
commit
4af8f488cd
8
app.py
8
app.py
@ -71,6 +71,14 @@ def logout():
|
|||||||
resp.delete_cookie("bfa_user")
|
resp.delete_cookie("bfa_user")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@app.route("/api/v1html", methods=["GET"])
|
||||||
|
def api_v1html():
|
||||||
|
html_path = os.path.join(LAYOUT_DIR, "v1_converted.html")
|
||||||
|
if os.path.exists(html_path):
|
||||||
|
with open(html_path) as f:
|
||||||
|
return f.read(), 200, {'Content-Type': 'text/html'}
|
||||||
|
return "", 404
|
||||||
|
|
||||||
@app.route("/api/layout", methods=["GET"])
|
@app.route("/api/layout", methods=["GET"])
|
||||||
def api_get_layout():
|
def api_get_layout():
|
||||||
return jsonify(get_layout())
|
return jsonify(get_layout())
|
||||||
|
|||||||
@ -254,12 +254,19 @@ function exportProject() {
|
|||||||
try {
|
try {
|
||||||
const resp = await fetch('api/layout');
|
const resp = await fetch('api/layout');
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
// Check if it's V2 (GrapesJS) or V1 (old format)
|
if (data.assets || data.styles || (data.pages && data.pages.length && data.pages[0].frames)) {
|
||||||
if (data.assets || data.styles || data.pages) {
|
// V2 GrapesJS project — load it
|
||||||
editor.loadProjectData(data);
|
editor.loadProjectData(data);
|
||||||
} else {
|
} else {
|
||||||
// V1 layout — start fresh with default canvas content
|
// No V2 yet — try loading converted V1 HTML
|
||||||
console.log('V1 layout detected — starting fresh GrapesJS project');
|
try {
|
||||||
|
const htmlResp = await fetch('api/v1html');
|
||||||
|
const html = await htmlResp.text();
|
||||||
|
if (html && html.length > 10) {
|
||||||
|
editor.setComponents(html);
|
||||||
|
console.log('Loaded V1 converted layout');
|
||||||
|
}
|
||||||
|
} catch(e2) { console.log('No V1 HTML either, starting blank'); }
|
||||||
}
|
}
|
||||||
} catch(e) { console.log('No saved layout, starting fresh'); }
|
} catch(e) { console.log('No saved layout, starting fresh'); }
|
||||||
})();
|
})();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user