refactor: add more Typescript code
This commit is contained in:
@@ -11,6 +11,7 @@ import { onMessageSendStarted } from "./handlers";
|
|||||||
import handleChatMessage from "../../common/hook/useStreaming/chat.handler";
|
import handleChatMessage from "../../common/hook/useStreaming/chat.handler";
|
||||||
import { Channel, CreateChannelDTO } from "../../types/channel";
|
import { Channel, CreateChannelDTO } from "../../types/channel";
|
||||||
import { RootState } from "../store";
|
import { RootState } from "../store";
|
||||||
|
import { ContentTypeKey } from "../../types/message";
|
||||||
export const channelApi = createApi({
|
export const channelApi = createApi({
|
||||||
reducerPath: "channelApi",
|
reducerPath: "channelApi",
|
||||||
baseQuery,
|
baseQuery,
|
||||||
@@ -118,8 +119,18 @@ export const channelApi = createApi({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
sendChannelMsg: builder.mutation({
|
sendChannelMsg: builder.mutation<
|
||||||
query: ({ id, content, type = "text", properties = "" }) => ({
|
number,
|
||||||
|
{
|
||||||
|
id: number;
|
||||||
|
content: string | object;
|
||||||
|
type: ContentTypeKey;
|
||||||
|
properties?: object;
|
||||||
|
from_uid: number;
|
||||||
|
ignoreLocal: boolean;
|
||||||
|
}
|
||||||
|
>({
|
||||||
|
query: ({ id, content, type = "text", properties = {} }) => ({
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": ContentTypes[type],
|
"content-type": ContentTypes[type],
|
||||||
"X-Properties": properties
|
"X-Properties": properties
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ContentTypes } from "../config";
|
|||||||
import { addChannelMsg, removeChannelMsg } from "../slices/message.channel";
|
import { addChannelMsg, removeChannelMsg } from "../slices/message.channel";
|
||||||
import { addUserMsg, removeUserMsg } from "../slices/message.user";
|
import { addUserMsg, removeUserMsg } from "../slices/message.user";
|
||||||
import { addMessage, removeMessage } from "../slices/message";
|
import { addMessage, removeMessage } from "../slices/message";
|
||||||
|
// import { ContentType } from "../../types/message";
|
||||||
|
|
||||||
export const onMessageSendStarted = async (
|
export const onMessageSendStarted = async (
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//call `group` in backend
|
||||||
import { ContentType } from "./message";
|
import { ContentType } from "./message";
|
||||||
export interface ChannelMember {}
|
export interface ChannelMember {}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export type ContentType = "text/plain" | "text/markdown" | "vocechat/file" | "vocechat/archive";
|
export type ContentType = "text/plain" | "text/markdown" | "vocechat/file" | "vocechat/archive";
|
||||||
|
export type ContentTypeKey = "text" | "markdown" | "file" | "archive";
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
export interface ArchiveUser {
|
||||||
|
name: string;
|
||||||
|
avatar?: number;
|
||||||
|
}
|
||||||
|
export interface ArchiveMessage {
|
||||||
|
from_user: number;
|
||||||
|
created_at: number;
|
||||||
|
mid: number;
|
||||||
|
source: { uid: number } | { gid: number };
|
||||||
|
properties?: object;
|
||||||
|
content_type: string;
|
||||||
|
content?: string;
|
||||||
|
file_id?: number;
|
||||||
|
thumbnail_id?: number;
|
||||||
|
}
|
||||||
|
export interface Archive {
|
||||||
|
users: ArchiveUser[];
|
||||||
|
messages: ArchiveMessage[];
|
||||||
|
num_attachments: number;
|
||||||
|
}
|
||||||
|
// 上传文件API响应
|
||||||
|
export interface UploadResponse {
|
||||||
|
path: string;
|
||||||
|
size: number;
|
||||||
|
hash: string;
|
||||||
|
image_properties?: {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// call `organization` in backend
|
||||||
import { User } from "./auth";
|
import { User } from "./auth";
|
||||||
|
|
||||||
export interface Server {
|
export interface Server {
|
||||||
|
|||||||
Reference in New Issue
Block a user