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

优化全局配置

parent 2cae4af9
...@@ -15,3 +15,4 @@ selenium-debug.log ...@@ -15,3 +15,4 @@ selenium-debug.log
*.ntvs* *.ntvs*
*.njsproj *.njsproj
*.sln *.sln
yarn.lock
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
$this.MsgBus.$emit('nextMusic') $this.MsgBus.$emit('nextMusic')
} }
}, false); }, false);
$this.connectServer() //$this.connectServer()
this.MsgBus.$on('setBarrageShow', function (type) { this.MsgBus.$on('setBarrageShow', function (type) {
$this.barrageIsShow = type $this.barrageIsShow = type
}) })
...@@ -63,6 +63,7 @@ export default { ...@@ -63,6 +63,7 @@ export default {
$this.setAudioPlay(0) $this.setAudioPlay(0)
}, 50) }, 50)
}) })
this.getMsg();
// setInterval(()=>{ // setInterval(()=>{
// let barrageObj = { // let barrageObj = {
// id: ++this.currentId, // id: ++this.currentId,
...@@ -74,6 +75,7 @@ export default { ...@@ -74,6 +75,7 @@ export default {
// } // }
// $this.barrageList.push(barrageObj) // $this.barrageList.push(barrageObj)
// }, 5000) // }, 5000)
//this.sendMsg();
}, },
methods: { methods: {
setAudioType: function (type) { setAudioType: function (type) {
...@@ -87,31 +89,32 @@ export default { ...@@ -87,31 +89,32 @@ export default {
this.$refs.homeAudio.pause() this.$refs.homeAudio.pause()
} }
}, },
connectServer() { // connectServer() {
var $this = this; // var $this = this;
var conn = $.hubConnection("http://192.168.2.65:7838/signalr", { // var conn = $.hubConnection("http://192.168.2.65:7838/signalr", {
qs: `i=888888&n=罗超&p=${encodeURIComponent( // qs: `i=888888&n=罗超&p=${encodeURIComponent(
"http://imgfile.oytour.com/New/Upload/User/20191018150051176.png" // "http://imgfile.oytour.com/New/Upload/User/20191018150051176.png"
)}` // )}`
}); // });
$this.proxy = conn.createHubProxy("annualLeaveHub"); // $this.proxy = conn.createHubProxy("annualLeaveHub");
$this.getMsg(); // $this.getMsg();
conn // conn
.start() // .start()
.done(data => { // .done(data => {
$this.sendMsg(); // $this.sendMsg();
}) // })
.fail(data => {}); // .fail(data => {});
}, // },
sendMsg () { sendMsg () {
var $this = this; var $this = this;
$this.proxy.invoke("SendBarrage", '0.0 让我康康是谁在说我坏话?').done(msg => { $this.$PROXY.invoke("SendBarrage", '0.0 让我康康是谁在说我坏话?').done(msg => {
console.log(msg) console.log(msg)
}); });
}, },
getMsg () { getMsg () {
var $this = this; var $this = this;
$this.proxy.on("barrage", data => { console.log(this.$PROXY)
this.$PROXY.on("barrage", data => {
let barrage = data let barrage = data
let barrageObj = { let barrageObj = {
id: ++this.currentId, id: ++this.currentId,
......
This diff is collapsed.
...@@ -8,11 +8,13 @@ import 'element-ui/lib/theme-chalk/index.css' ...@@ -8,11 +8,13 @@ import 'element-ui/lib/theme-chalk/index.css'
import socketio from 'socket.io-client' import socketio from 'socket.io-client'
import MsgBus from './assets/js/msgBus' import MsgBus from './assets/js/msgBus'
import { vueBaberrage } from 'vue-baberrage' import { vueBaberrage } from 'vue-baberrage'
import plugin from './plugin/index'
import 'signalr' import 'signalr'
Vue.prototype.MsgBus = MsgBus Vue.prototype.MsgBus = MsgBus
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(vueBaberrage) Vue.use(vueBaberrage)
Vue.use(plugin)
Vue.prototype.$socketio = socketio Vue.prototype.$socketio = socketio
/* 路由发生变化修改页面title */ /* 路由发生变化修改页面title */
...@@ -21,8 +23,8 @@ router.beforeEach((to, from, next) => { ...@@ -21,8 +23,8 @@ router.beforeEach((to, from, next) => {
document.title = to.meta.title document.title = to.meta.title
} }
next() next()
}) })
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
......
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