From 34dd55089e3aa0b4da32d364c2134cb599be048a Mon Sep 17 00:00:00 2001 From: ShiLong Date: Tue, 16 Jul 2024 16:57:18 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#IADDWP]=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0react-native-sensitive-info=E6=8C=87=E5=AF=BC=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-sensitive-info.md | 235 +++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 zh-cn/react-native-sensitive-info.md diff --git a/zh-cn/react-native-sensitive-info.md b/zh-cn/react-native-sensitive-info.md new file mode 100644 index 00000000..218ab41c --- /dev/null +++ b/zh-cn/react-native-sensitive-info.md @@ -0,0 +1,235 @@ +模板版本:v0.2.2 + +

+

react-native-sensitive-info

+

+ +

+ + Supported platforms + + + License + +

+ + +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-sensitive-info) + + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-sensitive-info Releases](https://github.com/react-native-oh-library/react-native-sensitive-info/releases),并下载适用版本的 tgz 包。 + +进入到工程目录并输入以下命令: + +> [!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-sensitive-info@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-sensitive-info@file:# +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import React, { useCallback, useState } from 'react'; +import { Alert, Button, SafeAreaView, Text } from 'react-native'; +import SInfo from 'react-native-sensitive-info'; + +const Home: React.FC = () => { + + const [logText, setLogText] = useState(''); + async function runTest() { + const options = { + sharedPreferencesName: 'exampleAppTest', + keychainService: 'exampleAppTest', + }; + let dbgText = ''; + dbgText += `setItem(key1, value1): ${await SInfo.setItem( + 'key1', + 'value1', + options, + )}\n`; + dbgText += `setItem(key2, value2): ${await SInfo.setItem( + 'key2', + 'value2', + options, + )}\n`; + dbgText += `setItem(key3, value3): ${await SInfo.setItem( + 'key3', + 'value3', + options, + )}\n`; + dbgText += `getItem(key2): ${await SInfo.getItem('key2', options)}\n`; + dbgText += `delItem(key2): ${await SInfo.deleteItem('key2', options)}\n`; + dbgText += `getAllItems():\n`; + const allItems = await SInfo.getAllItems(options); + for (const key in allItems) { + dbgText += ` - ${key} : ${allItems[key]}\n`; + } + setLogText(dbgText); + } + runTest(); + + return ( + +