Files
cli/test/cnb.ts

32 lines
905 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()