diff --git a/src/App.vue b/src/App.vue index 6cef945..402edeb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -205,7 +205,7 @@ if (useDarkTheme.value) { document.body.removeAttribute('arco-theme'); } const changeTheme = (theme) => { - localStorage.setItem(themeKey, JSON.stringify(theme)); + setLocalStorage(themeKey, JSON.stringify(theme)); window.location.reload(); }; diff --git a/src/views/Chat.vue b/src/views/Chat.vue index bfb1a2e..599f67c 100644 --- a/src/views/Chat.vue +++ b/src/views/Chat.vue @@ -156,16 +156,16 @@ const showHistorySyncConfig = () => { }; const enableHistorySync = () => { historySync.value = true; - localStorage.setItem(historySyncKey, JSON.stringify(historySync.value)); - localStorage.setItem(historySyncEncryptKey, JSON.stringify(historySyncEncrypt.value)); + setLocalStorage(historySyncKey, JSON.stringify(historySync.value)); + setLocalStorage(historySyncEncryptKey, JSON.stringify(historySyncEncrypt.value)); historySyncConfigVisible.value = false; historySyncEncryptObj.value = new Encryption(historySyncEncrypt.value); doHistorySync(); }; const disableHistorySync = () => { historySync.value = false; - localStorage.setItem(historySyncKey, JSON.stringify(historySync.value)); - localStorage.setItem(historySyncEncryptKey, JSON.stringify(historySyncEncrypt.value)); + setLocalStorage(historySyncKey, JSON.stringify(historySync.value)); + setLocalStorage(historySyncEncryptKey, JSON.stringify(historySyncEncrypt.value)); historySyncConfigVisible.value = false; }; const doHistorySync = async () => { @@ -187,13 +187,13 @@ const doHistorySync = async () => { if (currentMessageID.value === item.message_id) { if (!chatLoading.value) { localMessages.value = messages; - localStorage.setItem(item.message_id, JSON.stringify(messages)); + setLocalStorage(item.message_id, JSON.stringify(messages)); } } else { const createdAt = item.message_id.split('-')[2]; localMessageStore.value[item.message_id] = {'created_at': createdAt, 'title': messages[0].content}; - localStorage.setItem(localMessageStoreKey, JSON.stringify(localMessageStore.value)); - localStorage.setItem(item.message_id, JSON.stringify(messages)); + setLocalStorage(localMessageStoreKey, JSON.stringify(localMessageStore.value)); + setLocalStorage(item.message_id, JSON.stringify(messages)); } } // delete message @@ -214,7 +214,7 @@ const doHistorySync = async () => { } if (syncFinished) { historySyncStartTime.value = syncTime; - localStorage.setItem( + setLocalStorage( historySyncStartTimeKey, JSON.stringify(historySyncStartTime.value), );