This commit is contained in:
linfso 2025-01-01 23:40:31 +08:00
parent f4b1844d38
commit cf3bed37a3
2 changed files with 30 additions and 10 deletions

View File

@ -76,7 +76,9 @@
<script>
import {Notification} from "element-ui";
import Speech from 'speak-tts'
import { getToken } from "@/utils/auth";
import { encrypt } from '@/utils/jsencrypt'
// import Speech from 'speak-tts'
import {getTopNoticeListByUserId,addReadTimes,getPublicNoticeList,clearNotice} from "@/api/system/notice";
export default {
name: 'TopNotice',
@ -104,16 +106,16 @@ export default {
mounted() {
window.addEventListener("click", this.setCanPlayTone);
this.initXDNoticSdk();
this.speechInit();
// this.speechInit();
this.initUserNotice();
},
methods: {
speechInit() {
this.speech = new Speech();
this.speech.setLanguage("zh-CN");
this.speech.init().then(() => {});
},
// speechInit() {
// this.speech = new Speech();
// this.speech.setLanguage("zh-CN");
// this.speech.init().then(() => {});
// },
setCanPlayTone() {
this.isPlay = true;
},
@ -127,8 +129,11 @@ export default {
console.log("===>initXDNoticSdk==>")
this.xdNoticSdk = this.$xdNoticeSdk;
const userId=this.$store.getters.userId;
// const token=getToken();
// console.log("===>userId==>",userId);
this.xdNoticSdk.init(userId);
// this.xdNoticSdk.init(userId);
this.xdNoticSdk.initWsPlus(userId);
this.xdNoticSdk.setOnOpen(this.onNoticeOpen);
this.xdNoticSdk.setOnClose(this.onNoticeClose);

View File

@ -7,8 +7,13 @@ class XDNoticeSdk {
VERSION="1.0.0"
MAX_SENT_RETRY_COUNT = 9;
WS_URL = process.env.VUE_APP_WS_HOST+'/ws/';
WS_PLUS_URL = process.env.VUE_APP_WS_HOST+'/wsplus/';
userId = null;
encUserId = null;
token = null;
AUTH_TOKEN=null;
@ -55,6 +60,13 @@ class XDNoticeSdk {
this.start();
}
initWsPlus(userId){
// 初始化参数建立连接
this.userId=userId;
this.connect();
this.start();
}
setOnOpen(callback){
this.onOpenCallback.push(callback);
@ -107,8 +119,11 @@ class XDNoticeSdk {
if (!this.ws || this.getWSReadyState() === this.WS_CLOSING || this.getWSReadyState() === this.WS_CLOSE) {
try {
// wss://api.emis.tanex56.com/api/bizsvr/ws/123/pc
this.ws = new WebSocket(this.WS_URL+""+this.userId+"/pc");
// wss://api.emis.tanex56.com/api/bizsvr/ws/123
// wss://api.emis.tanex56.com/api/bizsvr/wsplus/123
// this.ws = new WebSocket(this.WS_URL+""+this.userId);
this.ws = new WebSocket(this.WS_PLUS_URL+""+this.userId);
this.ws.onerror = () => {
// console.log("ws onerror!");