diff --git a/projects/IoTCenter/wwwroot/index.html b/projects/IoTCenter/wwwroot/index.html index cb550980..10c607fe 100644 --- a/projects/IoTCenter/wwwroot/index.html +++ b/projects/IoTCenter/wwwroot/index.html @@ -15,7 +15,7 @@ body{ height:100%; } .Center-Container { - background-color: #07c160; + background-color: #35A9FE; position: relative; } @@ -35,6 +35,22 @@ body{ diff --git a/projects/IoTCenter/wwwroot/redirect.js b/projects/IoTCenter/wwwroot/redirect.js index b7b3d3d1..2aef3341 100644 --- a/projects/IoTCenter/wwwroot/redirect.js +++ b/projects/IoTCenter/wwwroot/redirect.js @@ -1,29 +1,12 @@ -/** - * [通过参数名获取url中的参数值] - * 示例URL:http://iot.edusoa.com/IoTCenter/index.html?organ=测试学校 - * @param {[string]} queryName [参数名] - * @return {[string]} [参数值] - */ -function GetQueryValue(queryName) { - var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i"); - var r = window.location.search.substr(1).match(reg); - if ( r != null ){ - return decodeURI(r[2]); - }else{ - return null; - } -} + var url = ''; -var school = GetQueryValue('organ').replace(/\'/g, ''); +var school = (GetQueryValue('organname') || '').replace(/\'/g, ''); switch(school) { - case '东师理想': - url = 'http://iot.edusoa.com' - break; case '唐山市税东中学': - url = 'http://tsssdzx.iot.edusoa.com' + url = 'http://221.194.113.154:8100' break; default: - url = 'http://iot.edusoa.com' + url = 'http://221.194.113.154:8100' } window.location.href = url; \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/400.html b/projects/WebSPA/wwwroot/400.html new file mode 100644 index 00000000..8e42f93e --- /dev/null +++ b/projects/WebSPA/wwwroot/400.html @@ -0,0 +1,39 @@ + + + + + + + + + + + +
+
+
+ +

+
+
+
+ + +
+
+
+ + + \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/400.svg b/projects/WebSPA/wwwroot/400.svg new file mode 100644 index 00000000..335955d0 --- /dev/null +++ b/projects/WebSPA/wwwroot/400.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/index.html b/projects/WebSPA/wwwroot/index.html index 1efe0bb1..4ef1eeae 100644 --- a/projects/WebSPA/wwwroot/index.html +++ b/projects/WebSPA/wwwroot/index.html @@ -24,9 +24,9 @@ - + @@ -39,10 +39,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/js/app.js b/projects/WebSPA/wwwroot/js/app.js index fb637c63..da753827 100644 --- a/projects/WebSPA/wwwroot/js/app.js +++ b/projects/WebSPA/wwwroot/js/app.js @@ -3,7 +3,9 @@ var isApp = userAgent.indexOf('isapp') !== -1; var localStoreMsg = false; // 是否本地存储消息 /* API 网关 */ var apigateway = config.apigateway; -/* 从存储载入消息 */ +console.log('config:'); +console.log(apigateway); + var isLoadedMSG = false; /** @@ -19,6 +21,7 @@ axios.interceptors.request.use( config.headers['x-requested-with'] = 'XMLHttpRequest'; config.headers['Authorization'] = 'Bearer ' + store.state.accessToken; config.headers['X-APP-VERSION'] = '2.0.0'; + console.log('url:' + config.url + 'auth token:' + config.headers['Authorization']); } // 绝对路径替换为网关+路径 (防止多次请求重复拼接URL) config.url = config.url.indexOf('/') == 0 ? apigateway + config.url : config.url; @@ -29,6 +32,8 @@ axios.interceptors.request.use( return config; }, function (error) { + console.log('axios.interceptors.request.error:'); + console.log(error); $('#loading').fadeOut(100); return Promise.reject(error); } @@ -39,6 +44,8 @@ axios.interceptors.request.use( * 前端网络请求异常统一处理 */ axios.interceptors.response.use(function (response) { + console.log('axios.interceptors.response:'); + console.log(response); $('#loading').fadeOut(100); //根据config内容动态设置url @@ -81,7 +88,7 @@ axios.interceptors.response.use(function (response) { error.config.headers['Authorization'] = 'Bearer ' + store.state.accessToken; console.log('刷新token后重发api请求'); /* 重新发送原请求 */ - delete error.config.headers.Authorization // 移除旧的AccessToken信息,避免拦截器无法设置新AccessToken + delete error.config.headers.Authorization //移除旧的AccessToken信息,避免拦截器无法设置新AccessToken axios.request(error.config); }) .catch(function (error) { // 如果为RefreshToken失败则跳转登录页面 @@ -104,7 +111,11 @@ const router = new VueRouter({ }); router.beforeEach((to, from, next) => { $('#loading').show(); + console.log('before...') + console.log('store.state.accessToken', store.state.accessToken) + console.log('to.path', to.path) if (!store.state.accessToken && to.path !== '/pages/login') { + console.log('router.push') router.push('/pages/login'); return; } @@ -117,10 +128,14 @@ router.beforeEach((to, from, next) => { route = routeList[i]; } } + console.log('route', route) if (!route) { + console.log('<<>>', to.path) var path = to.path === '/' ? '/pages/home' : to.path; + var url = path + '.js'; var method = path.replace(/\//g, '_').substr(1) + "()"; + console.log('preRoute:from ' + from.path + ' to path ' + to.path); $.getScript(url, function () { var response = eval(method); var route = { @@ -134,6 +149,8 @@ router.beforeEach((to, from, next) => { }); } else { + console.log('!route else', route) + console.log('route from:' + from.path + ' to:' + to.path); next(); } }); @@ -168,6 +185,7 @@ if(indexedDB){ console.log('不支持'); } +console.log(indexedDB); var db = null; var request = indexedDB.open('app', 1); request.onupgradeneeded = function(e) { @@ -183,22 +201,29 @@ request.onsuccess = function() { /** * 初始化消息列表 */ - + console.log('loading message'); //loadMessage(); } function saveMessage(msg){ if(db){ console.log("数据库打开"); + console.log(db); var transaction = db.transaction('message','readwrite'); var objectStore = transaction.objectStore('message'); + console.log("数据:"); + console.log(msg); + console.log("类型:"); var jsonMsg = JSON.parse(msg); + console.log(typeof JSON.parse(msg)); // 校验数据格式(当前只存储带key的消息,后续会有调整) if( jsonMsg.key ){ + console.log('IS MSG'); // 本地存储 if(localStoreMsg){ objectStore.add({data: jsonMsg}); } + // objectStore.delete(store.state.messages[0]._id); store.commit('setMessages', [{data: jsonMsg}]); } }else{ @@ -206,32 +231,50 @@ function saveMessage(msg){ } } -function loadMessage(callback, limit = 99){ +function loadMessage(callback, limit = 10){ if(db){ console.log("数据库打开"); + console.log(db); var transaction = db.transaction('message','readwrite'); var objectStore = transaction.objectStore('message'); + console.log('objectStore:') + console.log(objectStore); var req = objectStore.openCursor(); + console.log('req:') + console.log(req); var items = []; // 回调会被多次调用 req.onsuccess = function (evt) { var cursor = evt.target.result; + console.log('cursor:') + console.log(cursor); if(cursor){ // 必要检查 var item = cursor.value; + //console.log(item); if(item.data.device){ items.push(item); + console.log('append item !!!'); + //console.log(items); + console.log('####### item #######'); + console.log('displayName: ' + item.data.device.displayName); + console.log('Name: ' + item.data.name); + console.log('Value: ' + item.data.value); } + cursor.continue(); // 移动到下一项 }else{ // 回调函数 + console.log('call back!!!'); callback(items); // 加载后删除数据库,只缓存上次应用开启数据 //indexedDB.deleteDatabase('app'); objectStore.clear(); + //alert(items.length -100) } }; + console.log(limit); var req = objectStore.get(limit); req.onerror = function(event) { console.log('事务失败'); @@ -249,6 +292,7 @@ const app = new Vue({ data: { }, mounted: function () { + console.log('mounted:app'); // 判断是否登录 if(localStorage.getItem('accessToken') === null){ // @@ -256,9 +300,8 @@ const app = new Vue({ } }, destroyed: function(){ - //Todo + alert('des'); }, methods: { - //Todo }, }).$mount('#app'); \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/js/config.js b/projects/WebSPA/wwwroot/js/config.js index 5d4db5cd..1cd49e6d 100644 --- a/projects/WebSPA/wwwroot/js/config.js +++ b/projects/WebSPA/wwwroot/js/config.js @@ -5,3 +5,4 @@ var config = (function(global){ global.liverUrl = global.apigateway; // 流媒体服务器地址 return global; })(window.config||{}); +console.log('config init'); \ No newline at end of file diff --git a/projects/WebSPA/wwwroot/js/iot.js b/projects/WebSPA/wwwroot/js/iot.js index 724dbde0..b7713a77 100644 --- a/projects/WebSPA/wwwroot/js/iot.js +++ b/projects/WebSPA/wwwroot/js/iot.js @@ -38,16 +38,17 @@ function getData(device, name) { } //devices function parseModel(response) { - + console.log('parseModel'); var html = new DOMParser().parseFromString(response.data, 'text/html'); - + console.log(html); var template = html.getElementsByTagName('template')[0].innerHTML; - + console.log(template); var script = html.getElementsByTagName('script')[0].innerHTML; - + console.log(script); var model = eval(script); model.template = template; - + console.log('model:::::'); + console.log(model); return model; } Vue.component('iot-gateway', function (resolve, reject) { @@ -77,6 +78,7 @@ Vue.component('iot-person', function (resolve, reject) { }); Vue.component('iot-curtain', function (resolve, reject) { axios.get("/pages/iot/device/curtain.html").then(function (response) { + console.log(response); resolve(parseModel(response)); }); }); diff --git a/projects/WebSPA/wwwroot/js/message.js b/projects/WebSPA/wwwroot/js/message.js index 1472b9c4..62536c20 100644 --- a/projects/WebSPA/wwwroot/js/message.js +++ b/projects/WebSPA/wwwroot/js/message.js @@ -34,9 +34,25 @@ connection.on("ServerToClient", function (method, message, to, from) { var model = JSON.parse(message); router.currentRoute.meta.onMessage(event, model, to, from); + console.log('receive:'); + console.log(method); // 调用方法 + console.log(message); // 消息内容 // 本地存储消息 saveMessage(message); + console.log('old messages:'); + console.log('==='); + console.log(store.state.messages); + + console.log('save message'); + console.log('===event==='); + console.log(event); + + + console.log('-------------'); + //store.commit('setMessages', []); + console.log('-------------'); + /** * 调用定义的update事件处理 * 注:设备移除 @@ -48,6 +64,15 @@ connection.on("ServerToClient", function (method, message, to, from) { * from: null */ + console.log('message.js event:'); + console.log(event); + console.log('message.js model:'); + console.log(model); + console.log('message.js to:'); + console.log(to); + console.log('message.js from:'); + console.log(from); + /** * 事件过滤处理,绑定到对应异步操作 * 除设备操作事件外(Event > Mutations > State),其他事件只做Action触发,不直接刷新数据 diff --git a/projects/WebSPA/wwwroot/js/util.js b/projects/WebSPA/wwwroot/js/util.js index b0002784..2d913927 100644 --- a/projects/WebSPA/wwwroot/js/util.js +++ b/projects/WebSPA/wwwroot/js/util.js @@ -22,6 +22,7 @@ function update(list, item, key) { list.push(item); result = true; } + console.log(result?'insert':'update'+' data by '+key); return result; } //delete diff --git a/projects/WebSPA/wwwroot/pages/iot/node.html b/projects/WebSPA/wwwroot/pages/iot/node.html index b954a6e9..61bb8804 100644 --- a/projects/WebSPA/wwwroot/pages/iot/node.html +++ b/projects/WebSPA/wwwroot/pages/iot/node.html @@ -131,8 +131,8 @@
- - + +
@@ -166,8 +166,8 @@
- - + +
diff --git a/projects/WebSPA/wwwroot/pages/iot/product.html b/projects/WebSPA/wwwroot/pages/iot/product.html index b84007f8..a61453a7 100644 --- a/projects/WebSPA/wwwroot/pages/iot/product.html +++ b/projects/WebSPA/wwwroot/pages/iot/product.html @@ -7,13 +7,17 @@
- -
- - +
+
+ +
+ + +
+

{{device.displayName}}

+
-

{{device.displayName}}

- +
\ No newline at end of file