Browse Source

:bug: 修改判断 config.NOTIFY_TYPE 是否包含 serial 的方法

Mizore 1 year ago
parent
commit
b488237d9c
1 changed files with 9 additions and 2 deletions
  1. 9 2
      script/main.lua

+ 9 - 2
script/main.lua

@@ -57,8 +57,15 @@ util_mobile = require "util_mobile"
 util_location = require "util_location"
 util_notify = require "util_notify"
 
--- 由于NOTIFY_TYPE支持多个配置,需按照包含来判断
-if string.find(config.NOTIFY_TYPE, "serial") then
+-- 由于 NOTIFY_TYPE 支持多个配置, 需按照包含来判断
+local containsValue = function(t, value)
+    if t == value then return true end
+    if type(t) ~= "table" then return false end
+    for k, v in pairs(t) do if v == value then return true end end
+    return false
+end
+
+if containsValue(config.NOTIFY_TYPE, "serial") then
     -- 串口配置
     uart.setup(1, 115200, 8, 1, uart.NONE)
     -- 串口接收回调