Commit 8f799d33 authored by 罗超's avatar 罗超

优化全局配置

parent 2cae4af9
......@@ -15,3 +15,4 @@ selenium-debug.log
*.ntvs*
*.njsproj
*.sln
yarn.lock
......@@ -44,7 +44,7 @@ export default {
$this.MsgBus.$emit('nextMusic')
}
}, false);
$this.connectServer()
//$this.connectServer()
this.MsgBus.$on('setBarrageShow', function (type) {
$this.barrageIsShow = type
})
......@@ -63,6 +63,7 @@ export default {
$this.setAudioPlay(0)
}, 50)
})
this.getMsg();
// setInterval(()=>{
// let barrageObj = {
// id: ++this.currentId,
......@@ -74,6 +75,7 @@ export default {
// }
// $this.barrageList.push(barrageObj)
// }, 5000)
//this.sendMsg();
},
methods: {
setAudioType: function (type) {
......@@ -87,31 +89,32 @@ export default {
this.$refs.homeAudio.pause()
}
},
connectServer() {
var $this = this;
var conn = $.hubConnection("http://192.168.2.65:7838/signalr", {
qs: `i=888888&n=罗超&p=${encodeURIComponent(
"http://imgfile.oytour.com/New/Upload/User/20191018150051176.png"
)}`
});
$this.proxy = conn.createHubProxy("annualLeaveHub");
$this.getMsg();
conn
.start()
.done(data => {
$this.sendMsg();
})
.fail(data => {});
},
// connectServer() {
// var $this = this;
// var conn = $.hubConnection("http://192.168.2.65:7838/signalr", {
// qs: `i=888888&n=罗超&p=${encodeURIComponent(
// "http://imgfile.oytour.com/New/Upload/User/20191018150051176.png"
// )}`
// });
// $this.proxy = conn.createHubProxy("annualLeaveHub");
// $this.getMsg();
// conn
// .start()
// .done(data => {
// $this.sendMsg();
// })
// .fail(data => {});
// },
sendMsg () {
var $this = this;
$this.proxy.invoke("SendBarrage", '0.0 让我康康是谁在说我坏话?').done(msg => {
$this.$PROXY.invoke("SendBarrage", '0.0 让我康康是谁在说我坏话?').done(msg => {
console.log(msg)
});
},
getMsg () {
var $this = this;
$this.proxy.on("barrage", data => {
console.log(this.$PROXY)
this.$PROXY.on("barrage", data => {
let barrage = data
let barrageObj = {
id: ++this.currentId,
......
This diff is collapsed.
......@@ -8,24 +8,26 @@ import 'element-ui/lib/theme-chalk/index.css'
import socketio from 'socket.io-client'
import MsgBus from './assets/js/msgBus'
import { vueBaberrage } from 'vue-baberrage'
import plugin from './plugin/index'
import 'signalr'
Vue.prototype.MsgBus = MsgBus
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(vueBaberrage)
Vue.use(plugin)
Vue.prototype.$socketio = socketio
/* 路由发生变化修改页面title */
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
next()
})
/* eslint-disable no-new */
if (to.meta.title) {
document.title = to.meta.title
}
next()
})
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
el: '#app',
router,
components: { App },
template: '<App/>'
})
\ No newline at end of file
import getHubProxy from './signalr'
export default {
install(Vue, options) {
Vue.prototype.$PROXY = getHubProxy();
}
};
\ No newline at end of file
const HUBNAME = 'annualLeaveHub';
let PROXY = null;
let HUB = null;
const HUB_API = 'http://localhost:7838/signalr';
// 建立连接
export function startConnection() {
HUB = $.hubConnection(HUB_API, {
qs: `i=888888&n=罗超&p=${encodeURIComponent("http://imgfile.oytour.com/New/Upload/User/20191018150051176.png")}`
})
let PROXY = HUB.createHubProxy(HUBNAME)
HUB.start().done((connection) => {
console.log('Now connected, connection ID=' + connection.id)
}).fail(() => {
console.log('Could not connect');
})
HUB.error(function(error) {
console.log('SignalR error: ' + error)
})
HUB.connectionSlow(function() {
console.log('We are currently experiencing difficulties with the connection.')
});
HUB.disconnected(function() {
console.log('disconnected')
});
return PROXY
}
// 手动创建proxy
export default function getHubProxy() {
if (!PROXY) {
PROXY = startConnection();
}
// // 注册客户端方法
// clientMethodSets.map((item)=>{
// proxy.on(item.name,item.method)
// })
return PROXY
}
\ No newline at end of file
import Vue from 'vue'
// import from ''
\ No newline at end of file
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 to comment