Former-commit-id: c640bfc9a6e5aa04754b5f170b6f1019f5b8312b
TangShanKaiPing
wanggang 5 years ago
commit 50e1d2c041

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1590654813817" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2781" xmlns:xlink="http://www.w3.org/1999/xlink" width="1024" height="1024"><defs><style type="text/css"></style></defs><path d="M803.406102 829.44c0 14.578983-21.000678 26.554576-46.861017 26.554576H267.454915c-25.860339 0-46.861017-11.975593-46.861017-26.554576s21.000678-26.728136 46.861017-26.728136h489.09017c25.860339 0 46.861017 11.975593 46.861017 26.728136zM512 308.588475a23.08339 23.08339 0 0 1-23.777627-22.562712V190.915254a23.777627 23.777627 0 0 1 47.555254 0v95.631187a23.08339 23.08339 0 0 1-23.777627 22.562712zM333.928136 369.681356a24.471864 24.471864 0 0 1-17.355933-8.157288l-65.084745-73.068475a21.521356 21.521356 0 0 1 2.950508-31.587796 24.471864 24.471864 0 0 1 33.32339 2.776949l65.258305 73.068474a21.521356 21.521356 0 0 1-3.818305 31.761356 24.124746 24.124746 0 0 1-15.27322 5.380339zM239.338305 524.496271h-4.165424l-99.79661-17.355932a22.562712 22.562712 0 0 1-19.265085-25.860339 23.604068 23.604068 0 0 1 27.422373-17.87661l99.97017 17.355932a22.215593 22.215593 0 0 1 19.091525 25.860339 23.256949 23.256949 0 0 1-23.256949 18.570847zM690.071864 369.681356a24.992542 24.992542 0 0 1-15.27322-5.20678 21.521356 21.521356 0 0 1-2.950508-31.587796L737.106441 260.338983a24.818983 24.818983 0 0 1 33.32339-2.776949 21.521356 21.521356 0 0 1 2.950508 31.587797l-65.084746 73.242033a24.471864 24.471864 0 0 1-18.223729 8.157289zM784.661695 524.496271a23.430508 23.430508 0 0 1-23.256949-18.570847A22.215593 22.215593 0 0 1 781.016949 480.065085l99.97017-17.355932a23.604068 23.604068 0 0 1 27.422373 18.223728 22.562712 22.562712 0 0 1-19.265085 25.860339l-99.79661 17.355933h-4.165424z" fill="#d81e06" p-id="2782"></path><path d="M697.187797 577.431864c0-109.863051-82.961356-198.725424-185.187797-198.725423s-185.187797 88.862373-185.187797 198.725423v225.627119h370.375594z" fill="#d81e06" p-id="2783"></path><path d="M526.058305 576.216949h60.225085l-143.707119 172.517966 47.902373-121.491525h-53.456271l53.456271-143.36h104.135593z" fill="#d81e06" p-id="2784"></path></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -3,9 +3,7 @@ var isApp = userAgent.indexOf('isapp') !== -1;
var localStoreMsg = false; // 是否本地存储消息
/* API 网关 */
var apigateway = config.apigateway;
console.log('config:');
console.log(apigateway);
/* 从存储载入消息 */
var isLoadedMSG = false;
/**
@ -21,7 +19,6 @@ 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;
@ -32,8 +29,6 @@ axios.interceptors.request.use(
return config;
},
function (error) {
console.log('axios.interceptors.request.error:');
console.log(error);
$('#loading').fadeOut(100);
return Promise.reject(error);
}
@ -44,8 +39,6 @@ axios.interceptors.request.use(
* 前端网络请求异常统一处理
*/
axios.interceptors.response.use(function (response) {
console.log('axios.interceptors.response:');
console.log(response);
$('#loading').fadeOut(100);
//根据config内容动态设置url
@ -88,7 +81,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失败则跳转登录页面
@ -111,11 +104,7 @@ 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;
}
@ -128,14 +117,10 @@ router.beforeEach((to, from, next) => {
route = routeList[i];
}
}
console.log('route', route)
if (!route) {
console.log('<<<!route to.path>>>', 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 = {
@ -149,8 +134,6 @@ router.beforeEach((to, from, next) => {
});
}
else {
console.log('!route else', route)
console.log('route from:' + from.path + ' to:' + to.path);
next();
}
});
@ -185,7 +168,6 @@ if(indexedDB){
console.log('不支持');
}
console.log(indexedDB);
var db = null;
var request = indexedDB.open('app', 1);
request.onupgradeneeded = function(e) {
@ -201,29 +183,22 @@ 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{
@ -231,50 +206,32 @@ function saveMessage(msg){
}
}
function loadMessage(callback, limit = 10){
function loadMessage(callback, limit = 99){
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('事务失败');
@ -292,7 +249,6 @@ const app = new Vue({
data: {
},
mounted: function () {
console.log('mounted:app');
// 判断是否登录
if(localStorage.getItem('accessToken') === null){
//
@ -300,8 +256,9 @@ const app = new Vue({
}
},
destroyed: function(){
alert('des');
//Todo
},
methods: {
//Todo
},
}).$mount('#app');

@ -5,4 +5,3 @@ var config = (function(global){
global.liverUrl = global.apigateway; // 流媒体服务器地址
return global;
})(window.config||{});
console.log('config init');

@ -38,17 +38,16 @@ 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) {
@ -78,7 +77,6 @@ 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));
});
});

