Commit c9fc2373 by zhousil
parents d3e1ae90 110d8a6a
import { MessageType } from "@/customer-service/model"; import { MessageType } from "@/customer-service/model";
import { CardMessage } from '@/customer-service/model/card'; import { CardMessage } from "@/customer-service/model/card";
import Chat from "@/customer-service/xim";
const fsImg = /(fs(.*))/;
const mapping = new Map<MessageType, string>([ const mapping = new Map<MessageType, string>([
[MessageType.Image, '图片'], [MessageType.Image, "图片"],
[MessageType.Video, '视频'], [MessageType.Video, "视频"],
[MessageType.Voice, '语音'], [MessageType.Voice, "语音"],
[MessageType.File, '文件'], [MessageType.File, "文件"],
[MessageType.Withdraw, '撤回了一条消息'], [MessageType.Withdraw, "撤回了一条消息"],
[MessageType.MyPurchasePlan, '我的采购计划'], [MessageType.MyPurchasePlan, "我的采购计划"],
[MessageType.MyWelfare, '我的福利'], [MessageType.MyWelfare, "我的福利"],
[MessageType.QuestionAnswer, '问答'], [MessageType.QuestionAnswer, "问答"],
[MessageType.Pay, '付款通知'], [MessageType.Pay, "付款通知"],
[MessageType.PayV1, '付款通知'], [MessageType.PayV1, "付款通知"],
[MessageType.Refund, '退款通知'], [MessageType.Refund, "退款通知"],
[MessageType.RefundV1, '退款通知'], [MessageType.RefundV1, "退款通知"],
[MessageType.Notify, '通知'], [MessageType.Notify, "通知"],
]) ]);
export function parserMessage(type: MessageType, rawMsg: string) { export function parserMessage(type: MessageType, rawMsg: string) {
try { try {
...@@ -35,15 +38,30 @@ export function parserMessage(type: MessageType, rawMsg: string) { ...@@ -35,15 +38,30 @@ export function parserMessage(type: MessageType, rawMsg: string) {
if (type === MessageType.Card) { if (type === MessageType.Card) {
const p = JSON.parse(rawMsg) as CardMessage; const p = JSON.parse(rawMsg) as CardMessage;
if (p && p.title) { if (p && p.title) {
return p.title || '通知'; return p.title || "通知";
} }
} }
const t = mapping.get(type) const t = mapping.get(type);
if (t) { if (t) {
return `[${t}]`; return `[${t}]`;
} }
return `[系统自动回复]`; return `[系统自动回复]`;
} catch { } catch {
return "" return "";
}
}
export function rebuildImage(url: string) {
if (url) {
const sdk = Chat.getSdk();
const s = sdk.mediaController.buildThumbnail;
if (fsImg.test(url)) {
const m = fsImg.exec(url);
if (m && m.length) {
return sdk.global.baseUrl + s(m[0], 300);
}
}
return url;
} }
return "";
} }
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
:before-close="close" :before-close="close"
:visible="value" :visible="value"
:show-close="false" :show-close="false"
custom-class="transparent" custom-class="transparent flex"
width="90%" width="90%"
top="60px"
> >
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<div class="d-flex justify-content-center align-items-start"> <div class="d-flex justify-content-center align-items-start">
<img v-if="file" :src="file.url" /> <img v-if="file" :src="file.url" :style="imgStyle" />
<i class="el-icon-close" @click="close"></i> <i class="el-icon-close" @click="close"></i>
</div>
<div class="d-flex justify-content-center actions">
<a <a
class="d-flex align-items-center justify-content-center" class="d-flex align-items-center justify-content-center"
:href="file.url" :href="file.url"
:download="getAttachment" :download="getAttachment"
target="_blank"
> >
<i class="el-icon-download"></i> <i class="el-icon-download"></i>
</a> </a>
...@@ -37,6 +37,13 @@ ...@@ -37,6 +37,13 @@
@Prop() @Prop()
private file!: { name: string; url: string }; private file!: { name: string; url: string };
private get imgStyle() {
return {
"max-width": `${document.body.scrollWidth * 0.8}px`,
"max-height": `${document.body.scrollHeight * 0.8}px`,
};
}
private close() { private close() {
this.$emit("update", false); this.$emit("update", false);
} }
...@@ -70,25 +77,19 @@ ...@@ -70,25 +77,19 @@
} }
} }
.actions {
margin: 15px 0;
a { a {
width: 50px; padding: 10px;
height: 50px;
background-color: #7a7b7d; background-color: #7a7b7d;
color: #fff;
border-radius: 50%; border-radius: 50%;
cursor: pointer; position: absolute;
left: 50%;
bottom: -65px;
margin-left: -50px;
i { i {
color: #fff; color: #fff;
font-size: 30px; font-size: 30px;
} cursor: pointer;
& + span {
margin-left: 15px;
}
} }
} }
</style> </style>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@click="open" @click="open"
> >
<img <img
v-if="messageRealUrl" v-if="mini"
:src="messageRealUrl" :src="mini"
:title="messageBody.msg.name" :title="messageBody.msg.name"
:alt="messageBody.msg.name" :alt="messageBody.msg.name"
@error="onImageError" @error="onImageError"
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
import BaseMessage from "./index"; import BaseMessage from "./index";
import FileIcon from "./file-icon.vue"; import FileIcon from "./file-icon.vue";
import { UserAgentHelper } from "@/customer-service/third-party/user-agent"; import { UserAgentHelper } from "@/customer-service/third-party/user-agent";
import { rebuildImage } from "../controller";
@Component({ components: { FileIcon } }) @Component({ components: { FileIcon } })
export default class Index extends BaseMessage { export default class Index extends BaseMessage {
...@@ -31,6 +32,10 @@ ...@@ -31,6 +32,10 @@
window.navigator.userAgent window.navigator.userAgent
); );
private get mini() {
return rebuildImage(this.messageRealUrl);
}
private onImageError() { private onImageError() {
this.fileFailed2Load = true; this.fileFailed2Load = true;
this.messageRealUrl = ""; this.messageRealUrl = "";
......
...@@ -63,17 +63,17 @@ class ChatCacheDatabaseController { ...@@ -63,17 +63,17 @@ class ChatCacheDatabaseController {
} }
resolve(); resolve();
}; };
r.onsuccess = (e) => { r.onsuccess = e => {
this.db = (e.target as any).result; this.db = (e.target as any).result;
console.log(`index database init comepleted`); console.log(`index database init comepleted`);
setupDb(); setupDb();
}; };
r.onupgradeneeded = (e) => { r.onupgradeneeded = e => {
this.db = (e.target as any).result; this.db = (e.target as any).result;
console.log(`upgrade database comepleted`); console.log(`upgrade database comepleted`);
setupDb(); setupDb();
}; };
r.onerror = (e) => { r.onerror = e => {
console.log(`index database init failed, ${e}`); console.log(`index database init failed, ${e}`);
this.setupError = true; this.setupError = true;
reject(); reject();
...@@ -88,7 +88,7 @@ class ChatCacheDatabaseController { ...@@ -88,7 +88,7 @@ class ChatCacheDatabaseController {
const k = this.buildChatMessageKey(chat); const k = this.buildChatMessageKey(chat);
const t = this.messageDatabases.get(k); const t = this.messageDatabases.get(k);
if (!t) { if (!t) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.uid && indexedDB) { if (this.uid && indexedDB) {
const r = indexedDB.open(k, this.msgVersion); const r = indexedDB.open(k, this.msgVersion);
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
...@@ -102,17 +102,17 @@ class ChatCacheDatabaseController { ...@@ -102,17 +102,17 @@ class ChatCacheDatabaseController {
} }
setTimeout(() => resolve(), 200); setTimeout(() => resolve(), 200);
}; };
r.onsuccess = function (e) { r.onsuccess = function(e) {
const db = (e.target as any).result; const db = (e.target as any).result;
that.messageDatabases.set(k, db); that.messageDatabases.set(k, db);
setupDb(); setupDb();
}; };
r.onupgradeneeded = function (e) { r.onupgradeneeded = function(e) {
const db = (e.target as any).result; const db = (e.target as any).result;
that.messageDatabases.set(k, db); that.messageDatabases.set(k, db);
setupDb(); setupDb();
}; };
r.onerror = function (e) { r.onerror = function(e) {
console.log( console.log(
`chat message index database init failed, ${e}` `chat message index database init failed, ${e}`
); );
...@@ -163,11 +163,11 @@ class ChatCacheDatabaseController { ...@@ -163,11 +163,11 @@ class ChatCacheDatabaseController {
} }
public updateChat(p: ChatStore.ChatUpdateParameter) { public updateChat(p: ChatStore.ChatUpdateParameter) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.db) { if (this.db) {
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const t = store.get(p.chat); const t = store.get(p.chat);
t.onsuccess = (r) => { t.onsuccess = r => {
const chat = (r.target as any).result as Chat; const chat = (r.target as any).result as Chat;
if (chat) { if (chat) {
chat.eid = p.eid as string; chat.eid = p.eid as string;
...@@ -191,11 +191,11 @@ class ChatCacheDatabaseController { ...@@ -191,11 +191,11 @@ class ChatCacheDatabaseController {
} }
public updateChat4UnreadCount(chat: number, unread: number) { public updateChat4UnreadCount(chat: number, unread: number) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.db) { if (this.db) {
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const t = store.get(chat); const t = store.get(chat);
t.onsuccess = (r) => { t.onsuccess = r => {
const chat = (r.target as any).result as Chat; const chat = (r.target as any).result as Chat;
if (chat) { if (chat) {
chat.unread_msg_count = unread; chat.unread_msg_count = unread;
...@@ -214,11 +214,11 @@ class ChatCacheDatabaseController { ...@@ -214,11 +214,11 @@ class ChatCacheDatabaseController {
} }
public setRead(chat: number) { public setRead(chat: number) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.db) { if (this.db) {
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const t = store.get(chat); const t = store.get(chat);
t.onsuccess = (r) => { t.onsuccess = r => {
const chat = (r.target as any).result as Chat; const chat = (r.target as any).result as Chat;
if (chat) { if (chat) {
chat.unread_msg_count = 0; chat.unread_msg_count = 0;
...@@ -253,7 +253,7 @@ class ChatCacheDatabaseController { ...@@ -253,7 +253,7 @@ class ChatCacheDatabaseController {
allRead?: boolean; allRead?: boolean;
} }
) { ) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.db) { if (this.db) {
const store = this.buildChatMessageStore(chat); const store = this.buildChatMessageStore(chat);
if (option.end && option.end > option.start) { if (option.end && option.end > option.start) {
...@@ -267,7 +267,7 @@ class ChatCacheDatabaseController { ...@@ -267,7 +267,7 @@ class ChatCacheDatabaseController {
}; };
for (let i = option.start; i <= option.end; i++) { for (let i = option.start; i <= option.end; i++) {
const r = store.get(i); const r = store.get(i);
r.onsuccess = (m) => { r.onsuccess = m => {
const p = (m.target as any).result as Message; const p = (m.target as any).result as Message;
if (p) { if (p) {
if (option.allRead) { if (option.allRead) {
...@@ -284,7 +284,7 @@ class ChatCacheDatabaseController { ...@@ -284,7 +284,7 @@ class ChatCacheDatabaseController {
} }
} else { } else {
const r = store.get(option.start); const r = store.get(option.start);
r.onsuccess = (m) => { r.onsuccess = m => {
const p = (m.target as any).result as Message; const p = (m.target as any).result as Message;
if (p) { if (p) {
if (option.allRead) { if (option.allRead) {
...@@ -306,7 +306,7 @@ class ChatCacheDatabaseController { ...@@ -306,7 +306,7 @@ class ChatCacheDatabaseController {
} }
public removeChatFromList(chat: number) { public removeChatFromList(chat: number) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (this.db) { if (this.db) {
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const t = store.delete(chat); const t = store.delete(chat);
...@@ -319,27 +319,27 @@ class ChatCacheDatabaseController { ...@@ -319,27 +319,27 @@ class ChatCacheDatabaseController {
} }
public getChatList() { public getChatList() {
return new Promise<Chat[]>((resolve) => { return new Promise<Chat[]>(resolve => {
if (!this.db) { if (!this.db) {
return resolve([]); return resolve([]);
} }
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const r = store.getAll(); const r = store.getAll();
r.onsuccess = (o) => resolve((o.target as any).result); r.onsuccess = o => resolve((o.target as any).result);
r.onerror = () => resolve([]); r.onerror = () => resolve([]);
}); });
} }
public getChatByCode(code: string) { public getChatByCode(code: string) {
return new Promise<Chat | null>((resolve) => { return new Promise<Chat | null>(resolve => {
if (!this.db) { if (!this.db) {
return resolve(null); return resolve(null);
} }
const store = this.buildStore(this.chatListKey); const store = this.buildStore(this.chatListKey);
const r = store.getAll(); const r = store.getAll();
r.onsuccess = (o) => { r.onsuccess = o => {
const items = (o.target as any).result as Chat[]; const items = (o.target as any).result as Chat[];
resolve(items.find((i) => i.biz_type_code === code) as Chat); resolve(items.find(i => i.biz_type_code === code) as Chat);
}; };
r.onerror = () => resolve(null); r.onerror = () => resolve(null);
}); });
...@@ -364,21 +364,21 @@ class ChatCacheDatabaseController { ...@@ -364,21 +364,21 @@ class ChatCacheDatabaseController {
} }
public getChatMessages(chat: number) { public getChatMessages(chat: number) {
return new Promise<Message[]>((resolve) => { return new Promise<Message[]>(resolve => {
if (!this.db) { if (!this.db) {
return resolve([]); return resolve([]);
} }
this.setupChatMessageDatabase(chat).finally(() => { this.setupChatMessageDatabase(chat).finally(() => {
const store = this.buildChatMessageStore(chat); const store = this.buildChatMessageStore(chat);
const r = store.getAll(); const r = store.getAll();
r.onsuccess = (o) => resolve((o.target as any).result); r.onsuccess = o => resolve((o.target as any).result);
r.onerror = () => resolve([]); r.onerror = () => resolve([]);
}); });
}); });
} }
public appendMessages(chat: number, items: Message[]) { public appendMessages(chat: number, items: Message[]) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (!this.db || !items || !items.length) { if (!this.db || !items || !items.length) {
return resolve(); return resolve();
} }
...@@ -413,7 +413,7 @@ class ChatCacheDatabaseController { ...@@ -413,7 +413,7 @@ class ChatCacheDatabaseController {
public mergeChatList(source1: Chat[], source2: Chat[]) { public mergeChatList(source1: Chat[], source2: Chat[]) {
for (const item of source2) { for (const item of source2) {
const t = source1.find((i) => i.id === item.id); const t = source1.find(i => i.id === item.id);
if (t) { if (t) {
item.unread_msg_count = Math.max( item.unread_msg_count = Math.max(
item.unread_msg_count, item.unread_msg_count,
...@@ -445,14 +445,14 @@ class ChatCacheDatabaseController { ...@@ -445,14 +445,14 @@ class ChatCacheDatabaseController {
msg: number, msg: number,
status: MessageHandled status: MessageHandled
) { ) {
return new Promise<void>((resolve) => { return new Promise<void>(resolve => {
if (!this.db) { if (!this.db) {
return resolve(); return resolve();
} }
this.setupChatMessageDatabase(chat).finally(() => { this.setupChatMessageDatabase(chat).finally(() => {
const store = this.buildChatMessageStore(chat); const store = this.buildChatMessageStore(chat);
const r = store.get(msg); const r = store.get(msg);
r.onsuccess = (o) => { r.onsuccess = o => {
const p = (o.target as any).result as Message; const p = (o.target as any).result as Message;
p.handled = status; p.handled = status;
const u = store.put(p); const u = store.put(p);
......
...@@ -162,12 +162,6 @@ export enum IMDomainType { ...@@ -162,12 +162,6 @@ export enum IMDomainType {
"外国人工作许可h" = "biz_wgrgzxk_h", "外国人工作许可h" = "biz_wgrgzxk_h",
"成都购房社保合规咨询" = "biz_cdgfsbhgzx", "成都购房社保合规咨询" = "biz_cdgfsbhgzx",
"成都落户咨询服务" = "biz_cdlhzxfw", "成都落户咨询服务" = "biz_cdlhzxfw",
// 表格以外,亲亲小保项目中有使用
"企业社保薪酬咨询" = "con_qysbxcconsult",
"知识产权相关咨询" = "con_zscqxgconsult",
"公司资质咨询" = "con_gszzzx",
"保险及员工福利业务咨询" = "con_bxjygflywconsult",
"工商财税业务咨询" = "con_gscsywconsult",
} }
export const imItems = [ export const imItems = [
...@@ -814,27 +808,6 @@ export const imItems = [ ...@@ -814,27 +808,6 @@ export const imItems = [
type: IMDomainType.成都落户咨询服务, type: IMDomainType.成都落户咨询服务,
title: "成都落户咨询服务", title: "成都落户咨询服务",
}, },
// 表格以外,亲亲小保项目中有使用
{
type: IMDomainType.企业社保薪酬咨询,
title: "企业社保薪酬咨询",
},
{
type: IMDomainType.知识产权相关咨询,
title: "知识产权相关咨询",
},
{
type: IMDomainType.公司资质咨询,
title: "公司资质咨询",
},
{
type: IMDomainType.保险及员工福利业务咨询,
title: "保险及员工福利业务咨询",
},
{
type: IMDomainType.工商财税业务咨询,
title: "工商财税业务咨询",
},
]; ];
export function getOrderProductName(code: string) { export function getOrderProductName(code: string) {
......
...@@ -82,6 +82,11 @@ export interface ChatOption { ...@@ -82,6 +82,11 @@ export interface ChatOption {
message?: ChatMessageController; message?: ChatMessageController;
avatar?: string; avatar?: string;
/**
* 禁用IndexDb
*/
disabledIndexDb?:boolean;
} }
export interface ChatMessageController { export interface ChatMessageController {
......
import Axios, { AxiosResponse } from "axios"; import Axios, { AxiosResponse, AxiosAdapter } from "axios";
import { UniplatSdk } from "uniplat-sdk"; import { UniplatSdk } from "uniplat-sdk";
import { ImEnvironment } from "../model"; import { ImEnvironment } from "../model";
...@@ -26,6 +26,7 @@ export interface SdkMonitorOption { ...@@ -26,6 +26,7 @@ export interface SdkMonitorOption {
userAgent?: boolean; userAgent?: boolean;
envir: ImEnvironment; envir: ImEnvironment;
product: Product; product: Product;
call?: (r: any) => void;
} }
class WebMonitor { class WebMonitor {
...@@ -33,6 +34,7 @@ class WebMonitor { ...@@ -33,6 +34,7 @@ class WebMonitor {
private envir = ImEnvironment.Dev; private envir = ImEnvironment.Dev;
private product = Product.Default; private product = Product.Default;
private readonly url = "https://pre-hrs-monitor.hrs100.com"; private readonly url = "https://pre-hrs-monitor.hrs100.com";
private adapter: AxiosAdapter | undefined;
public updateKey(key: string) { public updateKey(key: string) {
this.key = key; this.key = key;
...@@ -42,6 +44,7 @@ class WebMonitor { ...@@ -42,6 +44,7 @@ class WebMonitor {
private buildHeaders() { private buildHeaders() {
return { return {
headers: { authorization: "cdd0a34e-f537-4e5b-808e-2ba06af21845" }, headers: { authorization: "cdd0a34e-f537-4e5b-808e-2ba06af21845" },
adapter: this.adapter,
}; };
} }
...@@ -85,11 +88,17 @@ class WebMonitor { ...@@ -85,11 +88,17 @@ class WebMonitor {
); );
} }
public useSdk(sdk: UniplatSdk, options: SdkMonitorOption) { public useSdk(
sdk: UniplatSdk,
options: SdkMonitorOption,
adapter?: AxiosAdapter
) {
this.envir = options.envir; this.envir = options.envir;
this.product = options.product; this.product = options.product;
this.adapter = adapter;
sdk.events.addUniversalErrorResponseCallback( sdk.events.addUniversalErrorResponseCallback(
(r: AxiosResponse<any>) => { (r: AxiosResponse<any>) => {
options.call && options.call(r);
if (this.enable()) { if (this.enable()) {
const msg: string[] = []; const msg: string[] = [];
msg.push( msg.push(
...@@ -111,12 +120,14 @@ class WebMonitor { ...@@ -111,12 +120,14 @@ class WebMonitor {
if (r.config && r.config.data) { if (r.config && r.config.data) {
const form = r.config.data as FormData; const form = r.config.data as FormData;
if (form.getAll) { if (form.getAll) {
const p = form.getAll('parameters'); const p = form.getAll("parameters");
for (const item of p) { for (const item of p) {
msg.push(`Payload: ${item}`); msg.push(`Payload: ${item}`);
} }
} else { } else {
msg.push(`Payload: ${JSON.stringify(r.config.data)}`); msg.push(
`Payload: ${JSON.stringify(r.config.data)}`
);
} }
} }
......
...@@ -21,6 +21,7 @@ import { decodeJwt } from "uniplat-sdk"; ...@@ -21,6 +21,7 @@ import { decodeJwt } from "uniplat-sdk";
import { ChatStatus, ChatStore, ChatStoreState } from "./model"; import { ChatStatus, ChatStore, ChatStoreState } from "./model";
import { RootStoreState } from "@/store/model"; import { RootStoreState } from "@/store/model";
import { rebuildImage } from "../components/controller";
export const ns = ChatStore.ns; export const ns = ChatStore.ns;
...@@ -45,7 +46,7 @@ function combineMessages( ...@@ -45,7 +46,7 @@ function combineMessages(
items.push(item); items.push(item);
} }
} }
return items.sort((x, y) => (x.id - y.id ? 1 : -1)); return items.sort((x, y) => x.id - y.id);
} }
let removeRegisterChatEvents: (() => void)[] = []; let removeRegisterChatEvents: (() => void)[] = [];
...@@ -71,7 +72,7 @@ async function preCacheImgs(msgs?: any[]) { ...@@ -71,7 +72,7 @@ async function preCacheImgs(msgs?: any[]) {
typeof Image !== "undefined" typeof Image !== "undefined"
) { ) {
const preCache = new Image(); const preCache = new Image();
preCache.src = url; preCache.src = rebuildImage(url);
preCache.onload = () => resolve(); preCache.onload = () => resolve();
setTimeout(resolve, 2000); setTimeout(resolve, 2000);
} else { } else {
...@@ -778,9 +779,7 @@ export default { ...@@ -778,9 +779,7 @@ export default {
if (!chatId) { if (!chatId) {
return; return;
} }
const chatList = state[ const chatList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST];
ChatStore.STATE_MY_CHAT_ROOM_LIST
] as ChatType[];
let wantedChatRoom = chatList.find((k) => k.chat_id === chatId); let wantedChatRoom = chatList.find((k) => k.chat_id === chatId);
if (!wantedChatRoom) { if (!wantedChatRoom) {
...@@ -819,12 +818,12 @@ export default { ...@@ -819,12 +818,12 @@ export default {
ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID, ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID,
info.uniplatId info.uniplatId
); );
dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}) })
.catch(console.error); .catch(console.error);
commit(ChatStore.MUTATION_INITING_CHAT); commit(ChatStore.MUTATION_INITING_CHAT);
removeRegisterChatEvents.forEach((k) => k()); removeRegisterChatEvents.forEach((k) => k());
removeRegisterChatEvents = []; removeRegisterChatEvents = [];
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
try { try {
await Promise.all([ await Promise.all([
dispatch(ChatStore.ACTION_REGISTER_EVENT), dispatch(ChatStore.ACTION_REGISTER_EVENT),
......
...@@ -58,7 +58,12 @@ class Chat { ...@@ -58,7 +58,12 @@ class Chat {
option.message && (this.messageController = option.message); option.message && (this.messageController = option.message);
option.avatar !== undefined && (this.defaultAvatar = option.avatar); option.avatar !== undefined && (this.defaultAvatar = option.avatar);
await this.setupIndexDb(option.orgId()); if(!option.disabledIndexDb){
await this.setupIndexDb(option.orgId()).catch(err => {
// 必须catch error不然小程序不会向后运行
console.error("setupIndexDb Error")
});
}
this.token = async () => option.sdk().global.jwtToken; this.token = async () => option.sdk().global.jwtToken;
tokenManager.save(this.token); tokenManager.save(this.token);
......
...@@ -8,7 +8,7 @@ import { Message, NotifyMessage } from "./models/chat"; ...@@ -8,7 +8,7 @@ import { Message, NotifyMessage } from "./models/chat";
import chat from "./index"; import chat from "./index";
import { STATUS } from "xchat-client/dist/xchat"; import { STATUS } from "xchat-client/dist/xchat";
wampDebug(true); wampDebug(false);
const DefaultMsgPageSize = 20; const DefaultMsgPageSize = 20;
......
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