0.2.2 • Published 2 years ago

@tmaito/authcode v0.2.2

Weekly downloads
80
License
ISC
Repository
-
Last release
2 years ago

Quick Start

Install

npm i @tmaito/authcode
// or
yarn add @tmaito/authcode

Use

import  { isDevEnv, Authcode, AuthcodeContext, AuthcodeProvider } form '@tmaito/authcode';

const authCodes = [
	{
    "resourceCode": "S20600002"
  },
  {
    "resourceCode": "S20600001"
  }
]

// **提示:**
// `authKey` 是为了将 `authCodes` 过滤为
// [S20600002, S20600001]

<AuthcodeProvider authCodes={authCodes} authKey="resourceCode">
	{...children}
</AuthcodeProvider>

<Authcode authcode="A00101007">
	<Button>发票关联</Button>
</Authcode>

// 可以通过一下方式获取到 authCodes
	const { authCodes } = useContext(AuthcodeContext);

// 当前是否为本地开发环境, 判断依据 `localhost`、`127.0.0.1`、`0.0.0.0`
console.log(isDevEnv);

// 可以在域名追加参数 `ignore_auth`, `auth_debug` 进行调试
// ignore_auth=1 可忽略权限认证
// auth_debug=1 可输出当前 authcode 及 authCodes
0.2.2

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago