mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
Fix
This commit is contained in:
@@ -314,7 +314,7 @@
|
||||
const suggestName = async (): Promise<void> => {
|
||||
const suggestMessage: Message = {
|
||||
role: 'user',
|
||||
content: "Using appropriate language, please tell me a short 6 word summary of this conversation's topic for use as a book title. Only respond with the summary.",
|
||||
content: "Suggest a 6 word summary of this conversation's topic for use as a title of this converstation. Only respond with the 6 word summary.",
|
||||
uuid: uuidv4()
|
||||
}
|
||||
|
||||
@@ -322,7 +322,6 @@
|
||||
suggestMessages.push(suggestMessage)
|
||||
|
||||
const currentModel = chat.settings.model
|
||||
// chat.settings.model = "gpt-4o";
|
||||
|
||||
chatRequest.updating = true
|
||||
chatRequest.updatingMessage = 'Getting suggestion for chat name...'
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
|
||||
let waitingForConfirm:any = 0
|
||||
|
||||
onMount(async () => {
|
||||
if (!chat.name) {
|
||||
chat.name = `Chat ${chat.id}`
|
||||
}
|
||||
})
|
||||
chat = { ...chat }
|
||||
|
||||
const keydown = (event:KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
} from '@fortawesome/free-solid-svg-icons/index'
|
||||
import { faSquareMinus, faSquarePlus as faSquarePlusOutline } from '@fortawesome/free-regular-svg-icons/index'
|
||||
import { addChatFromJSON, chatsStorage, checkStateChange, clearChats, clearMessages, copyChat, globalStorage, setGlobalSettingValueByKey, showSetChatSettings, pinMainMenu, getChat, deleteChat, saveChatStore, saveCustomProfile } from './Storage.svelte'
|
||||
import { getChatSortOption } from './Storage.svelte'
|
||||
import { getChatSortOption, loadLocalStorage, dumpLocalStorage } from './Storage.svelte'
|
||||
import { exportAsMarkdown, exportChatAsJSON } from './Export.svelte'
|
||||
import { newNameForProfile, restartProfile } from './Profiles.svelte'
|
||||
import { replace } from 'svelte-spa-router'
|
||||
@@ -164,73 +164,6 @@
|
||||
reader.readAsText(image)
|
||||
}
|
||||
|
||||
function dumpLocalStorage () {
|
||||
try {
|
||||
const storageObject = {}
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i)
|
||||
if (key) {
|
||||
storageObject[key] = localStorage.getItem(key)
|
||||
}
|
||||
}
|
||||
|
||||
const dataStr = JSON.stringify(storageObject, null, 2)
|
||||
const blob = new Blob([dataStr], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
const now = new Date()
|
||||
const dateTimeStr = now.toISOString().replace(/:\d+\.\d+Z$/, '').replace(/-|:/g, '_')
|
||||
link.download = `ChatGPT-web-${dateTimeStr}.json`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
} catch (error) {
|
||||
console.error('Error dumping localStorage:', error)
|
||||
}
|
||||
}
|
||||
|
||||
function loadLocalStorage () {
|
||||
const fileInput = document.createElement('input')
|
||||
fileInput.type = 'file'
|
||||
fileInput.addEventListener('change', function (e) {
|
||||
const file = e.target.files[0]
|
||||
if (file) {
|
||||
const reader = new FileReader()
|
||||
reader.onload = function (e) {
|
||||
const data = JSON.parse(e.target.result)
|
||||
Object.keys(data).forEach(function (key) {
|
||||
localStorage.setItem(key, data[key])
|
||||
})
|
||||
window.location.reload()
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
})
|
||||
document.body.appendChild(fileInput)
|
||||
fileInput.click()
|
||||
fileInput.remove()
|
||||
}
|
||||
|
||||
function backupLocalStorage () {
|
||||
try {
|
||||
const storageObject = {}
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i)
|
||||
if (key) {
|
||||
storageObject[key] = localStorage.getItem(key)
|
||||
}
|
||||
}
|
||||
const dataStr = JSON.stringify(storageObject, null, 2)
|
||||
const now = new Date()
|
||||
const dateTimeStr = now.toISOString().replace(/:\d+\.\d+Z$/, '').replace(/-|:/g, '_')
|
||||
localStorage.setItem(`prev-${dateTimeStr}`, dataStr)
|
||||
} catch (error) {
|
||||
console.error('Error backing up localStorage:', error)
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="dropdown {style}" class:is-active={showChatMenu} use:clickOutside={() => { showChatMenu = false }}>
|
||||
|
||||
@@ -611,4 +611,56 @@
|
||||
latestModelMap.set(modelMapStore)
|
||||
}
|
||||
|
||||
export const dumpLocalStorage = () => {
|
||||
try {
|
||||
const storageObject: Record<string, string | null> = {};
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
if (key) {
|
||||
storageObject[key] = localStorage.getItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
const dataStr = JSON.stringify(storageObject, null, 2);
|
||||
const blob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
const now = new Date();
|
||||
const dateTimeStr = now.toISOString().replace(/:\d+\.\d+Z$/, '').replace(/-|:/g, '_');
|
||||
link.download = `ChatGPT-web-${dateTimeStr}.json`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (error) {
|
||||
console.error('Error dumping localStorage:', error);
|
||||
}
|
||||
};
|
||||
|
||||
export const loadLocalStorage = () => {
|
||||
const fileInput = document.createElement('input');
|
||||
fileInput.type = 'file';
|
||||
fileInput.addEventListener('change', function (e) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
if (!input.files || input.files.length === 0) return;
|
||||
const file = input.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
if (!e.target) return;
|
||||
const data = JSON.parse(e.target.result as string);
|
||||
Object.keys(data).forEach(function (key) {
|
||||
localStorage.setItem(key, data[key]);
|
||||
});
|
||||
window.location.reload();
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
});
|
||||
document.body.appendChild(fileInput);
|
||||
fileInput.click();
|
||||
document.body.removeChild(fileInput);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user