Install
``sh`
npm i @tmaito/authcode
// or
yarn add @tmaito/authcode
Use
`js
import { isDevEnv, Authcode, AuthcodeContext, AuthcodeProvider } form '@tmaito/authcode';
const authCodes = [
{
"resourceCode": "S20600002"
},
{
"resourceCode": "S20600001"
}
]
// 提示:
// authKey 是为了将 authCodes 过滤为
// [S20600002, S20600001]
{...children}
// 可以通过一下方式获取到 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