Commit ee2ae62f by Sixong.Zhu

eventhub导入

parent f4b0a55e
......@@ -244,7 +244,7 @@ export default class ModelChatList extends Vue {
this.listName === "group_receiving" ||
this.listName === "group_wait"
) {
this.$eventHub.$on(EVENTS.ChatUpdate, this.refreshListDebounce);
xim.$on(EVENTS.ChatUpdate, this.refreshListDebounce);
}
}
......@@ -267,7 +267,7 @@ export default class ModelChatList extends Vue {
this.listName === "group_before_handle" &&
e.dataUpdates.findIndex((it) => it.action === "sendMsg") > -1
) {
this.$eventHub.$emit(EVENTS.ChatUpdate);
xim.$emit(EVENTS.ChatUpdate);
}
this.refreshListDebounce();
}
......
......@@ -59,8 +59,9 @@ import Controller from "./controller/chat-list";
import { EVENTS } from "@/EventConsts";
import avatar from "@/customer-service/components/avatar.vue";
import { ChatStore } from "@/customer-service/store/model";
import { Chat as ChatType } from "@/customer-service/xim/models/chat";
import { ServiceType } from "../model";
import xim from "@/customer-service/xim";
@Component({ components: { avatar } })
export default class ChatList extends Controller {
......@@ -85,7 +86,7 @@ export default class ChatList extends Controller {
});
this.unReadMsgCount = unReadMsgCount;
this.$emit("list-count-update", this.unReadMsgCount);
this.$eventHub.$emit(EVENTS.NewMsg, this.unReadMsgCount);
xim.$emit(EVENTS.NewMsg, this.unReadMsgCount);
return list;
}
return [];
......@@ -100,7 +101,7 @@ export default class ChatList extends Controller {
async created() {
await this.getMyChatList();
this.setSource(ChatStore.StateChatSourceDirection.Server);
this.setSource(ServiceType.Backend);
this.scrollbar.update();
}
......
......@@ -122,7 +122,7 @@ export default class ChatModelDetail extends Vue {
}
if (!authed) {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "authors_list",
params: {
actionName: actionParams.action_name,
......@@ -135,7 +135,7 @@ export default class ChatModelDetail extends Vue {
if (container === "page") {
this.$message.warning("该类型操作暂不支持");
} else if (container === "dialog" || container === "none") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_executor_dialog",
params: {
autoSubmit: container === "none",
......@@ -154,7 +154,7 @@ export default class ChatModelDetail extends Vue {
},
});
} else if (container === "batch") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_execute_batch",
params: {
model_name: this.model_name,
......@@ -165,7 +165,7 @@ export default class ChatModelDetail extends Vue {
},
});
} else if (container === "detail_dialog") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_detail_dialog",
params: {
forward: forward,
......@@ -183,7 +183,7 @@ export default class ChatModelDetail extends Vue {
forward.replace(/^\//, "");
}
}
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_iframe_dialog",
params: {
title: "",
......@@ -193,7 +193,7 @@ export default class ChatModelDetail extends Vue {
},
});
} else if (container === "startProcess") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "start_process_dialog",
params: {
autoSubmit: container === "none",
......
......@@ -93,8 +93,8 @@ export default class WorkFlow extends Vue {
})
private readonly name!: string;
private processName = ""
private selectedProcess = []
private processName = "";
private selectedProcess = [];
private startDialogConfirm() {
console.log("startDialogConfirm");
......@@ -108,7 +108,10 @@ export default class WorkFlow extends Vue {
private flowList = [];
public async created() {
this.flowList = await sdk().model(this.model_name).workflow2().queryProcessByAssociateId(+this.id);
this.flowList = await sdk()
.model(this.model_name)
.workflow2()
.queryProcessByAssociateId(+this.id);
}
public start(workflow: any) {
......@@ -118,7 +121,7 @@ export default class WorkFlow extends Vue {
}
public goToDetail(workflow: any) {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
Chat.$emit(EVENTS.ShowModalDialog, {
dialogName: "show_process_detail",
params: {
modelName: this.model_name,
......
......@@ -62,6 +62,8 @@ export interface ChatOption {
* 用于标记会话启动是在客户端(用户)还是服务端(后端)
*/
serviceType?: ServiceType;
eventHub?: Vue;
}
export interface ChatServiceLogger {
......
......@@ -19,12 +19,11 @@ class Chat {
private token!: TokenStringGetter;
private serviceType = ServiceType.Backend;
private product = CustomerServiceProduct.Default;
private eventHub: Vue | null = null;
private userMapping: { [key: string]: { name: string; avatar: string } } =
{};
private webHost = false;
public async setup(option: ChatOption) {
if (!option) {
throw new Error(`You must specify a chat option for chat service`);
......@@ -39,6 +38,7 @@ class Chat {
this._orgId = option.orgId;
option.serviceType && (this.serviceType = option.serviceType);
option.product && (this.product = option.product);
this.eventHub = option.eventHub;
dbController.setup(this._sdk().global.uid);
......@@ -77,10 +77,6 @@ class Chat {
return this._orgId();
};
public isWebHost() {
return this.webHost;
}
public setToken(token: TokenStringGetter) {
return xim.setToken(token);
}
......@@ -125,6 +121,18 @@ class Chat {
private debug(message: string) {
ChatLoggerService.logger?.debug(message);
}
public $emit(event: string, ...args: any[]) {
if (this.eventHub) {
this.eventHub.$emit(event, ...args);
}
}
public $on(event: string, callback: Function) {
if (this.eventHub) {
this.eventHub.$on(event, callback);
}
}
}
export default new Chat();
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