no message

This commit is contained in:
kuaifan 2022-07-03 21:42:59 +08:00
parent 9c861ec58c
commit e80a38fa78
3 changed files with 26 additions and 23 deletions

View File

@ -76,26 +76,6 @@
} }
}, },
/**
* 格式化websocket的消息
* @param data
*/
formatWebsocketMessageDetail(data) {
if ($A.isJson(data)) {
for (let key in data) {
if (!data.hasOwnProperty(key)) continue;
data[key] = $A.formatWebsocketMessageDetail(data[key]);
}
} else if ($A.isArray(data)) {
data.forEach((val, index) => {
data[index] = $A.formatWebsocketMessageDetail(val);
});
} else if (typeof data === "string") {
data = data.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
}
return data;
},
/** /**
* 格式化时间 * 格式化时间
* @param date * @param date
@ -391,6 +371,29 @@
return text.replace(/<[^>]+>/g,"") return text.replace(/<[^>]+>/g,"")
}, },
/**
* 消息格式化处理将消息内的RemoteURL换成真实地址
* @param data
*/
formatMsgBasic(data) {
if (!data) {
return data
}
if ($A.isJson(data)) {
for (let key in data) {
if (!data.hasOwnProperty(key)) continue;
data[key] = $A.formatMsgBasic(data[key]);
}
} else if ($A.isArray(data)) {
data.forEach((val, index) => {
data[index] = $A.formatMsgBasic(val);
});
} else if (typeof data === "string") {
data = data.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
}
return data
},
/** /**
* 消息格式化处理 * 消息格式化处理
* @param text * @param text

View File

@ -84,8 +84,8 @@ export default {
handleProgress(event, file) { handleProgress(event, file) {
// //
if (file.tempId === undefined) { if (file.tempId === undefined) {
file.tempId = $A.randomString(8); file.tempId = $A.randNum(1000000000, 9999999999)
this.$emit('on-progress', file); this.$emit('on-progress', file)
} }
}, },

View File

@ -2392,7 +2392,7 @@ export default {
}; };
state.ws.onmessage = (e) => { state.ws.onmessage = (e) => {
wgLog && console.log("[WS] Message", e); wgLog && console.log("[WS] Message", e);
const msgDetail = $A.formatWebsocketMessageDetail($A.jsonParse(e.data)); const msgDetail = $A.formatMsgBasic($A.jsonParse(e.data));
const {type, msgId} = msgDetail; const {type, msgId} = msgDetail;
switch (type) { switch (type) {
case "open": case "open":