From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码

---
 vf205_access/dxmodules/dxMap.js |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/vf205_access/dxmodules/dxMap.js b/vf205_access/dxmodules/dxMap.js
new file mode 100644
index 0000000..0f73d1d
--- /dev/null
+++ b/vf205_access/dxmodules/dxMap.js
@@ -0,0 +1,109 @@
+import { mapClass } from './libvbar-m-dxmap.so'
+/**
+ * build:20240407
+ * map 缁勪欢锛屽彲浠ュ湪鍐呭瓨閲岃鍐檏ey/value
+ */
+const mapObj = new mapClass();
+
+const map = {
+    get: function (name) {
+        if (!name || name.length == 0) {
+            throw new Error("dxMap.get:name should not be null or empty")
+        }
+        //绗竴娆ut浼氳嚜鍔ㄥ垱寤哄疄渚�
+        return {
+            /**
+             * @brief   鑾峰彇Map涓殑鎵�鏈夐敭,杩斿洖涓�涓暟缁�
+             */
+            keys: function () {
+                let all = mapObj.keys(name)
+                return all == null ? [] : all
+            },
+            /**
+             * @brief   鏍规嵁key鑾峰彇value
+             */
+            get: function (key) {
+                if (!key || key.length < 1) {
+                    throw new Error("The 'key' parameter cannot be null or empty")
+                }
+                // put绌哄瓧绗︿覆锛実et浼氭槸null
+                let value = mapObj.get(name, key)
+                if (value === undefined || value === null) {
+                    value = ""
+                }
+                return _parseString(value)
+            },
+            /**
+             * @brief   鍚慚ap涓彃鍏ラ敭鍊煎
+             */
+            put: function (key, value) {
+                if (!key || key.length < 1) {
+                    throw new Error("The 'key' parameter cannot be null or empty")
+                }
+                if (value == null || value == undefined) {
+                    throw new Error("The 'value' parameter cannot be null or empty")
+                }
+                return mapObj.insert(name, key, _stringifyValue(value))
+            },
+            /**
+             * @brief   鏍规嵁Key鍒犻櫎閿�煎
+             */
+            del: function (key) {
+                if (!key || key.length < 1) {
+                    throw new Error("The 'key' parameter cannot be null or empty")
+                }
+                return mapObj.delete(name, key)
+            },
+            /**
+             * 涓嶅啀浣跨敤浜嗭紝灏遍攢姣�
+             */
+            destroy: function () {
+                return mapObj.destroy(name)
+            },
+        }
+    }
+
+}
+function _stringifyValue(value) {
+    const type = typeof value
+    if (type === 'string') {
+        return value
+    }
+    if (type === 'number') {
+        return '#n#' + value
+    }
+    if (type === 'boolean') {
+        return '#b#' + value
+    }
+    if (type === 'object') {
+        // 濡傛灉鏄璞★紝杩涗竴姝ュ垽鏂槸鍚︿负鏁扮粍
+        if (Array.isArray(value)) {
+            return '#a#' + JSON.stringify(value);
+        }// else if (value === null) { 鍓嶉潰宸茬粡瑙勯伩浜唍ull鐨勬儏鍐�
+        return '#o#' + JSON.stringify(value)
+    }
+    if (type === 'function') {
+        throw new Error("The 'value' parameter should not be function")
+    }
+}
+function _parseString(str) {
+    if (str.startsWith('#n#')) {
+        // 瑙f瀽鏁板瓧
+        const numberStr = str.substring(3);
+        return numberStr.includes('.') ? parseFloat(numberStr) : parseInt(numberStr, 10);
+    } else if (str.startsWith('#b#')) {
+        // 瑙f瀽甯冨皵鍊�
+        return str.substring(3) === 'true';
+    } else if (str.startsWith('#a#')) {
+        // 瑙f瀽鏁扮粍
+        return JSON.parse(str.substring(3));
+    } else if (str.startsWith('#o#')) {
+        // 瑙f瀽瀵硅薄
+        return JSON.parse(str.substring(3));
+    } else {
+        // 榛樿鎯呭喌涓嬶紝灏嗗瓧绗︿覆杩斿洖
+        return str;
+    }
+}
+export default map;
+

--
Gitblit v1.9.3