Browse Source

feat: add feature flag __TAKEOVER__

Casper Dai 3 years ago
parent
commit
2ffe25fa26
3 changed files with 6 additions and 11 deletions
  1. 2 0
      .env
  2. 3 9
      feature.js
  3. 1 2
      src/views/device/detail/index.vue

+ 2 - 0
.env

@@ -8,6 +8,8 @@ __PLACEHOLDER__ = 'disabled'
 __SENSOR__ = 'disabled'
 # 设备仪表盘
 __DEVICE_DASHBARD__ = 'disabled'
+# 设备接管
+__TAKEOVER__ = 'disabled'
 
 # gateway
 VUE_APP_GATEWAY = ''

+ 3 - 9
feature.js

@@ -6,9 +6,7 @@ function isEnable (feature) {
 }
 
 function createFeature (feature) {
-  return {
-    [feature]: isEnable(feature)
-  }
+  return { [feature]: isEnable(feature) }
 }
 
 function getTimestamp () {
@@ -22,15 +20,11 @@ module.exports = {
   logger: isStaging || isEnable('LOGGER'),
   features: {
     __VERSION__: JSON.stringify(`v${require('./package.json').version}.${getTimestamp()}`),
-    // 未开发完的路由
     __DEV__: !isProd,
-    // 待测试的功能
     __STAGING__: !isProd || isStaging,
-    // 未开发的功能组件
     ...createFeature('__PLACEHOLDER__'),
-    // 传感器
     ...createFeature('__SENSOR__'),
-    // 设备仪表盘
-    ...createFeature('__DEVICE_DASHBARD__')
+    ...createFeature('__DEVICE_DASHBARD__'),
+    ...createFeature('__TAKEOVER__')
   }
 }

+ 1 - 2
src/views/device/detail/index.vue

@@ -105,7 +105,7 @@ export default {
         this.accessSet.has(Access.MANAGE_DEVICE) ? { key: 'DeviceInvoke', label: '设备操控' } : null,
         __SENSOR__ ? { key: 'Sensors', label: '传感器' } : null,
         { key: 'DeviceExternal', label: '全链路监测' },
-        this.accessSet.has(Access.MANAGE_GROUP) ? { key: 'DeviceTakeOver', label: '接管' } : null
+        __TAKEOVER__ && this.accessSet.has(Access.MANAGE_GROUP) ? { key: 'DeviceTakeOver', label: '接管' } : null
       ].filter(Boolean)
     }
   },
@@ -151,7 +151,6 @@ export default {
   },
   methods: {
     onBack () {
-      console.log(this.$route.name)
       switch (this.$route.name) {
         case 'device-management-detail':
           this.$router.replace({