Skip to content

Commit

Permalink
fix(storage): sessionStorage写入内容格式修复
Browse files Browse the repository at this point in the history
  • Loading branch information
X3ZvaWQ committed May 14, 2024
1 parent 4443917 commit 0760410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jx3box/jx3box-emotion",
"version": "1.2.7",
"version": "1.2.8",
"description": "通用表情插入与渲染模块",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 0760410

Please sign in to comment.