Kaynağa Gözat

feat: remove switch operation of device

Casper Dai 3 yıl önce
ebeveyn
işleme
981ee2253f

+ 14 - 14
src/layout/components/Sidebar/Link.vue

@@ -1,43 +1,43 @@
 <template>
   <component
     :is="type"
-    v-bind="linkProps(to)"
+    v-bind="linkProps"
   >
     <slot />
   </component>
 </template>
 
 <script>
-import { isExternal } from '@/utils/validate'
-
 export default {
   props: {
-    to: {
-      type: String,
+    item: {
+      type: Object,
       required: true
     }
   },
   computed: {
-    isExternal () {
-      return isExternal(this.to)
-    },
     type () {
-      if (this.isExternal) {
+      if (this.item.meta.external) {
         return 'a'
       }
       return 'router-link'
-    }
-  },
-  methods: {
+    },
     linkProps (to) {
-      if (this.isExternal) {
+      if (this.item.meta.external) {
         return {
           href: to,
           target: '_blank',
           rel: 'noopener'
         }
       }
-      return { to }
+      if (this.item.meta.internal) {
+        return {
+          to: this.item.path.replace(/internal:/, '')
+        }
+      }
+      return {
+        to: this.item.path
+      }
     }
   }
 }

+ 1 - 1
src/layout/components/Sidebar/SidebarItem.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <template v-if="!item.children">
-      <app-link :to="item.path">
+      <app-link :item="item">
         <el-menu-item :index="item.path">
           <item
             :icon="item.meta.icon"

+ 5 - 5
src/layout/components/Sidebar/index.vue

@@ -46,7 +46,7 @@ function filterRoutes (routes, basePath) {
     if (route.hidden) {
       return
     }
-    const { name, meta = {} } = route
+    const { meta = {} } = route
     const path = basePath ? resolve(basePath, route.path) : route.path
     let children = route.children
     if (children) {
@@ -55,13 +55,13 @@ function filterRoutes (routes, basePath) {
         return
       }
       if (children.length === 1) {
-        const { path: cpath, name: cname, meta: cmeta = {} } = children[0]
-        res.push({ path: resolve(path, cpath), name: cname, meta: { ...meta, ...cmeta } })
+        const { path: cpath, meta: cmeta = {} } = children[0]
+        res.push({ path: resolve(path, cpath), meta: { ...meta, ...cmeta } })
         return
       }
-      res.push({ path, name, meta, children })
+      res.push({ path, meta, children })
     } else {
-      res.push({ path, name, meta })
+      res.push({ path, meta })
     }
   })
 

+ 15 - 47
src/router/index.js

@@ -13,7 +13,7 @@ Vue.use(Router)
  * sub-menu only appear when route children.length >= 1
  * dev: true,                      if set true, item will not show in production
  * hidden: true,                   if set true, item will not show in the sidebar(default is false)
- * name:'router-name' ,            if it is not a wrapping layer(Layout or Solo), it must be set!!!
+ * name:'router-name' ,            if it is a manual jump, it must be set!!!
  * include: ['admin'],             control the page roles (you can set multiple roles)
  * access: 'manage-profile',       control the page access
  * meta : {
@@ -67,14 +67,12 @@ export const asyncRoutes = [
     meta: { title: '内容管理', icon: 'am' },
     children: [
       {
-        name: 'media-list',
         path: 'media',
         component: () => import('@/views/screen/material/media/index'),
         access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
         meta: { title: '资源' }
       },
       {
-        name: 'program-list',
         path: 'program',
         component: () => import('@/views/screen/material/program/index'),
         access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
@@ -129,14 +127,12 @@ export const asyncRoutes = [
         ]
       },
       {
-        name: 'tag',
         path: 'tag',
         component: () => import('@/views/screen/material/tag/index'),
         access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
         meta: { title: '资源标签' }
       },
       {
-        name: 'material-review',
         path: 'review',
         component: () => import('@/views/screen/review/single/index'),
         access: Access.MANAGE_GROUP,
@@ -150,14 +146,12 @@ export const asyncRoutes = [
     meta: { title: '智能信发', icon: 'cm' },
     children: [
       {
-        name: 'deploy-device',
         path: 'deploy/device',
         component: () => import('@/views/screen/deploy/device/index'),
         access: Access.MANAGE_CALENDAR,
         meta: { title: '按设备发布' }
       },
       {
-        name: 'deploy-ratio',
         path: 'deploy/ratio',
         component: () => import('@/views/screen/deploy/ratio/index'),
         access: Access.MANAGE_CALENDAR,
@@ -191,7 +185,6 @@ export const asyncRoutes = [
         ]
       },
       {
-        name: 'deploy-history',
         path: 'history',
         component: () => import('@/views/screen/review/history/index'),
         access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
@@ -206,25 +199,21 @@ export const asyncRoutes = [
     access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
     children: [
       {
-        name: 'contract',
         path: 'contract',
         component: () => import('@/views/ad/contract/index'),
         meta: { title: '合同' }
       },
       {
-        name: 'task',
         path: 'list',
         component: () => import('@/views/ad/task/index'),
         meta: { title: '屏体上播管理' }
       },
       {
-        name: 'scheduling',
         path: 'scheduling',
         component: () => import('@/views/ad/scheduling/index'),
         meta: { title: '节目单' }
       },
       {
-        name: 'dataset',
         path: 'dataset',
         component: () => import('@/views/ad/dataset/index'),
         meta: { title: '填充素材包' }
@@ -257,19 +246,16 @@ export const asyncRoutes = [
         ]
       },
       {
-        name: 'device-timeline',
         path: 'timeline',
         component: () => import('@/views/device/timeline/index'),
         meta: { title: '排期预览' }
       },
       {
-        name: 'record',
         path: 'record',
         component: () => import('@/views/device/record/index'),
         meta: { title: '视频回采' }
       },
       {
-        name: 'group',
         path: 'group',
         component: () => import('@/views/device/group/index'),
         meta: { title: '分组管理' }
@@ -283,19 +269,16 @@ export const asyncRoutes = [
     meta: { title: '平台管理', icon: 'pm' },
     children: [
       {
-        name: 'settings',
         path: 'settings',
         component: () => import('@/views/realm/settings/index'),
         meta: { title: '功能管理' }
       },
       {
-        name: 'org',
         path: 'org',
         component: () => import('@/views/realm/org/index'),
         meta: { title: '组织管理' }
       },
       {
-        name: 'account',
         path: 'account',
         component: () => import('@/views/realm/user/index'),
         meta: { title: '账号管理' }
@@ -328,19 +311,16 @@ export const asyncRoutes = [
         ]
       },
       {
-        name: 'device-assign',
         path: 'device/assign',
         component: () => import('@/views/realm/assign/index'),
         meta: { title: '设备分配' }
       },
       {
-        name: 'ai-audit',
         path: 'ai/audit',
         component: () => import('@/views/realm/ai/ai-audit/index'),
         meta: { title: 'AI审核' }
       },
       {
-        name: 'ai-timing',
         path: 'ai/timing',
         component: () => import('@/views/realm/ai/ai-timing/index'),
         meta: { title: 'AI抽帧检测' }
@@ -354,13 +334,11 @@ export const asyncRoutes = [
     meta: { title: '应急广播', icon: 'bm' },
     children: [
       {
-        name: 'broadcast-deploy',
         path: 'deploy',
         component: () => import('@/views/broadcast/deploy/index'),
         meta: { title: '发布' }
       },
       {
-        name: 'broadcast-deploy-history',
         path: 'history',
         component: () => import('@/views/broadcast/history/index'),
         meta: { title: '发布历史' }
@@ -374,28 +352,22 @@ export const asyncRoutes = [
     meta: { icon: 'logger', title: '数据统计' },
     children: [
       {
-        name: 'statistic-asset',
         path: 'asset',
         component: () => import('@/views/dashboard/statistic/index'),
         meta: { title: '素材播放' }
       },
       {
         path: 'logger',
-        name: 'logger',
         component: () => import('@/views/realm/logger/index'),
         meta: { title: '操作日志' }
       },
       {
-        name: 'dashboard-v0',
-        path: 'v0',
-        component: () => import('@/views/dashboard/v0/index'),
-        meta: { title: '大数据V0' }
+        path: 'internal:dashboard/v0',
+        meta: { title: '大数据V0', internal: true }
       },
       {
-        name: 'dashboard-v1',
-        path: 'v1',
-        component: () => import('@/views/dashboard/v1/index'),
-        meta: { title: '大数据V1' }
+        path: 'internal:dashboard/v1',
+        meta: { title: '大数据V1', internal: true }
       }
     ]
   },
@@ -407,7 +379,6 @@ export const asyncRoutes = [
     children: [
       {
         path: 'tenant',
-        name: 'tenant',
         component: () => import('@/views/platform/tenant/index'),
         meta: { title: '租户管理' }
       },
@@ -432,31 +403,26 @@ export const asyncRoutes = [
         ]
       },
       {
-        name: 'broadcast-template',
         path: 'template',
         component: () => import('@/views/broadcast/template/index'),
         meta: { title: '应急广播模板管理' }
       },
       {
-        name: 'ai-stock',
         path: 'ai/stock',
         component: () => import('@/views/platform/ai-stock/index'),
         meta: { title: 'AI审核库存' }
       },
       {
         path: 'mqtt',
-        name: 'mqtt',
         component: () => import('@/views/platform/debug/index'),
         meta: { title: 'MQTT' }
       },
       {
         path: 'simulator',
-        name: 'simulator',
         component: () => import('@/views/platform/simulator/index'),
         meta: { title: '模拟器' }
       },
       {
-        name: 'cooperation',
         path: 'cooperation',
         component: () => import('@/views/platform/cooperation/index'),
         meta: { title: '合作意向' }
@@ -471,20 +437,17 @@ export const asyncRoutes = [
     children: [
       {
         path: 'transmitter',
-        name: 'transmitter',
         component: () => import('@/views/external/transmitter/index'),
         meta: { title: '发送控制设备' }
       },
       {
         dev: !__GATEWAY__,
         path: 'gateway',
-        name: 'gateway',
         component: () => import('@/views/external/gateway/index'),
         meta: { title: '网关' }
       },
       {
         path: 'camera',
-        name: 'camera',
         component: () => import('@/views/external/camera/index'),
         meta: { title: '摄像头' }
       }
@@ -497,19 +460,16 @@ export const asyncRoutes = [
     access: Access.MANAGE_TENANTS,
     children: [
       {
-        name: 'ad-asset-review',
         path: 'asset/review',
         component: () => import('@/views/ad/review-asset/index'),
         meta: { title: '素材审核' }
       },
       {
-        name: 'ad-order-review',
         path: 'order/review',
         component: () => import('@/views/ad/review-order/index'),
         meta: { title: '订单审核' }
       },
       {
-        name: 'ad-order-history',
         path: 'order/history',
         component: () => import('@/views/ad/history/index'),
         meta: { title: '订单历史' }
@@ -524,13 +484,11 @@ export const asyncRoutes = [
     children: [
       {
         path: 'apk',
-        name: 'upgrade-apk',
         component: () => import('@/views/platform/upgrade/index'),
         meta: { title: '版本管理' }
       },
       {
         path: 'deploy',
-        name: 'upgrade-deploy',
         component: () => import('@/views/platform/upgrade/deploy/index'),
         meta: { title: '发布升级' }
       }
@@ -543,6 +501,16 @@ export const asyncRoutes = [
     component: () => import('@/views/screen/material/program/ast/index'),
     props: true
   },
+  {
+    hidden: true,
+    path: '/d/dashboard/v0',
+    component: () => import('@/views/dashboard/v0/index')
+  },
+  {
+    hidden: true,
+    path: '/d/dashboard/v1',
+    component: () => import('@/views/dashboard/v1/index')
+  },
   {
     dev: !__DEVICE_DASHBARD__,
     hidden: true,

+ 0 - 29
src/views/dashboard/v0/DeviceInfo.vue

@@ -23,20 +23,6 @@
     </div>
 
     <div class="l-flex--row l-flex__fill center">
-      <button
-        class="l-flex__none  o-button"
-        @click="onSwitch(true)"
-      >
-        <i class="o-button__icon el-icon-switch-button" />
-        开机
-      </button>
-      <button
-        class="l-flex__none  o-button"
-        @click="onSwitch(false)"
-      >
-        <i class="o-button__icon el-icon-switch-button" />
-        关机
-      </button>
       <button
         class="l-flex__none  o-button"
         @click="onReboot"
@@ -131,21 +117,6 @@ export default {
         this.online = result[3] === 'online'
       }
     },
-    onSwitch (open) {
-      if (!this.online) {
-        this.$message({
-          type: 'warning',
-          message: '设备未上线,请稍后再试'
-        })
-        return
-      }
-      this.$confirm(
-        `立即${open ? '开机' : '关机'}?`,
-        { type: 'warning' }
-      ).then(() => {
-        this.sendTopic(open ? 'bootDevice' : 'shutdownDevice')
-      })
-    },
     onReboot () {
       if (!this.online) {
         this.$message({

+ 0 - 5
src/views/dashboard/v0/Map.vue

@@ -10,7 +10,6 @@
       :class="{ fullscreen }"
     >
       <div
-        v-if="mapMarkers.length"
         ref="map"
         class="l-flex__fill"
       />
@@ -71,10 +70,6 @@ export default {
       }, 100)
     },
     initMap (soon) {
-      if (!this.deviceList.length) {
-        return
-      }
-
       AMapLoader.load({
         key: process.env.VUE_APP_GAODE_MAP_KEY,
         version: '2.0',

+ 0 - 3
src/views/device/detail/components/DeviceInvoke/index.vue

@@ -3,7 +3,6 @@ import ScreenSwitch from './ScreenSwitch'
 import ScreenLight from './ScreenLight'
 import ScreenVolume from './ScreenVolume'
 import DeviceNetwork from './DeviceNetwork'
-import DeviceSwitch from './DeviceSwitch'
 import DeviceReboot from './DeviceReboot'
 import PLCSwitch from './PLCSwitch'
 import MultifunctionCardPowerSwitch from './MultifunctionCardPowerSwitch'
@@ -15,7 +14,6 @@ export default {
     ScreenLight,
     ScreenVolume,
     DeviceNetwork,
-    DeviceSwitch,
     DeviceReboot,
     PLCSwitch,
     MultifunctionCardPowerSwitch
@@ -44,7 +42,6 @@ export default {
       __STAGING__
         ? [
           h('DeviceNetwork', { props: this.$attrs }),
-          h('DeviceSwitch', { props: this.$attrs }),
           h('ScreenSwitch', { props: this.$attrs }),
           h('MultifunctionCardPowerSwitch', { props: this.$attrs }),
           h('PLCSwitch', { props: this.$attrs }),

+ 0 - 24
src/views/device/detail/dashboard/DeviceInfo.vue

@@ -13,13 +13,6 @@
         />
       </div>
     </div>
-    <button
-      class="l-flex__none c-sibling-item far o-button"
-      @click="onSwitch(false)"
-    >
-      <i class="o-button__icon el-icon-switch-button" />
-      关机
-    </button>
     <button
       class="l-flex__none c-sibling-item far o-button"
       @click="onReboot"
@@ -51,8 +44,6 @@ export default {
     return {
       online: this.device.activate && this.device.onlineStatus === 1,
       rebooting: false,
-      openFunctionKey: 'bootDevice',
-      closeFunctionKey: 'shutdownDevice',
       items: [
         {
           label: '名称',
@@ -81,21 +72,6 @@ export default {
       this.online = online
       this.rebooting = false
     },
-    onSwitch (open) {
-      if (!this.online) {
-        this.$message({
-          type: 'warning',
-          message: '设备未上线,请稍后再试'
-        })
-        return
-      }
-      this.$confirm(
-        `立即${open ? '开机' : '关机'}?`,
-        { type: 'warning' }
-      ).then(() => {
-        this.sendTopic(open ? this.openFunctionKey : this.closeFunctionKey)
-      })
-    },
     onReboot () {
       if (!this.online) {
         this.$message({