feat: server update message in SSE
This commit is contained in:
@@ -109,6 +109,7 @@ export const ChatPrefixes = {
|
||||
};
|
||||
export const vapidKey = `BOmzyZhw-DcIGYQ77mzQUVqLlcvn0bm_76P_kc7rpwRxzXNbui-JP8iPyEQYfyoxyJeq43Ud4IiIsJSMNHNujn0`;
|
||||
export const tokenHeader = "X-API-Key";
|
||||
export const KEY_SERVER_VERSION = "VC_SERVER_VERSION"; //
|
||||
export const FILE_SLICE_SIZE = 1000 * 1000; //
|
||||
export const FILE_IMAGE_SIZE = 1000 * 10000 * 8; //10mb
|
||||
export const KEY_MOBILE_APP_TIP = "MOBILE_APP_TIP";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
import { unescape } from "lodash";
|
||||
|
||||
import { ChatContext } from "@/types/common";
|
||||
import { ChatMessage, ContentTypeKey, UploadFileResponse } from "@/types/message";
|
||||
|
||||
@@ -21,7 +21,13 @@ import {
|
||||
TestEmailDTO
|
||||
} from "@/types/server";
|
||||
import { User } from "@/types/user";
|
||||
import BASE_URL, { ContentTypes, IS_OFFICIAL_DEMO, PAYMENT_URL_PREFIX } from "../config";
|
||||
import { compareVersion } from "@/utils";
|
||||
import BASE_URL, {
|
||||
ContentTypes,
|
||||
IS_OFFICIAL_DEMO,
|
||||
KEY_SERVER_VERSION,
|
||||
PAYMENT_URL_PREFIX
|
||||
} from "../config";
|
||||
import { updateInfo } from "../slices/server";
|
||||
import { updateCallInfo, upsertVoiceList } from "../slices/voice";
|
||||
import { RootState } from "../store";
|
||||
@@ -68,6 +74,7 @@ export const serverApi = createApi({
|
||||
async onQueryStarted(data, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const resp = await queryFulfilled;
|
||||
localStorage.setItem(KEY_SERVER_VERSION, resp.data);
|
||||
dispatch(updateInfo({ version: resp.data }));
|
||||
} catch {
|
||||
console.error("get server version error");
|
||||
@@ -260,10 +267,13 @@ export const serverApi = createApi({
|
||||
}
|
||||
}
|
||||
}),
|
||||
updateServer: builder.mutation<void, Server>({
|
||||
updateServer: builder.mutation<void, Partial<Server>>({
|
||||
query: (data) => ({
|
||||
url: "admin/system/organization",
|
||||
method: "POST",
|
||||
method:
|
||||
compareVersion(localStorage.getItem(KEY_SERVER_VERSION) ?? "", "0.3.7") > 0
|
||||
? "PUT"
|
||||
: "POST",
|
||||
body: data
|
||||
}),
|
||||
async onQueryStarted(data, { dispatch, queryFulfilled, getState }) {
|
||||
|
||||
Reference in New Issue
Block a user