Commit ae024595 by Sixong.Zhu

update

parent 9aed20af
Showing with 154 additions and 38 deletions
......@@ -63,7 +63,7 @@ class Chat implements ChatMessageController {
option.message && (this.messageController = option.message);
this.setupIndexDb();
await this.setupIndexDb();
this.token = async () => option.sdk().global.jwtToken;
tokenManager.save(this.token);
......@@ -92,7 +92,7 @@ class Chat implements ChatMessageController {
s.global.uid + "-" + (s.global.initData.orgId || 0)
);
}
return Promise.reject(new Error('Sdk is not defined'));
return Promise.reject(new Error("Sdk is not defined"));
}
public resetup(org: () => string | number) {
......
......@@ -7,6 +7,7 @@ import { Message, NotifyMessage } from "./models/chat";
import chat from "./index";
import { STATUS } from "xchat-client/dist/xchat";
import { AxiosInstance } from "axios";
wampDebug(true);
......@@ -203,6 +204,55 @@ export class Xim {
return data;
}
public async queryLastPageMsgWhenNotMember(chatParameter: {
model: string;
obj: string;
}) {
return this.queryMessagesWhenNotMember(chatParameter, 0, 0, 20, 1);
}
public async queryPreviousPageMsgWhenNotMember(
chatParameter: {
model: string;
obj: string;
},
start: number
) {
return this.queryMessagesWhenNotMember(chatParameter, 0, start, 20, 1);
}
public async queryNextPageMsgWhenNotMember(
chatParameter: {
model: string;
obj: string;
},
end: number
) {
return this.queryMessagesWhenNotMember(chatParameter, end, 0, 20, 0);
}
private queryMessagesWhenNotMember(
chatParameter: { model: string; obj: string },
lid: number,
rid: number,
limit: number,
desc: number
) {
const sdk = chat.getSdk();
const query = sdk.getAxios() as AxiosInstance;
const q = [
`lid=${lid}`,
`rid=${rid}`,
`limit=${limit}`,
`desc=${desc}`,
];
return query.get<any, Message[]>(
`${sdk.global.baseUrl}general/xim/model/${chatParameter.model}/${
chatParameter.obj
}/msgs?${q.join("&")}`
);
}
/** 查询上一页消息 */
public async queryPrevPageMsg(
chatType: string,
......@@ -398,7 +448,8 @@ export class Xim {
}
private debug(message: any, ...params: any[]) {
ChatLoggerService.logger && ChatLoggerService.logger.debug(message, params);
ChatLoggerService.logger &&
ChatLoggerService.logger.debug(message, params);
}
public registerOnMessage(vue: Vue, action: (e: Message) => void) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment