mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-22 05:35:48 +08:00
🚸 降低请求次数
This commit is contained in:
@@ -64,6 +64,9 @@ onMounted(async () => await displayBox(props));
|
|||||||
|
|
||||||
async function getRandomEmoji(): Promise<void> {
|
async function getRandomEmoji(): Promise<void> {
|
||||||
if (localEmojis.value.length === 0) {
|
if (localEmojis.value.length === 0) {
|
||||||
|
const emojisRead = localStorage.getItem("emojis");
|
||||||
|
if (emojisRead) localEmojis.value = Object.values(JSON.parse(emojisRead));
|
||||||
|
else {
|
||||||
const resp = await bbsReq.emojis();
|
const resp = await bbsReq.emojis();
|
||||||
if ("retcode" in resp) {
|
if ("retcode" in resp) {
|
||||||
console.error(resp);
|
console.error(resp);
|
||||||
@@ -74,6 +77,7 @@ async function getRandomEmoji(): Promise<void> {
|
|||||||
localEmojis.value = Object.values(resp);
|
localEmojis.value = Object.values(resp);
|
||||||
localStorage.setItem("emojis", JSON.stringify(resp));
|
localStorage.setItem("emojis", JSON.stringify(resp));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
iconUrl.value = localEmojis.value[Math.floor(Math.random() * localEmojis.value.length)];
|
iconUrl.value = localEmojis.value[Math.floor(Math.random() * localEmojis.value.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user