Skip to content

Commit

Permalink
refactor(local storage): change method
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenZhang committed Jan 2, 2025
1 parent c3ca3e0 commit 9c73299
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
</script>
Expand Down
16 changes: 8 additions & 8 deletions src/views/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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
Expand All @@ -214,7 +214,7 @@ const doHistorySync = async () => {
}
if (syncFinished) {
historySyncStartTime.value = syncTime;
localStorage.setItem(
setLocalStorage(
historySyncStartTimeKey,
JSON.stringify(historySyncStartTime.value),
);
Expand Down

0 comments on commit 9c73299

Please sign in to comment.