Update authorization&cartId.js
This commit is contained in:
@@ -99,6 +99,13 @@ function appendHistory(entry) {
|
|||||||
if (Array.isArray(parsed)) history = parsed;
|
if (Array.isArray(parsed)) history = parsed;
|
||||||
} catch (e) { history = []; }
|
} catch (e) { history = []; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 去重:相同 cartId 的记录不重复写入
|
||||||
|
if (history.some(h => h.cartId === entry.cartId)) {
|
||||||
|
console.log(`[history] SKIP: cartId=${entry.cartId} 已存在于历史中`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
history.push(entry);
|
history.push(entry);
|
||||||
if (history.length > MAX_HISTORY) history = history.slice(-MAX_HISTORY);
|
if (history.length > MAX_HISTORY) history = history.slice(-MAX_HISTORY);
|
||||||
$persistentStore.write(JSON.stringify(history), "cartId_history");
|
$persistentStore.write(JSON.stringify(history), "cartId_history");
|
||||||
|
|||||||
Reference in New Issue
Block a user