feat: add query-login
This commit is contained in:
22
libs/query-login/src/test/login.ts
Normal file
22
libs/query-login/src/test/login.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { QueryLogin } from '../query-login';
|
||||
import { Query } from '@kevisual/query';
|
||||
const query = new Query({
|
||||
url: 'https://kevisual.silkyai.cn/api/router',
|
||||
});
|
||||
query.before(async (options) => {
|
||||
console.log('before', options);
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
};
|
||||
}
|
||||
return options;
|
||||
});
|
||||
const queryLogin = new QueryLogin({
|
||||
query,
|
||||
isBrowser: true,
|
||||
});
|
||||
// @ts-ignore
|
||||
window.queryLogin = queryLogin;
|
||||
Reference in New Issue
Block a user