mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-01 14:52:48 +08:00
feat(phoneimage): 接入保存/配置/历史操作日志并移除layer.load遮罩
This commit is contained in:
@@ -337,6 +337,7 @@
|
||||
if (arr == null || arr.length == 0) {
|
||||
return true;
|
||||
}
|
||||
PhoneImageLogPanel.log('粘贴图片处理中...', 'info');
|
||||
layer.load();
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var src = arr[i].match(srcReg);
|
||||
@@ -372,6 +373,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
PhoneImageLogPanel.log('粘贴图片处理完成', 'success');
|
||||
layer.closeAll('loading');
|
||||
editor.dangerouslyInsertHtml(pasteStr);
|
||||
event.preventDefault();
|
||||
@@ -425,6 +427,7 @@
|
||||
// 松手后: 触发完整渲染(重新分页 + html2canvas截图)
|
||||
$slider.on('change', function() {
|
||||
var val = parseFloat($(this).val());
|
||||
PhoneImageLogPanel.log('字号调整为 ' + val.toFixed(1) + 'x', 'info');
|
||||
doRender({ fontScale: val });
|
||||
// 触发保存,确保字号倍数持久化
|
||||
updateSaveState('saving');
|
||||
@@ -435,8 +438,10 @@
|
||||
content_html: PhoneImageEngine.getContentHtml()
|
||||
}, saveConfigUrl).then(function(data) {
|
||||
if (data.output_id) lastOutputId = data.output_id;
|
||||
PhoneImageLogPanel.log('字号配置已保存', 'success');
|
||||
updateSaveState('saved');
|
||||
}).catch(function(err) {
|
||||
PhoneImageLogPanel.log('字号保存失败: ' + err, 'error');
|
||||
updateSaveState('error');
|
||||
});
|
||||
});
|
||||
@@ -482,6 +487,7 @@
|
||||
currentConfig.size = layero.find('[name="s_size"]').val();
|
||||
currentConfig.watermark = layero.find('[name="s_watermark"]').val();
|
||||
layer.close(index);
|
||||
PhoneImageLogPanel.log('应用新设置: 尺寸=' + currentConfig.size, 'info');
|
||||
doRender();
|
||||
}
|
||||
});
|
||||
@@ -561,6 +567,7 @@
|
||||
if (autoSaveLock) {
|
||||
autoSaveLock = false;
|
||||
updateSaveState('saving');
|
||||
PhoneImageLogPanel.log('自动保存中...', 'info');
|
||||
PhoneImageEngine.saveConfig(postData.postId, {
|
||||
size: currentConfig.size,
|
||||
watermark: currentConfig.watermark,
|
||||
@@ -568,8 +575,10 @@
|
||||
content_html: PhoneImageEngine.getContentHtml()
|
||||
}, saveConfigUrl).then(function (data) {
|
||||
if (data.output_id) lastOutputId = data.output_id;
|
||||
PhoneImageLogPanel.log('自动保存完成', 'success');
|
||||
updateSaveState('saved');
|
||||
}).catch(function (err) {
|
||||
PhoneImageLogPanel.log('自动保存失败: ' + err, 'error');
|
||||
updateSaveState('error');
|
||||
});
|
||||
}
|
||||
@@ -585,8 +594,8 @@
|
||||
// 清除自动保存定时器,避免冲突
|
||||
clearTimeout(autoSaveTimer);
|
||||
autoSaveLock = false;
|
||||
layer.msg('保存中...');
|
||||
|
||||
PhoneImageLogPanel.log('保存配置中...', 'info');
|
||||
PhoneImageEngine.saveConfig(postData.postId, {
|
||||
size: currentConfig.size,
|
||||
watermark: currentConfig.watermark,
|
||||
@@ -595,9 +604,11 @@
|
||||
}, saveConfigUrl).then(function (data) {
|
||||
if (data.output_id) lastOutputId = data.output_id;
|
||||
$('#post-content-html').html(PhoneImageEngine.getContentHtml());
|
||||
PhoneImageLogPanel.log('配置保存成功', 'success');
|
||||
layer.msg('保存成功');
|
||||
updateSaveState('saved');
|
||||
}).catch(function (err) {
|
||||
PhoneImageLogPanel.log('保存失败: ' + err, 'error');
|
||||
layer.msg('保存失败: ' + err);
|
||||
updateSaveState('error');
|
||||
}).always(function () {
|
||||
@@ -609,21 +620,27 @@
|
||||
$('#btn-generate').click(function () {
|
||||
var btn = $(this);
|
||||
btn.prop('disabled', true).html('<i class="layui-icon layui-icon-picture"></i> 生成中...');
|
||||
layer.msg('正在生成图片,请稍候...');
|
||||
|
||||
PhoneImageLogPanel.log('开始生成图片...', 'info');
|
||||
PhoneImageEngine.saveImages(postData.postId, {
|
||||
size: currentConfig.size,
|
||||
watermark: currentConfig.watermark,
|
||||
fontScale: currentConfig.fontScale || 1,
|
||||
content_html: PhoneImageEngine.getContentHtml()
|
||||
}, function(current, total, canvas) {
|
||||
if (total > 0) {
|
||||
PhoneImageLogPanel.log('截图: 第 ' + current + '/' + total + ' 页', 'info');
|
||||
}
|
||||
}).then(function (data) {
|
||||
if (data.output_id) {
|
||||
lastOutputId = data.output_id;
|
||||
}
|
||||
$('#post-content-html').html(PhoneImageEngine.getContentHtml());
|
||||
PhoneImageLogPanel.log('图片生成并保存成功 (output_id: ' + data.output_id + ')', 'success');
|
||||
layer.msg('保存成功!');
|
||||
btn.prop('disabled', false).html('<i class="layui-icon layui-icon-picture"></i> 生成并保存');
|
||||
}).catch(function (err) {
|
||||
PhoneImageLogPanel.log('保存失败: ' + err, 'error');
|
||||
layer.msg('保存失败: ' + err);
|
||||
btn.prop('disabled', false).html('<i class="layui-icon layui-icon-picture"></i> 生成并保存');
|
||||
});
|
||||
@@ -634,10 +651,10 @@
|
||||
$('body').append(historyBtn);
|
||||
|
||||
historyBtn.on('click', function () {
|
||||
var loadIdx = layer.load();
|
||||
PhoneImageLogPanel.log('获取历史记录...', 'info');
|
||||
$.get(historyListUrl, function (res) {
|
||||
layer.close(loadIdx);
|
||||
if (res.code !== 0 || !res.data || res.data.length === 0) {
|
||||
PhoneImageLogPanel.log('暂无历史记录', 'warn');
|
||||
layer.msg('暂无历史记录');
|
||||
return;
|
||||
}
|
||||
@@ -674,15 +691,14 @@
|
||||
}
|
||||
});
|
||||
}).fail(function () {
|
||||
layer.close(loadIdx);
|
||||
PhoneImageLogPanel.log('获取历史记录失败', 'error');
|
||||
layer.msg('获取历史记录失败');
|
||||
});
|
||||
});
|
||||
|
||||
function loadFromHistory(outputId) {
|
||||
var loadIdx2 = layer.load();
|
||||
PhoneImageLogPanel.log('加载历史记录配置...', 'info');
|
||||
$.get(loadConfigUrl + '?id=' + outputId, function (res) {
|
||||
layer.close(loadIdx2);
|
||||
if (res.code !== 0 || !res.data) {
|
||||
layer.msg('加载失败: ' + (res.msg || '未知错误'));
|
||||
return;
|
||||
@@ -712,20 +728,20 @@
|
||||
}
|
||||
|
||||
lastOutputId = outputId;
|
||||
PhoneImageLogPanel.log('历史配置已加载', 'success');
|
||||
layer.closeAll();
|
||||
|
||||
// 更新引擎配置并重新渲染
|
||||
PhoneImageEngine.updateConfig(historyConfig);
|
||||
var loadIdx3 = layer.load();
|
||||
PhoneImageEngine.render().then(function (pages) {
|
||||
layer.close(loadIdx3);
|
||||
PhoneImageLogPanel.log('历史渲染完成,共 ' + pages.length + ' 页', 'success');
|
||||
layer.msg('已加载历史配置,共 ' + pages.length + ' 页');
|
||||
}).catch(function (err) {
|
||||
layer.close(loadIdx3);
|
||||
PhoneImageLogPanel.log('历史渲染失败: ' + err, 'error');
|
||||
if (err !== 'rendering') layer.msg('渲染失败: ' + err);
|
||||
});
|
||||
}).fail(function () {
|
||||
layer.close(loadIdx2);
|
||||
PhoneImageLogPanel.log('加载历史配置失败', 'error');
|
||||
layer.msg('加载历史配置失败');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user