|
|
@ -30,38 +30,20 @@ export async function getDocs(): Promise<Doc[] | null> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function getLocalApiKey(): Promise<string | null> {
|
|
|
|
export function getLocalApiKey(): string | null {
|
|
|
|
try {
|
|
|
|
|
|
|
|
const key = localStorage.getItem('DocsGPTApiKey');
|
|
|
|
const key = localStorage.getItem('DocsGPTApiKey');
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function getLocalRecentDocs(): Promise<string | null> {
|
|
|
|
export function getLocalRecentDocs(): string | null {
|
|
|
|
try {
|
|
|
|
|
|
|
|
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
|
|
|
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
|
|
|
return doc;
|
|
|
|
return doc;
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function setLocalApiKey(key: string): Promise<void> {
|
|
|
|
export function setLocalApiKey(key: string): void {
|
|
|
|
try {
|
|
|
|
|
|
|
|
localStorage.setItem('DocsGPTApiKey', key);
|
|
|
|
localStorage.setItem('DocsGPTApiKey', key);
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function setLocalRecentDocs(doc: Doc): Promise<void> {
|
|
|
|
export function setLocalRecentDocs(doc: Doc): void {
|
|
|
|
try {
|
|
|
|
|
|
|
|
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
|
|
|
|
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|