Browse Source

feat(env): __WECHAT__

whether the system support WeChat
Casper Dai 3 years ago
parent
commit
9e35fcde24

+ 2 - 0
.env

@@ -14,6 +14,8 @@ __GATEWAY__ = 'disabled'
 __SUB_DEVICE__ = 'disabled'
 # 设备接管
 __TAKEOVER__ = 'enabled'
+# 微信
+__WECHAT__ = 'enabled'
 
 VUE_APP_NAME = '浪潮屏媒安播云平台'
 

+ 3 - 0
.env.fujian

@@ -5,3 +5,6 @@ ENV = 'fujian'
 PLATFORM = 'fujian'
 
 VUE_APP_NAME = '万福千屏户外安播云平台'
+
+# 小程序
+__WECHAT__ = 'disabled'

+ 2 - 1
feature.js

@@ -26,6 +26,7 @@ module.exports = {
     ...createFeature('__DEVICE_DASHBARD__'),
     ...createFeature('__GATEWAY__'),
     ...createFeature('__SUB_DEVICE__'),
-    ...createFeature('__TAKEOVER__')
+    ...createFeature('__TAKEOVER__'),
+    ...createFeature('__WECHAT__')
   }
 }

+ 2 - 2
src/api/device.js

@@ -14,7 +14,7 @@ import {
 } from './base'
 import {
   AssetType,
-  AlarmStrategies
+  SupportedAlarmStrategies
 } from '@/constant'
 
 export function getRatiosWithUser () {
@@ -382,7 +382,7 @@ export function getDeviceAlarms (query) {
             }
             : { label: '-' }
         }
-        AlarmStrategies.forEach(({ key }) => {
+        SupportedAlarmStrategies.forEach(({ key }) => {
           alarm[key] = getTag(item[key])
         })
         return alarm

+ 6 - 4
src/constant.js

@@ -181,12 +181,14 @@ export const RoleAccess = {
 }
 
 export const AlarmStrategies = [
-  { key: 'note', label: '短信' },
-  { key: 'email', label: '邮件' },
-  { key: 'wechat', label: '微信' },
-  { key: 'wechatApplet', label: '小程序' }
+  { key: 'note', label: '短信', support: true },
+  { key: 'email', label: '邮件', support: true },
+  { key: 'wechat', label: '微信', support: !__WECHAT__ },
+  { key: 'wechatApplet', label: '小程序', support: !__WECHAT__ }
 ]
 
+export const SupportedAlarmStrategies = AlarmStrategies.filter(({ support }) => support)
+
 export const Sensor = {
   SMOKE: 0,
   TEMPERATURE: 1,

+ 2 - 1
src/global-api.js

@@ -1,7 +1,7 @@
 import {
   showLoading,
   closeLoading
-} from './utils/pop'
+} from '@/utils/pop'
 
 export function injectGlobalApi (Vue) {
   Vue.config.productionTip = false
@@ -11,6 +11,7 @@ export function injectGlobalApi (Vue) {
   }
 
   Vue.prototype.__PLACEHOLDER__ = __PLACEHOLDER__
+  Vue.prototype.__WECHAT__ = __WECHAT__
 
   Vue.prototype.$showLoading = showLoading
   Vue.prototype.$closeLoading = closeLoading

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

@@ -11,7 +11,7 @@
 <script>
 import { getDeviceAlarms } from '@/api/device'
 import { createListOptions } from '@/utils'
-import { AlarmStrategies } from '@/constant'
+import { SupportedAlarmStrategies } from '@/constant'
 
 export default {
   name: 'DeviceAlarm',
@@ -33,7 +33,7 @@ export default {
           { prop: 'type', label: '类型', 'min-width': 120 },
           { prop: 'handle', label: '处理方式' },
           { prop: 'status', label: '处理结果', type: 'tag' },
-          ...AlarmStrategies.map(({ key, label }) => {
+          ...SupportedAlarmStrategies.map(({ key, label }) => {
             return {
               prop: key,
               label: `${label}通知`,

+ 4 - 1
src/views/platform/profile/index.vue

@@ -78,7 +78,10 @@
               @update="updateUser({email}, '更新邮箱')"
             />
           </div>
-          <div class="l-flex--row center has-top-padding">
+          <div
+            v-if="__WECHAT__"
+            class="l-flex--row center has-top-padding"
+          >
             <div
               class="o-app u-pointer"
               @click="onClickWechat"

+ 2 - 2
src/views/realm/settings/api.js

@@ -1,4 +1,4 @@
-import { AlarmStrategies } from '@/constant'
+import { SupportedAlarmStrategies } from '@/constant'
 import {
   update,
   send,
@@ -26,7 +26,7 @@ export function getInformStrategy () {
 }
 
 function getStrategyOptions (strategy) {
-  return AlarmStrategies.map(({ key, label }) => {
+  return SupportedAlarmStrategies.map(({ key, label }) => {
     return {
       key, label,
       value: strategy[key]

+ 5 - 0
src/views/realm/settings/components/AlarmStratConfigDialog.vue

@@ -32,6 +32,7 @@
 </template>
 
 <script>
+import { AlarmStrategies } from '@/constant'
 import {
   getInformStrategy,
   updateInformStrategy
@@ -53,11 +54,15 @@ export default {
     },
     onSave (done) {
       const strategies = {}
+      const unsupports = AlarmStrategies.filter(({ support }) => !support)
       this.strategies.forEach(({ level, options }) => {
         const strategy = {}
         options.forEach(({ key, value }) => {
           strategy[key] = value
         })
+        unsupports.forEach(({ key }) => {
+          strategy[key] = false
+        })
         strategies[level] = strategy
       })
       updateInformStrategy(strategies).then(done)