mirror of
http://10.0.2.1:3031/sauer/bfa-dryer-design.git
synced 2026-06-30 14:26: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")
|
||||
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"])
|
||||
def api_get_layout():
|
||||
return jsonify(get_layout())
|
||||
|
||||
@ -254,12 +254,19 @@ function exportProject() {
|
||||
try {
|
||||
const resp = await fetch('api/layout');
|
||||
const data = await resp.json();
|
||||
// Check if it's V2 (GrapesJS) or V1 (old format)
|
||||
if (data.assets || data.styles || data.pages) {
|
||||
if (data.assets || data.styles || (data.pages && data.pages.length && data.pages[0].frames)) {
|
||||
// V2 GrapesJS project — load it
|
||||
editor.loadProjectData(data);
|
||||
} else {
|
||||
// V1 layout — start fresh with default canvas content
|
||||
console.log('V1 layout detected — starting fresh GrapesJS project');
|
||||
// No V2 yet — try loading converted V1 HTML
|
||||
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'); }
|
||||
})();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user