diff --git a/test/cnb.ts b/test/cnb.ts new file mode 100644 index 0000000..86584e9 --- /dev/null +++ b/test/cnb.ts @@ -0,0 +1,32 @@ +import { CNB } from '@kevisual/cnb' +import { useKey } from '@kevisual/context' +import { QueryLoginNode } from '@kevisual/api/query-login-node' +import { Query } from '@kevisual/query' +const queryLogin = new QueryLoginNode({ + query: new Query({ url: 'https://kevisual.cn/api/router' }) +}) +// const token = useKey('CNB_TOKEN'); +const token = '0054fuHjqpQ279mOva3H3ImIDlD' +const cnb = new CNB({ + token +}) +export const cnbLogin = async () => { + const userInfo = await cnb.user.getUser() + console.log('CNB用户信息', userInfo); +} +cnbLogin() + +const testCnbLogin = async () => { + const res = await queryLogin.loginByCnb({ + cnbToken: token, + }) + console.log('CNB登录结果', res); + if (res.code === 200) { + const userInfo = await queryLogin.checkLocalUser() + console.log('CNB登录成功,用户信息', userInfo); + } else { + console.log('CNB登录失败', res); + } +} + +// testCnbLogin() \ No newline at end of file