You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.8 KiB
74 lines
1.8 KiB
const routes = [
|
|
//{ path: '/', component: home },
|
|
//{ path: '/login', component: login },
|
|
//{path:'*'}
|
|
];
|
|
|
|
var routeList=routes.concat();
|
|
|
|
const router = new VueRouter({
|
|
routes
|
|
});
|
|
|
|
router.beforeEach((to,from,next)=>{
|
|
var route;
|
|
for(var i=0;i<routeList.length;i++)
|
|
{
|
|
if(routeList[i].path==to.path)
|
|
{
|
|
route=routeList[i];
|
|
}
|
|
}
|
|
if(!route)
|
|
{
|
|
var path = to.path==='/'?'/pages/home':to.path;
|
|
var url = path + '.js';
|
|
var method = path.replace(/\//g,'_').substr(1) + "()";
|
|
$.getScript(url,function(){
|
|
var route ={
|
|
path:to.path,
|
|
component:eval(method)
|
|
};
|
|
router.addRoutes([route]);
|
|
routeList.push(route);
|
|
router.push(to.fullPath);
|
|
});
|
|
}
|
|
else{
|
|
next();
|
|
}
|
|
|
|
});
|
|
|
|
var connection;
|
|
|
|
const app = new Vue({
|
|
router,
|
|
data() {
|
|
},
|
|
mounted: function () {
|
|
$('#loadingToast').fadeOut(100);
|
|
//if (!hasLogin) {
|
|
//Vue.nextTick(function(){
|
|
//router.go('/login');
|
|
//});
|
|
//}
|
|
connection = new signalR.HubConnectionBuilder().withUrl("/IoTCenter/hub?group=page").build();
|
|
connection.on('Connected', function (id) {
|
|
connectionId = id;
|
|
console.log(connectionId);
|
|
});
|
|
connection.on("ServerToClient", function (method, json, to, from) {
|
|
console.log(method + ':' + json);
|
|
});
|
|
connection.start().then(function () {
|
|
console.log('客户端与服务器连接成功!');
|
|
}).catch(function (err) {
|
|
console.log(err);
|
|
//setTimeout(connect, 15 * 1000);
|
|
});
|
|
},
|
|
destroyed: function () {
|
|
connection.stop();
|
|
},
|
|
}).$mount('#app'); |