From 0760410937696e4fac512f70b3f4a0037f19ef6f Mon Sep 17 00:00:00 2001 From: x3zvawq Date: Tue, 14 May 2024 12:48:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(storage):=20sessionStorage=E5=86=99?= =?UTF-8?q?=E5=85=A5=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d415a3f..6c6a148 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,12 @@ async function loadEmotionList() { // 尝试从sessionStorage中获取其他页面的缓存 const emotion = sessionStorage.getItem("jx3_emotion"); if (emotion) { + const emotions = JSON.parse(emotion); + emotionList.push( + ...emotions + .map(item => item.items) + .reduce((a, b) => a.concat(b), []) + ); emotionList.push(...JSON.parse(emotion)); } else { const data = await fetch( @@ -36,7 +42,7 @@ async function loadEmotionList() { emotionList.push( ...data.map(item => item.items).reduce((a, b) => a.concat(b), []) ); - sessionStorage.setItem("jx3_emotion", JSON.stringify(emotionList)); + sessionStorage.setItem("jx3_emotion", JSON.stringify(data)); } // 通知等待队列里面的有数据了 loading = false; diff --git a/package.json b/package.json index b88dc61..4e43710 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jx3box/jx3box-emotion", - "version": "1.2.7", + "version": "1.2.8", "description": "通用表情插入与渲染模块", "main": "index.js", "repository": {