Browse Source

perf: merge styles and cancel some duplicate calls

Casper Dai 3 năm trước cách đây
mục cha
commit
8b4c65180e

+ 2 - 1
keycloak-theme/login/messages/messages_zh_CN.properties

@@ -27,4 +27,5 @@ identityProviderNotFoundMessage=无法找到认证提供方
 staleCodeMessage=当前页面已无效,请到登录界面重新登录
 cookieNotFoundMessage="授权码失效"
 
-invalidParameterMessage=无效的参数 \: {0}
+invalidParameterMessage=无效的参数 \: {0}
+invalidRequestMessage=无效的请求参数

+ 4 - 4
src/api/asset.js

@@ -30,7 +30,7 @@ export function updateAsset (data) {
 export function deleteAsset ({ keyName, originalName }) {
   return del({
     url: '/minio-data/delete',
-    method: 'get',
+    method: 'GET',
     params: { keyName }
   }, originalName)
 }
@@ -50,7 +50,7 @@ export function getThumbnailUrl (keyName, ratio = 'x0.2,q30') {
 export function submitAsset ({ keyName, originalName }) {
   return submit({
     url: '/minio-data/submit',
-    method: 'get',
+    method: 'GET',
     params: { keyName }
   }, originalName)
 }
@@ -58,7 +58,7 @@ export function submitAsset ({ keyName, originalName }) {
 export function resolveAsset ({ keyName, originalName }) {
   return resolve({
     url: '/minio-data/reviewed',
-    method: 'get',
+    method: 'GET',
     params: { keyName }
   }, originalName)
 }
@@ -66,7 +66,7 @@ export function resolveAsset ({ keyName, originalName }) {
 export function rejectAsset ({ keyName, originalName }, reason) {
   return reject({
     url: '/minio-data/reject',
-    method: 'get',
+    method: 'GET',
     params: { keyName },
     data: { reason }
   }, originalName)

+ 1 - 1
src/api/base.js

@@ -16,7 +16,7 @@ export function send (config) {
 }
 
 export function messageSend (config, message) {
-  return send(config).then(data => {
+  return (config.onUploadProgress ? request : send)(config).then(data => {
     message && Message({
       type: 'success',
       message: `${message}成功`

+ 14 - 14
src/api/calendar.js

@@ -16,7 +16,7 @@ export function getSchedules (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/content/calendar/page',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -27,7 +27,7 @@ export function getSchedules (query) {
 export function getSchedule (id, options) {
   return request({
     url: `/content/calendar/${id}`,
-    method: 'get',
+    method: 'GET',
     ...options
   }).then(({ data }) => {
     const { id, type, name, resolutionRatio, eventDetail } = data
@@ -38,7 +38,7 @@ export function getSchedule (id, options) {
 export function addSchedule (data) {
   return add({
     url: '/content/calendar',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -46,7 +46,7 @@ export function addSchedule (data) {
 export function deleteSchedule ({ id, name }) {
   return del({
     url: `/content/calendar/${id}`,
-    method: 'delete'
+    method: 'DELETE'
   }, name)
 }
 
@@ -58,7 +58,7 @@ export function saveSchedulePrograms (schedule, programs) {
   const { id, type } = schedule
   return messageSend({
     url: `/content/calendar/${id}/${httpEnum[type]}`,
-    method: 'post',
+    method: 'POST',
     data: programs
   }, '保存')
 }
@@ -91,7 +91,7 @@ export function submitSchedule ({ id, type, name }, programs) {
     } else {
       send({
         url: `/content/calendar/${id}`,
-        method: 'get'
+        method: 'GET'
       }).then(({ data }) => {
         resolve(data.eventDetail)
       }, reject)
@@ -100,7 +100,7 @@ export function submitSchedule ({ id, type, name }, programs) {
     if (checkSchedule(type, programs)) {
       return submit({
         url: `/content/calendar/${id}/submit`,
-        method: 'post'
+        method: 'POST'
       }, name)
     }
     return Promise.reject()
@@ -110,7 +110,7 @@ export function submitSchedule ({ id, type, name }, programs) {
 export function resolveSchedule ({ id, name }) {
   return resolve({
     url: `/content/calendar/${id}/approval`,
-    method: 'post',
+    method: 'POST',
     data: { remark: '' }
   }, name)
 }
@@ -118,7 +118,7 @@ export function resolveSchedule ({ id, name }) {
 export function rejectSchedule ({ id, name }, remark) {
   return reject({
     url: `/content/calendar/${id}/reject`,
-    method: 'post',
+    method: 'POST',
     data: { remark }
   }, name)
 }
@@ -134,7 +134,7 @@ export function publish ({ id, type, name }, devices, options) {
     }
     return messageSend({
       url: '/orchestration/calendarRelease',
-      method: 'post',
+      method: 'POST',
       data
     }, '发布')
   })
@@ -144,7 +144,7 @@ export function getReleases (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/orchestration/calendarRelease/page',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -155,7 +155,7 @@ export function getReleases (query) {
 export function resolveRelease ({ id, name }) {
   return resolve({
     url: `/orchestration/calendarRelease/${id}/approval`,
-    method: 'post',
+    method: 'POST',
     data: { remark: '' }
   }, name)
 }
@@ -163,7 +163,7 @@ export function resolveRelease ({ id, name }) {
 export function rejectRelease ({ id, name }, remark) {
   return reject({
     url: `/orchestration/calendarRelease/${id}/reject`,
-    method: 'post',
+    method: 'POST',
     data: { remark }
   }, name)
 }
@@ -171,7 +171,7 @@ export function rejectRelease ({ id, name }, remark) {
 export function getTimeline (deviceId, options) {
   return request({
     url: `/content/deviceCalender/${deviceId}`,
-    method: 'get',
+    method: 'GET',
     ...options
   })
 }

+ 24 - 24
src/api/device.js

@@ -12,7 +12,7 @@ import {
 export function getRatios () {
   return request({
     url: '/device/resolutionRatio',
-    method: 'get'
+    method: 'GET'
   }).then(({ data }) => {
     return Object.keys(data).map(key => {
       return {
@@ -26,7 +26,7 @@ export function getRatios () {
 export function addDevice (data) {
   return add({
     url: '/device',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -42,7 +42,7 @@ export function updateDevice (data) {
 export function deleteDevice ({ id, name }) {
   return send({
     url: `/device/${id}/standbyDevice`,
-    method: 'get',
+    method: 'GET',
     params: { pageNum: 1, pageSize: 1 }
   }).then(({ data }) => {
     return confirm(data.length
@@ -50,7 +50,7 @@ export function deleteDevice ({ id, name }) {
       : `确定删除 ${name}?`
     ).then(() => messageSend({
       url: `/device/${id}`,
-      method: 'delete'
+      method: 'DELETE'
     }, '删除'))
   })
 }
@@ -59,7 +59,7 @@ export function getDevices (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/device/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -86,7 +86,7 @@ export function deactivateDevice ({ id, name }) {
 export function getDevice (id) {
   return request({
     url: `/device/${id}`,
-    method: 'get'
+    method: 'GET'
   })
 }
 
@@ -94,7 +94,7 @@ export function getSubDevices (query) {
   const { id, pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: `/device/${id}/standbyDevice`,
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -105,7 +105,7 @@ export function getSubDevices (query) {
 export function addSubDevice ({ id }, data) {
   return add({
     url: `/device/${id}/addStandby`,
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -113,7 +113,7 @@ export function addSubDevice ({ id }, data) {
 export function addProductType (data) {
   return add({
     url: '/productType',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -129,7 +129,7 @@ export function updateProductType (data) {
 export function deleteProductType ({ id, name }) {
   return del({
     url: `/productType/${id}`,
-    method: 'delete'
+    method: 'DELETE'
   }, name)
 }
 
@@ -137,7 +137,7 @@ export function getProductTypes (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/productType/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -148,7 +148,7 @@ export function getProductTypes (query) {
 export function addProduct (data) {
   return add({
     url: '/product',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -164,7 +164,7 @@ export function updateProduct (data) {
 export function deleteProduct ({ id, name }) {
   return del({
     url: `/product/${id}`,
-    method: 'delete'
+    method: 'DELETE'
   }, name)
 }
 
@@ -172,7 +172,7 @@ export function getProducts (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/product/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -183,7 +183,7 @@ export function getProducts (query) {
 export function addDeviceGroup (data) {
   return add({
     url: '/deviceGroup',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -199,7 +199,7 @@ export function updateDeviceGroup (data) {
 export function deleteDeviceGroup ({ id, name }) {
   return del({
     url: `/deviceGroup/${id}`,
-    method: 'delete'
+    method: 'DELETE'
   }, name)
 }
 
@@ -207,7 +207,7 @@ export function getDeviceGroups (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/deviceGroup/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -218,21 +218,21 @@ export function getDeviceGroups (query) {
 export function getDevicesByGroup (id) {
   return request({
     url: `/deviceGroup/${id}/device`,
-    method: 'get'
+    method: 'GET'
   })
 }
 
 export function getDeviceTree () {
   return request({
     url: '/deviceGroup/deviceTree',
-    method: 'get'
+    method: 'GET'
   })
 }
 
 export function addDeviceToGroup (id, deviceId) {
   return add({
     url: `/deviceGroup/${id}/device`,
-    method: 'post',
+    method: 'POST',
     data: [].concat(deviceId)
   })
 }
@@ -240,7 +240,7 @@ export function addDeviceToGroup (id, deviceId) {
 export function deleteDeviceFromGroup (id, { id: deviceId, name }) {
   return confirmAndSend('移除', name, {
     url: `/deviceGroup/${id}/device`,
-    method: 'delete',
+    method: 'DELETE',
     params: { deviceId }
   })
 }
@@ -248,7 +248,7 @@ export function deleteDeviceFromGroup (id, { id: deviceId, name }) {
 export function getDeviceStatistics (productId) {
   return request({
     url: '/device/listDeviceTotal',
-    method: 'post',
+    method: 'POST',
     data: { productId }
   })
 }
@@ -257,7 +257,7 @@ export function getDeviceAlarms (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/deviceException/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -268,7 +268,7 @@ export function getDeviceAlarms (query) {
 export function getSensors (options) {
   return request({
     url: '/device/sensorType',
-    method: 'get',
+    method: 'GET',
     ...options
   })
 }

+ 3 - 3
src/api/logger.js

@@ -5,7 +5,7 @@ export function getLogs (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/sysLog/list',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -16,13 +16,13 @@ export function getLogs (query) {
 export function getLog (id) {
   return send({
     url: `/sysLog/${id}`,
-    method: 'get'
+    method: 'GET'
   })
 }
 
 export function getBusiness () {
   return request({
     url: '/sysLog/business',
-    method: 'get'
+    method: 'GET'
   })
 }

+ 9 - 9
src/api/program.js

@@ -12,7 +12,7 @@ export function getPrograms (query) {
   const { pageNum: currentPage, pageSize: pageCount, ...params } = query
   return request({
     url: '/item/listByPage',
-    method: 'post',
+    method: 'POST',
     data: {
       currentPage, pageCount,
       ...params
@@ -23,7 +23,7 @@ export function getPrograms (query) {
 export function addProgram (data) {
   return add({
     url: '/item/add',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -31,7 +31,7 @@ export function addProgram (data) {
 export function deleteProgram ({ id, name }) {
   return del({
     url: '/item/delete',
-    method: 'get',
+    method: 'GET',
     params: { id }
   }, name)
 }
@@ -54,7 +54,7 @@ export function updateProgram (data) {
   formData.append('itemJsonStr', itemJsonStr)
   return request({
     url: '/item/update',
-    method: 'post',
+    method: 'POST',
     data: formData,
     timeout: 0,
     custom: true
@@ -64,7 +64,7 @@ export function updateProgram (data) {
 export function updateProgramName (data) {
   return update({
     url: '/item/updateItemName',
-    method: 'post',
+    method: 'POST',
     data
   })
 }
@@ -72,7 +72,7 @@ export function updateProgramName (data) {
 export function getProgram (id, options) {
   return request({
     url: `/item/getById/${id}`,
-    method: 'get',
+    method: 'GET',
     ...options
   })
 }
@@ -80,7 +80,7 @@ export function getProgram (id, options) {
 export function submitProgram ({ id, name }) {
   return submit({
     url: '/item/submit',
-    method: 'get',
+    method: 'GET',
     params: { id }
   }, name)
 }
@@ -88,14 +88,14 @@ export function submitProgram ({ id, name }) {
 export function resolveProgram ({ id, name }) {
   return resolve({
     url: '/item/reviewed',
-    method: 'get',
+    method: 'GET',
     params: { id }
   }, name)
 }
 export function rejectProgram ({ id, name }, reason) {
   return reject({
     url: '/item/reject',
-    method: 'get',
+    method: 'GET',
     params: { id },
     data: { reason }
   }, name)

+ 10 - 11
src/api/upgrade.js

@@ -8,7 +8,7 @@ export function getApks (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/apkUpgradeFile/queryListPage',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -16,34 +16,33 @@ export function getApks (query) {
   })
 }
 
-export function addApk (formData, progressCb) {
+export function addApk (data, onUploadProgress) {
   return request({
     url: '/apkUpgradeFile/add',
-    method: 'post',
-    data: formData,
+    method: 'POST',
     timeout: 0,
-    onUploadProgress: progressCb
+    data, onUploadProgress
   })
 }
 
 export function enableApk ({ id, name }) {
   return confirmAndSend('启用', name, {
     url: `/apkUpgradeFile/enable/${id}`,
-    method: 'get'
+    method: 'GET'
   })
 }
 
 export function disableApk ({ id, name }) {
   return confirmAndSend('禁用', name, {
     url: `/apkUpgradeFile/disable/${id}`,
-    method: 'get'
+    method: 'GET'
   })
 }
 
 export function delApk ({ id, name }) {
   return del({
     url: '/apkUpgradeFile/delBatchByIds',
-    method: 'post',
+    method: 'POST',
     data: [id]
   }, name)
 }
@@ -52,7 +51,7 @@ export function getVersions (query) {
   const { pageNum: pageIndex, pageSize, ...params } = query
   return request({
     url: '/apkUpgradePolicy/queryListPage',
-    method: 'get',
+    method: 'GET',
     params: {
       pageIndex, pageSize,
       ...params
@@ -63,7 +62,7 @@ export function getVersions (query) {
 export function deployVersion (version) {
   return confirmAndSend('发布', version.name, {
     url: '/apkUpgradePolicy/add',
-    method: 'post',
+    method: 'POST',
     data: version
   })
 }
@@ -71,7 +70,7 @@ export function deployVersion (version) {
 export function delVersion ({ id, deviceName, versionName, status }) {
   return confirmAndSend('删除', `对${deviceName}的${versionName}升级${status === 1 ? '' : '记录'}`, {
     url: '/apkUpgradePolicy/delBatchByIds',
-    method: 'post',
+    method: 'POST',
     data: [id]
   })
 }

+ 3 - 3
src/layout/components/Navbar/UploadDashboard/index.vue

@@ -17,8 +17,8 @@
       <template v-if="show">
         <el-upload
           ref="upload"
-          class="c-upload-dashboard__item o-upload u-pointer"
-          :class="{ smaller: hasFile }"
+          class="c-upload-dashboard__item o-upload"
+          :class="{ 'l-flex__fill': !hasFile }"
           action="none"
           :accept="accept"
           :auto-upload="false"
@@ -112,7 +112,7 @@ export default {
 
 @keyframes breathe {
   0% {
-    text-shadow: 0 0 2px rgba($blue, .5);
+    text-shadow: 0 0 2px rgba($blue, 0.5);
   }
   100% {
     text-shadow: 0 0 20px $blue;

+ 65 - 0
src/scss/bem/_component.scss

@@ -148,6 +148,10 @@
       width: 50px;
     }
 
+    &.large {
+      width: 180px;
+    }
+
     &.required::before {
       content: '*';
       color: #ff0000;
@@ -269,3 +273,64 @@
   justify-content: center;
   align-items: center;
 }
+
+.c-info {
+  color: $black;
+  line-height: 1;
+
+  &.large {
+    .c-info__title {
+      width: 180px;
+    }
+  }
+
+  &__block {
+    padding: 20px 32px;
+    background-color: #f5f7f9;
+
+    & + & {
+      margin-top: 8px;
+    }
+  }
+
+  &__item + &__item {
+    margin-left: 20px;
+  }
+
+  &__title {
+    width: 120px;
+    color: $info--dark;
+  }
+
+  &__value {
+    font-size: 18px;
+    font-weight: bold;
+
+    &.primary {
+      color: $blue;
+    }
+  }
+
+  &__edit {
+    color: $blue;
+    font-size: 14px;
+  }
+}
+
+.c-info-grid {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
+  grid-row-gap: $spacing;
+  grid-column-gap: $spacing;
+  align-items: start;
+
+  &.less {
+    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
+  }
+
+  &__item {
+    height: 180px;
+    border: 1px solid $info;
+    border-radius: 2px;
+  }
+}

+ 7 - 11
src/scss/bem/_object.scss

@@ -44,14 +44,14 @@
   }
 
   &.success {
-    background-color: #04a681;
+    background-color: $success--dark;
 
     &:hover {
-      background-color: rgba(#04a681, .8);
+      background-color: rgba($success--dark, .8);
     }
 
     &:active {
-      background-color: darken(#04a681, 5%);
+      background-color: darken($success--dark, 5%);
     }
   }
 
@@ -203,27 +203,23 @@
 }
 
 .o-upload {
-  flex: 1 0 auto;
   display: flex;
 
-  &.smaller {
-    flex: none;
-  }
-
   .el-upload {
     display: flex;
     flex: 1 1 auto;
   }
 
   .el-upload-dragger {
-    flex: 1 1 auto;
+    flex: 1 1 0;
     display: flex;
     flex-direction: column;
     justify-content: center;
     align-items: center;
     min-width: 0;
+    width: auto;
     height: auto;
-    padding: $spacing 0;
+    padding: $spacing;
     color: $gray;
     font-size: 14px;
     font-weight: bold;
@@ -265,4 +261,4 @@
   &:hover {
     color: $blue;
   }
-}
+}

+ 4 - 1
src/scss/helpers/_variables.scss

@@ -18,5 +18,8 @@ $warning--light: #ebb563;
 $error: #f56c6c;
 $error--dark: #e51414;
 
+$info: #d5d9e4;
+$info--dark: #8e929c;
+
 $spacing: 16px;
-$radius: 8px;
+$radius: 8px;

+ 3 - 0
src/views/device/category/index.vue

@@ -126,6 +126,9 @@ export default {
       }
     }
   },
+  created () {
+    this.getList()
+  },
   methods: {
     check (item) {
       if (!item.name) {

+ 1 - 1
src/views/device/detail/components/DeviceAlarm.vue

@@ -170,7 +170,7 @@ export default {
 
   &__block {
     height: 180px;
-    border: 1px solid #d5d9e4;
+    border: 1px solid $info;
     border-radius: 2px;
   }
 }

+ 1 - 40
src/views/device/detail/components/DeviceInfo.vue

@@ -3,7 +3,7 @@
     <div class="l-flex--row has-bottom-padding u-bold">
       <span class="c-sibling-item">设备信息</span>
       <span
-        class="c-sibling-item o-edit u-pointer"
+        class="c-sibling-item c-info__edit u-pointer"
         @click="toEdit"
       >
         <i class="el-icon-edit" />
@@ -150,42 +150,3 @@ export default {
   }
 }
 </script>
-
-<style lang="scss" scoped>
-.c-info {
-  color: $black;
-  line-height: 1;
-
-  &__block {
-    padding: 20px 32px;
-    background-color: #f5f7f9;
-
-    & + & {
-      margin-top: 8px;
-    }
-  }
-
-  &__item + &__item {
-    margin-left: 20px;
-  }
-
-  &__title {
-    width: 120px;
-    color: #8e929c;
-  }
-
-  &__value {
-    font-size: 18px;
-    font-weight: bold;
-
-    &.primary {
-      color: $blue;
-    }
-  }
-}
-
-.o-edit {
-  color: $blue;
-  font-size: 14px;
-}
-</style>

+ 18 - 38
src/views/device/detail/components/DeviceStatus.vue

@@ -1,16 +1,9 @@
 <template>
   <div class="l-flex--col">
-    <div class="l-flex--row l-flex__none c-status-bar">
-      <div
-        v-for="tab in tabs"
-        :key="tab.key"
-        class="l-flex__none c-status-bar__item u-pointer"
-        :class="{ active: tab.key === active }"
-        @click="active = tab.key"
-      >
-        {{ tab.name }}
-      </div>
-    </div>
+    <tabs
+      :items="tabs"
+      :active.sync="active"
+    />
     <div class="l-flex__fill u-overflow-y--auto">
       <component
         :is="activeComponent"
@@ -21,12 +14,18 @@
 </template>
 
 <script>
+import {
+  startSensor,
+  stopSensor
+} from '../monitor'
+import Tabs from './Tabs'
 import DeviceRuntime from './DeviceRuntime'
 import DeviceSensor from './DeviceSensor'
 
 export default {
   name: 'DeviceStatus',
   components: {
+    Tabs,
     DeviceRuntime,
     DeviceSensor
   },
@@ -50,39 +49,20 @@ export default {
           return null
       }
     }
+  },
+  activated () {
+    startSensor()
+  },
+  deactivated () {
+    stopSensor()
   }
 }
 </script>
 
-<style lang="scss" scoped>
-.c-status-bar {
-  align-self: flex-start;
-  padding: 8px 12px;
-  margin-bottom: $spacing;
-  border-radius: 2px;
-  background-color: #f4f7fb;
-  overflow-x: auto;
-
-  &__item {
-    color: #8e929c;
-    font-size: 16px;
-    line-height: 1;
-
-    & + & {
-      margin-left: 32px;
-    }
-
-    &.active {
-      color: $blue;
-    }
-  }
-}
-</style>
-
 <style lang="scss">
 .c-runtime {
   padding: 12px 16px 16px;
-  color: #d5d9e4;
+  color: $info;
   font-size: 14px;
   line-height: 1;
 
@@ -133,7 +113,7 @@ export default {
   }
 
   &__title {
-    color: #8e929c;
+    color: $info--dark;
   }
 
   &__list {

+ 3 - 2
src/views/device/detail/components/Sensor.vue

@@ -72,6 +72,7 @@ import {
 } from '../monitor'
 
 export default {
+  name: 'DeviceSensor',
   props: {
     type: {
       type: String,
@@ -157,13 +158,13 @@ export default {
 .o-senser {
   &__current {
     margin-top: 6px;
-    color: #d5d9e4;
+    color: $info;
     font-size: 12px;
   }
 
   &__more {
     padding: 8px 0;
-    color: #8e929c;
+    color: $info--dark;
     font-size: 14px;
     border-bottom: 1px solid #edf0f6;
   }

+ 0 - 20
src/views/device/detail/index.vue

@@ -223,23 +223,3 @@ export default {
   }
 }
 </style>
-
-<style lang="scss">
-.c-info-grid {
-  display: grid;
-  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
-  grid-row-gap: $spacing;
-  grid-column-gap: $spacing;
-  align-items: start;
-
-  &.less {
-    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
-  }
-
-  &__item {
-    height: 180px;
-    border: 1px solid #d5d9e4;
-    border-radius: 2px;
-  }
-}
-</style>

+ 28 - 10
src/views/device/detail/monitor.js

@@ -29,9 +29,6 @@ export function start (device) {
   createImmediateType('online', { parser: onlineParser })
   createLoadType('status', { defaults: '未知', parser: statusParser })
   createLoopType('download', { parser: downloadParser })
-  if (__SENSOR__) {
-    updateSensors(createLoopType('sensor', { parser: sensorParser }))
-  }
 }
 
 export function stop () {
@@ -254,23 +251,44 @@ function transform (type, arr) {
   })
 }
 
+export function startSensor () {
+  let sensor = types.get('sensor')
+  if (sensor) {
+    if (sensor.running) {
+      return
+    }
+    sensor.running = true
+  } else {
+    sensor = createLoopType('sensor', { parser: sensorParser })
+  }
+  updateSensors(sensor)
+}
+
+export function stopSensor () {
+  const sensor = types.get('sensor')
+  if (sensor) {
+    sensor.running = false
+  }
+}
+
 function updateSensors (inst) {
   inst.running && getSensors({ custom: true }).then(({ data }) => {
     inst.running && onUpdate(inst, data)
-  }).finally(() => {
+    return 5000
+  }, () => 2000).then(delay => {
     if (inst.running) {
-      setTimeout(updateSensors, 5000, inst)
+      setTimeout(updateSensors, delay, inst)
     }
   })
 }
 
 function sensorParser (inst, map) {
   Object.keys(map).forEach(type => {
-    let inst = types.get(type)
-    if (!inst) {
-      inst = createLoopType(type)
+    let sensorInst = types.get(type)
+    if (!sensorInst) {
+      sensorInst = createLoopType(type)
     }
-    inst.value = transform(type, map[type])
-    onUpdate(inst)
+    sensorInst.value = transform(type, map[type])
+    onUpdate(sensorInst)
   })
 }

+ 3 - 0
src/views/device/group/index.vue

@@ -279,6 +279,9 @@ export default {
       deviceOptions: createListOptions()
     }
   },
+  created () {
+    this.getList()
+  },
   methods: {
     check (item) {
       if (!item.name) {

+ 0 - 3
src/views/device/mixins/index.js

@@ -13,9 +13,6 @@ export default {
       return this.isAdd ? `新增${this.type}` : `编辑${this.type}`
     }
   },
-  created () {
-    this.getList()
-  },
   methods: {
     getDefaults () {
       return { name: '', remark: '' }

+ 3 - 0
src/views/device/product/index.vue

@@ -209,6 +209,9 @@ export default {
       return this.loaded ? this.typeOptions.slice(1) : this.isAdd ? [] : [{ value: this.currObj.productTypeId, label: this.productTypeName }]
     }
   },
+  created () {
+    this.getList()
+  },
   methods: {
     _getProductTypes () {
       this.fetching = true

+ 0 - 8
src/views/profile/index.vue

@@ -340,14 +340,6 @@ export default {
     checkBind () {
       if (!this.wechat && !this.$checkTimer) {
         this.$checkTimer = setInterval(this.check, 2000)
-        // setTimeout(() => {
-        //   this.updateUser({
-        //     attributes: {
-        //       ...this.user.attributes,
-        //       wechat: ['9999']
-        //     }
-        //   }, null)
-        // }, 5000)
       }
     },
     check () {

+ 21 - 23
src/views/upgrade/index.vue

@@ -150,29 +150,27 @@
       :before-close="close"
     >
       <div class="c-form large">
-        <div class="c-form__section fill">
-          <el-upload
-            ref="upload"
-            class="o-upload u-pointer"
-            action="none"
-            accept=".apk"
-            :auto-upload="false"
-            :show-file-list="false"
-            :on-change="onChange"
-            drag
-          >
-            <div class="l-flex--row">
-              <i class="o-upload__icon el-icon-upload" />
-              <template v-if="apk.file">
-                <div class="o-upload__file">{{ apk.file.name }}</div>
-              </template>
-              <template v-else>
-                拖拽文件到此或
-                <span class="o-upload__tip">点击选择文件</span>
-              </template>
-            </div>
-          </el-upload>
-        </div>
+        <el-upload
+          ref="upload"
+          class="c-form__section fill o-upload"
+          action="none"
+          accept=".apk"
+          :auto-upload="false"
+          :show-file-list="false"
+          :on-change="onChange"
+          drag
+        >
+          <div class="l-flex--row">
+            <i class="o-upload__icon el-icon-upload" />
+            <template v-if="apk.file">
+              <div class="o-upload__file">{{ apk.file.name }}</div>
+            </template>
+            <template v-else>
+              拖拽文件到此或
+              <span class="o-upload__tip">点击选择文件</span>
+            </template>
+          </div>
+        </el-upload>
         <div class="c-form__section">
           <span class="c-form__label required">文件名:</span>
           <el-input