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:
@@ -1171,6 +1171,7 @@ function cleanupSrcFields(jsonObjects, objsArray) {
|
||||
function applyCloudWriteResult(result, fallbackName) {
|
||||
if (result && result.fileKey) {
|
||||
openAs.name = result.fileKey;
|
||||
if (typeof window.soonMarkSaveInPlace === 'function') window.soonMarkSaveInPlace(result.fileKey);
|
||||
return result.fileKey;
|
||||
}
|
||||
return fallbackName;
|
||||
@@ -1272,6 +1273,7 @@ function saveAs(op1, callback) {
|
||||
if (fs) {
|
||||
fs.writeFileSync(fp, content, 'utf8');
|
||||
openAs.name = fp;
|
||||
if (typeof window.soonMarkSaveInPlace === 'function') window.soonMarkSaveInPlace(openAs.name);
|
||||
if (typeof window.soonToast === 'function') window.soonToast(language_str('saveSucc') + openAs.name, 'success');
|
||||
else layer.msg(language_str('saveSucc') + openAs.name, { shade: 0 });
|
||||
saveHistory();
|
||||
@@ -1357,6 +1359,7 @@ function save(op1, callback) {
|
||||
if (fs) {
|
||||
fs.writeFileSync(fp, content, 'utf8');
|
||||
openAs.name = fp;
|
||||
if (typeof window.soonMarkSaveInPlace === 'function') window.soonMarkSaveInPlace(openAs.name);
|
||||
if (typeof window.soonToast === 'function') window.soonToast(language_str('saveSucc') + openAs.name, 'success');
|
||||
else layer.msg(language_str('saveSucc') + openAs.name, { shade: 0 });
|
||||
saveHistory();
|
||||
@@ -1429,9 +1432,18 @@ function saveHistory() {
|
||||
// 使用 window.openFile 避免与浏览器原生的 window.open 冲突
|
||||
window.openFile = function open(file, jAlready) {
|
||||
if (!file) return;
|
||||
if (typeof window.soonOnOpenDesignFile === 'function') window.soonOnOpenDesignFile(file);
|
||||
if (typeof window.soonBindFileMeta === 'function') window.soonBindFileMeta(file);
|
||||
function doOpenWithJson(j) {
|
||||
if (!j || !background_image) {
|
||||
if (typeof window.soonNormalizeSoonJson === 'function') {
|
||||
j = window.soonNormalizeSoonJson(j);
|
||||
}
|
||||
if (!j) {
|
||||
if (typeof window.soonReportOpenLoadError === 'function') window.soonReportOpenLoadError('模板/文件加载失败');
|
||||
return;
|
||||
}
|
||||
function runOpen() {
|
||||
if (!background_image) {
|
||||
if (typeof window.soonReportOpenLoadError === 'function') window.soonReportOpenLoadError('模板/文件加载失败');
|
||||
return;
|
||||
}
|
||||
@@ -1636,6 +1648,14 @@ window.openFile = function open(file, jAlready) {
|
||||
canvas2Loaded = true
|
||||
saveInitialState()
|
||||
})
|
||||
}
|
||||
if (typeof window.soonRunWhenDesignBgReady === 'function') {
|
||||
window.soonRunWhenDesignBgReady(runOpen, function () {
|
||||
if (typeof window.soonReportOpenLoadError === 'function') window.soonReportOpenLoadError('模板/文件加载失败');
|
||||
});
|
||||
} else {
|
||||
runOpen();
|
||||
}
|
||||
}
|
||||
if (arguments.length >= 2 && jAlready) {
|
||||
doOpenWithJson(jAlready);
|
||||
|
||||
Reference in New Issue
Block a user