fix(web): 修复 .soon/模板加载、旧文件兼容与另存为离开提示
- 删除 design1 ui 遗留代码,修复加载竞态与新建不弹保存提示 - cloud-files 归一化旧版 .soon,IndexedDB 写入完成后再跳转设计页 - 模板/本地 .soon 首次保存须另存为,离开前统一确认 - 发版缓存 bust(version.js、soon-cache.js)及宝塔 Nginx 配置文档 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -444,26 +444,39 @@
|
||||
}
|
||||
return fetchFromNetwork(key, cacheKey);
|
||||
|
||||
function readSessionJson(key, attempt) {
|
||||
attempt = attempt || 0;
|
||||
if (typeof window.soonLocalGet === 'function') {
|
||||
return window.soonLocalGet(cacheKey).then(function (hit) {
|
||||
if (hit && hit.json) return hit.json;
|
||||
var raw = null;
|
||||
try {
|
||||
raw = sessionStorage.getItem(key);
|
||||
if (!raw && typeof localStorage !== 'undefined') raw = localStorage.getItem(key);
|
||||
if (raw && raw !== 'idb') return JSON.parse(raw);
|
||||
} catch (e) { /* ignore */ }
|
||||
if (raw === 'idb' && attempt < 8) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(resolve, 60);
|
||||
}).then(function () { return readSessionJson(key, attempt + 1); });
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
try {
|
||||
var j = sessionStorage.getItem(key);
|
||||
if (!j && typeof localStorage !== 'undefined') j = localStorage.getItem(key);
|
||||
if (!j || j === 'idb') return Promise.resolve(null);
|
||||
return Promise.resolve(JSON.parse(j));
|
||||
} catch (e) { return Promise.resolve(null); }
|
||||
}
|
||||
|
||||
function fetchFromNetwork(key, cacheKey) {
|
||||
if (key.indexOf('soondesign_session:') === 0) {
|
||||
if (typeof window.soonLocalGet === 'function') {
|
||||
return window.soonLocalGet(cacheKey).then(function (hit) {
|
||||
if (hit && hit.json) return hit.json;
|
||||
try {
|
||||
var j = sessionStorage.getItem(key);
|
||||
if (!j && typeof localStorage !== 'undefined') j = localStorage.getItem(key);
|
||||
if (!j || j === 'idb') return null;
|
||||
var parsed = JSON.parse(j);
|
||||
return afterNetworkJson(parsed, { source: 'session', name: key });
|
||||
} catch (e) { return null; }
|
||||
});
|
||||
}
|
||||
try {
|
||||
var j = sessionStorage.getItem(key);
|
||||
if (!j && typeof localStorage !== 'undefined') j = localStorage.getItem(key);
|
||||
if (!j || j === 'idb') return Promise.resolve(null);
|
||||
return Promise.resolve(JSON.parse(j));
|
||||
} catch (e) { return Promise.resolve(null); }
|
||||
return readSessionJson(key, 0).then(function (parsed) {
|
||||
if (!parsed) return null;
|
||||
return afterNetworkJson(parsed, { source: 'session', name: key });
|
||||
});
|
||||
}
|
||||
if (key && key.indexOf('soondesign_file:') === 0 && typeof fetch !== 'undefined') {
|
||||
var fileMatch = key.match(/^soondesign_file:(\d+)/);
|
||||
|
||||
Reference in New Issue
Block a user