修复: 本地存储写满静默丢数据——失败告警 + 导入图片体积闸门
This commit is contained in:
@@ -149,6 +149,18 @@ function doImport() {
|
||||
let insertedImages = 0
|
||||
let insertedSlides = 0
|
||||
|
||||
// 图片体积闸门:localStorage 约 5MB 字符上限,超限导入后刷新会丢图
|
||||
if (images.length > 0) {
|
||||
const imgChars = images.reduce((s, e) => s + (e.data?.length || 0), 0)
|
||||
let deckChars = 0
|
||||
try { deckChars = JSON.stringify(store.getDeck()).length } catch (e) { /* ignore */ }
|
||||
const QUOTA_CHARS = 4_500_000
|
||||
if (deckChars + imgChars > QUOTA_CHARS) {
|
||||
emit('toast', '图片过大:导入后约 ' + ((deckChars + imgChars) / 1048576).toFixed(1) + 'MB,超本地存储上限(约 5MB),刷新可能丢失。请压缩图片、减少数量,或先清理文库/旧图')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 图片 → 当前幻灯片
|
||||
if (images.length > 0) {
|
||||
if (images.length === 1) {
|
||||
|
||||
Reference in New Issue
Block a user