Web 端本地缓存、首页与会员弹窗体验优化
新增 IndexedDB 与最近文件 L1 缓存、云保存/打开链路;首页支持下载与清空本地缓存;修复清空 storage 后语言初始化报错;优化 design2 背景加载与侧栏标签样式;完善会员激活/支付弹层样式;后端补充文件缩略图字段与 thumb 接口。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -150,6 +150,7 @@ function applySysLan(data) {
|
||||
localStorage.setItem("lang", "zh");
|
||||
break;
|
||||
case 'zh-TW':
|
||||
case 'ozh':
|
||||
s_lan = "ozh";
|
||||
// 同步到全局作用域(用于 .jsc 文件加载)
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -375,64 +376,73 @@ window.rotate = function (id) {
|
||||
$(`#${id}`).attr("angle", angle);
|
||||
}
|
||||
|
||||
function soonPlaceBgOnCanvas(image, canvasSelector) {
|
||||
var cw = $(canvasSelector).width() || (document.querySelector(canvasSelector) && document.querySelector(canvasSelector).clientWidth) || 800;
|
||||
var ch = $(canvasSelector).height() || (document.querySelector(canvasSelector) && document.querySelector(canvasSelector).clientHeight) || 600;
|
||||
image.left = (cw - image.width * image.get("scaleX")) / 2;
|
||||
image.top = (ch - image.height * image.get("scaleY")) / 2;
|
||||
image.selectable = false;
|
||||
image.hoverable = false;
|
||||
image.hoverCursor = "default";
|
||||
}
|
||||
|
||||
function soonOpenPendingDesignFile() {
|
||||
var file = typeof window.soonResolveOpenFileKey === 'function'
|
||||
? window.soonResolveOpenFileKey(GetFile)
|
||||
: (GetFile().get('file') || '');
|
||||
if (file && file != 'empty') {
|
||||
if (typeof window.soonConsumeOpenMeta === 'function') {
|
||||
window.soonConsumeOpenMeta(file);
|
||||
}
|
||||
window.openFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
function addBackground() {
|
||||
// 类型改变
|
||||
fabric.Image.fromURL(soonAsset('bg_front_1.png'), function (image) {
|
||||
let width = $("#canvas1").width()
|
||||
if (is_bgi_add || window.is_bgi_add) return;
|
||||
var loadBg = typeof window.soonFabricImageFromAsset === 'function'
|
||||
? window.soonFabricImageFromAsset
|
||||
: null;
|
||||
var whenReady = typeof window.soonRunWhenCanvasReady === 'function'
|
||||
? window.soonRunWhenCanvasReady
|
||||
: function (_sel, fn) { fn(); };
|
||||
|
||||
image.left = ($("#canvas1").width() - image.width * image.get("scaleX")) / 2;
|
||||
image.top = ($("#canvas1").height() - image.height * image.get("scaleY")) / 2;
|
||||
function finishBack(backImg) {
|
||||
if (backImg) {
|
||||
soonPlaceBgOnCanvas(backImg, '#canvas2');
|
||||
background_image2 = backImg;
|
||||
window.background_image2 = backImg;
|
||||
canvas2.add(backImg);
|
||||
canvas2.renderAll();
|
||||
recordObjs2.push(JSON.stringify(objs2));
|
||||
recordJson2.push(canvas2.toJSON(TO_JSON_PROPERTIES));
|
||||
}
|
||||
is_bgi_add = true;
|
||||
window.is_bgi_add = true;
|
||||
soonOpenPendingDesignFile();
|
||||
}
|
||||
|
||||
image.selectable = false;
|
||||
image.hoverable = false;
|
||||
image.hoverCursor = "default"
|
||||
image.setSrc(image.toDataURL(), function (image) {
|
||||
image.scale(1, 1);
|
||||
background_image1 = image;
|
||||
background_image = background_image1;
|
||||
window.background_image1 = background_image1;
|
||||
window.background_image = background_image;
|
||||
canvas.add(image);
|
||||
function startLoad() {
|
||||
if (!loadBg) return;
|
||||
loadBg('bg_front_1.png', function (frontImg) {
|
||||
if (!frontImg) return;
|
||||
frontImg.scale(1, 1);
|
||||
soonPlaceBgOnCanvas(frontImg, '#canvas1');
|
||||
background_image1 = frontImg;
|
||||
background_image = frontImg;
|
||||
window.background_image1 = frontImg;
|
||||
window.background_image = frontImg;
|
||||
canvas.add(frontImg);
|
||||
canvas.renderAll();
|
||||
//pre_objs1.push(JSON.stringify(objs1));
|
||||
//pre_json1.push(canvas1.toJSON(["selectable","hoverable","hoverCursor"]));
|
||||
|
||||
recordObjs1.push(JSON.stringify(objs1));
|
||||
recordJson1.push(canvas1.toJSON(TO_JSON_PROPERTIES));
|
||||
loadBg('bg_back.png', finishBack, function () { loadBg('bg_back.png', finishBack); });
|
||||
}, function () {
|
||||
setTimeout(startLoad, 200);
|
||||
});
|
||||
// 类型改变
|
||||
fabric.Image.fromURL(soonAsset('bg_back.png'), function (image) {
|
||||
image.left = ($("#canvas2").width() - image.width) / 2;
|
||||
image.top = ($("#canvas2").height() - image.height) / 2;
|
||||
}
|
||||
|
||||
image.selectable = false;
|
||||
image.hoverable = false;
|
||||
image.hoverCursor = "default"
|
||||
|
||||
image.setSrc(image.toDataURL(), function (image) {
|
||||
background_image2 = image;
|
||||
window.background_image2 = background_image2;
|
||||
canvas2.add(image);
|
||||
canvas2.renderAll();
|
||||
//pre_objs2.push(JSON.stringify(objs2));
|
||||
//pre_json2.push(canvas2.toJSON(["selectable","hoverable","hoverCursor"]));
|
||||
|
||||
recordObjs2.push(JSON.stringify(objs2));
|
||||
recordJson2.push(canvas2.toJSON(TO_JSON_PROPERTIES));
|
||||
|
||||
var file = typeof window.soonResolveOpenFileKey === 'function'
|
||||
? window.soonResolveOpenFileKey(GetFile)
|
||||
: (GetFile().get('file') || '');
|
||||
if (file && file != 'empty') {
|
||||
if (typeof window.soonConsumeOpenMeta === 'function') {
|
||||
window.soonConsumeOpenMeta(file);
|
||||
}
|
||||
window.openFile(file);
|
||||
}
|
||||
});
|
||||
});
|
||||
is_bgi_add = true;
|
||||
});
|
||||
whenReady('#canvas1', startLoad);
|
||||
}
|
||||
|
||||
// 将 updateControls 附加到 window 对象,确保在 eval() 加载 .jsc 文件时也能访问
|
||||
|
||||
Reference in New Issue
Block a user