refactor: user v1 store (#2047)

This commit is contained in:
boojack
2023-07-29 18:57:09 +08:00
committed by GitHub
parent f5793c142c
commit a6a1898c41
17 changed files with 97 additions and 46 deletions

View File

@ -1,6 +1,4 @@
import axios from "axios";
import { fetchEventSource } from "@microsoft/fetch-event-source";
import { Message } from "@/store/zustand/message";
export function getSystemStatus() {
return axios.get<SystemStatus>("/api/v1/status");
@ -139,32 +137,11 @@ export function unpinMemo(memoId: MemoId) {
export function deleteMemo(memoId: MemoId) {
return axios.delete(`/api/v1/memo/${memoId}`);
}
export function checkOpenAIEnabled() {
return axios.get<boolean>(`/api/openai/enabled`);
}
export async function chatStreaming(messageList: Array<Message>, onmessage: any, onclose: any) {
await fetchEventSource("/api/v1/openai/chat-streaming", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(messageList),
async onopen() {
// to do nth
},
onmessage(event: any) {
onmessage(event);
},
onclose() {
onclose();
},
onerror(error: any) {
console.log("error", error);
},
});
}
export function getShortcutList(shortcutFind?: ShortcutFind) {
const queryList = [];
if (shortcutFind?.creatorUsername) {