tmaito-authcode

0.0.3 • Public • Published

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` 进行调试
// auth_debug 可忽略权限认证
// auth_debug 可输出当前 authcode 及 authCodes

Readme

Keywords

none

Package Sidebar

Install

npm i tmaito-authcode

Weekly Downloads

1

Version

0.0.3

License

ISC

Unpacked Size

20.7 kB

Total Files

4

Last publish

Collaborators

  • zmh7057