@ -34,25 +34,9 @@ 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事件处理
* 设备移除
@ -64,15 +48,6 @@ 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触发不直接刷新数据

@ -33,9 +33,6 @@ const store = new Vuex.Store({
*
*/
update(context, model) {
console.log('#########################################'+model.event+'#########################################');
console.log(model)
// alert('update');
context.commit(model.event, model);
},
@ -148,19 +145,24 @@ const store = new Vuex.Store({
* 设置消息数据
* @param {*} state 原有状态
* @param {*} messages 新的消息数组
* @param {*} limit 默认条数限制
*/
setMessages(state, messages){
console.log('<<>>');
console.log(state.messages);
console.log(messages);
console.log('====================================');
//state.messages = messages;
//state.messages.push(messages);
// 便利消息列表追加
setMessages(state, messages, limit = 99){
// 推出超出条数FIFO
state.messages.forEach(function(value,i){
if(i >= limit){
state.messages.shift()
}
})
// 消息列表追加
messages.forEach(function(value,i){
if(state.messages >= limit){
state.messages.shift()
}
state.messages.push(value);
})
console.log(state.messages);
},
nodeEntityUpdated(state, data) {

@ -22,7 +22,6 @@ function update(list, item, key) {
list.push(item);
result = true;
}
console.log(result?'insert':'update'+' data by '+key);
return result;
}
//delete

@ -15,14 +15,14 @@
},
mounted: function () {
weui.tab('#tab', { defaultIndex: 1 });
console.log('setUser>>>>>>>>');
var url = this.url;
axios.get(url).then(function (response) {
store.commit('setUser', response.data);
}).catch(function (error) {
//error
})
console.log('载入消息2>>>>>>>>');
// 从存储载入消息
if(!isLoadedMSG) {
loadMessage(function(msgs){

@ -30,12 +30,10 @@
},
// 实例生命周期钩子 (销毁完毕)
destroyed: function () {
console.log('destroyed:');
store.commit('setDevice', null);
},
methods: {
updateChart: function () {
console.log('updateChart:');
var dataList = Enumerable.from(this.device.data).where(function (o) {
return o.type === 10 || o.type === 20;
}).toArray();
@ -44,7 +42,6 @@
}
},
changeTime: function (key, time,title) {
console.log('changeTime:');
var vm = this;
var t = (new Date()).valueOf();
var url = '/IoTCenter/api/v1/Device/GetChartData?t=' + t;
@ -57,14 +54,12 @@
.then(function (response) {
var data = response.data;
vm.UpdateChartInternal(key, data,title);
console.log('折线图更新成功');
})
.catch(function (error) {
console.log(error);
});
},
UpdateChartInternal(key, data, title) {
console.log('UpdateChartInternal:');
var canvas = document.getElementById(this.device.number + '-' + key);
var chart;
Chart.helpers.each(Chart.instances, function (instance) {
@ -72,7 +67,6 @@
chart = instance;
}
});
console.log('chart:', chart);
if (chart === '') {
chart.data = data;
@ -80,8 +74,7 @@
}
else {
var ctx = canvas.getContext('2d');
// ctx.canvas.height = 150;
console.log('canvas.getContext:', ctx);
var options = {
responsive: true,
legend: {
@ -124,11 +117,8 @@
},
computed: {
// 计算属性的 getter
device: function () {
console.log('++++++++++++++++debug++++++++++++++++');
console.log(store.state.device);
device: function () {
return store.state.device;
},
hasChart: function () {
// `this` 指向 app 实例
@ -141,18 +131,9 @@
}),
onMessage: function (event, model, to, from) {
// event : execApiResponse | dataEntityUpdated
console.log('@@@@ device.js @@@@')
console.log(event)
console.log('@@@@ device.js @@@@')
if(event === 'dataEntityUpdated'){
console.log('%%%%%%%%')
console.log(event)
console.log(model)
console.log(to)
console.log(from)
store.dispatch('update', {event, model, to, from});
}
//alert(event)
}
}
}
}

@ -123,25 +123,20 @@
this.flvPlayer.muted = this.muted;
var vm = this;
this.timer = setInterval(function () {
console.log('.');
if (vm.flvPlayer.statisticsInfo.speed === 0) {
console.log('reload1');
clearInterval(vm.timer);
vm.playByFlvJs();
}
else if (vm.decodedFrames && vm.flvPlayer.statisticsInfo.decodedFrames <= decodedFrames) {
console.log('reload2');
clearInterval(vm.timer);
vm.playByFlvJs();
}
else if (vm.flvPlayer.buffered.length > 0 && vm.flvPlayer.buffered.end(0) - vm.flvPlayer.currentTime > 2) {
console.log('reset currentTime');
vm.flvPlayer.currentTime = vm.flvPlayer.buffered.end(0) - 0.001;
}
vm.decodedFrames = vm.flvPlayer.statisticsInfo.decodedFrames;
}, 30 * 1000);
} catch (e) {
console.log('error:');
console.log(e);
}
}

@ -56,7 +56,6 @@
color: function () {
var h = Math.round(parseInt(this.hue || 128) * 360 / 255);
var result = 'hsl(' + h + ',100%,50%)';
console.log('color:'+result);
return result;
},
hsl: function () {
@ -64,7 +63,6 @@
var s = Math.round(parseInt(this.saturation || 128) * 100 / 254);
var l = Math.round(parseInt(this.brightness || 128) * 100 / 254);
var result = 'hsl(' + h + ',' + s + '%,' + l + '%);';
console.log('hsl:'+result);
return result;
}
}

@ -27,11 +27,9 @@
props: ['device'],
computed: {
electricity: function () {
console.log('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$-electricity');
return parseFloat(getDeviceDataValue(this.device, '电量')||0).toFixed(2);
},
power: function (){
console.log('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$-power');
return parseFloat(getDeviceDataValue(this.device, '功率')||0).toFixed(2);
}
}

@ -30,8 +30,6 @@
},
getShowFlag:function (name){
arr = Enumerable.from(this.node.devices).where(function (o) { return o.name === name; }).toArray();
console.log('arrarrarrarr', arr)
console.log('arrarrarrarr', JSON.parse(arr[0].data[0].value)[0].name)
return JSON.parse(arr[0].data[0].value)[0].name !== '测试' ? true : false;
},
getDeviceDataAttr: function (number, name, attr) {
@ -59,18 +57,9 @@
}),
onMessage: function (event, model, to, from) {
// event : execApiResponse | dataEntityUpdated
console.log('@@@@ node.js @@@@')
console.log(event)
console.log('@@@@ node.js @@@@')
if(event === 'dataEntityUpdated'){
console.log('%%%%%%%%')
console.log(event)
console.log(model)
console.log(to)
console.log(from)
store.dispatch('update', {event, model, to, from});
}
//alert(event)
}
}
}

@ -36,18 +36,10 @@
}),
onMessage: function (event, model, to, from) {
// event : deviceEntityDeleted | productEntityInserted
console.log('@@@@')
console.log(event)
// 当当前为产品设备列表页面时,刷新产品设备列表 (由于每次进入页面都触发数据刷新,非当前页面则不做数据更新处理)
var number = getUrlKey('number');
if(event === 'productEntityInserted'){
console.log('%%%%%%%%')
console.log(event)
console.log(model)
console.log(to)
console.log(from)
store.dispatch('getProducts', {event, model, to, from});
// 向产品设备列表中新增
store.dispatch('getProduct', {number:number});

@ -33,17 +33,9 @@ function pages_iot_products() {
}),
onMessage: function (event, model, to, from) {
// event : execApiResponse | dataEntityUpdated
console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
console.log(event)
if(event === 'productEntityInserted'){
console.log('%%%%%%%%')
console.log(event)
console.log(model)
console.log(to)
console.log(from)
store.dispatch('getProducts', {event, model, to, from});
}
//alert(event)
}
}
}

@ -11,11 +11,9 @@
};
},
mounted: function () {
console.log('mounted:login');
weui.form.checkIfBlur('#form', this.regexp);
// 绑定enter事件
this.enterKeyup();
console.log('mounted:enterKeyup');
},
computed: {
regexp: function () {

Loading…
Cancel
Save