fix: update login error
This commit is contained in:
parent
4b16ec8499
commit
d56c4c15f2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/envision-cli",
|
||||
"version": "0.0.33",
|
||||
"version": "0.0.34",
|
||||
"description": "envision command tools",
|
||||
"main": "dist/app.mjs",
|
||||
"type": "module",
|
||||
@ -33,7 +33,7 @@
|
||||
],
|
||||
"author": "abearxiong",
|
||||
"devDependencies": {
|
||||
"@kevisual/query": "0.0.13",
|
||||
"@kevisual/query": "0.0.15",
|
||||
"@kevisual/query-login": "workspace:*",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.3",
|
||||
|
25
pnpm-lock.yaml
generated
25
pnpm-lock.yaml
generated
@ -37,8 +37,8 @@ importers:
|
||||
version: 6.2.2(@types/node@22.13.11)
|
||||
devDependencies:
|
||||
'@kevisual/query':
|
||||
specifier: 0.0.13
|
||||
version: 0.0.13(encoding@0.1.13)(ws@8.18.0)
|
||||
specifier: 0.0.15
|
||||
version: 0.0.15(encoding@0.1.13)(ws@8.18.0)
|
||||
'@kevisual/query-login':
|
||||
specifier: workspace:*
|
||||
version: link:submodules/kevisual-query-login
|
||||
@ -118,8 +118,8 @@ importers:
|
||||
specifier: ^0.0.1
|
||||
version: 0.0.1(rollup@4.36.0)(tslib@2.8.1)(typescript@5.8.2)
|
||||
'@kevisual/query':
|
||||
specifier: ^0.0.12
|
||||
version: 0.0.12(encoding@0.1.13)(ws@8.18.0)
|
||||
specifier: ^0.0.15
|
||||
version: 0.0.15(encoding@0.1.13)(ws@8.18.0)
|
||||
dotenv:
|
||||
specifier: ^16.4.7
|
||||
version: 16.4.7
|
||||
@ -447,11 +447,8 @@ packages:
|
||||
'@kevisual/load@0.0.6':
|
||||
resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==}
|
||||
|
||||
'@kevisual/query@0.0.12':
|
||||
resolution: {integrity: sha512-/1lZJhNCdcNG4a2Nncl55XC/nha5+GZiJPQdP77lufv2dnZfcssA7NHSZ2Ubh0Pm0HWV22IiGfQMiaYl2pkK1Q==}
|
||||
|
||||
'@kevisual/query@0.0.13':
|
||||
resolution: {integrity: sha512-gSEIDiCvwSaLLAFZv4vam4wSrMsaCuQ3VGjE3kwRwZ8urlVH1TOA+NUO908A22p9m1Iij7Y1Q/JlfSJi2QzuKQ==}
|
||||
'@kevisual/query@0.0.15':
|
||||
resolution: {integrity: sha512-DK41qvyOiJMmlj70QyVP/48M0gszA39DdnBLtgU94YwAe6OqKrr9tYXHLjZrOROmUVMezIIBQuWMLedSAvb54A==}
|
||||
|
||||
'@kevisual/router@0.0.9':
|
||||
resolution: {integrity: sha512-qPyC2GVJ7iOIdJCCKNDsWMAKOQeSJW9HBpL5ZWKHTbi+t4jJBGTzIlXmjKeMHRd0lr/Qq1imQvlkSh4hlrbodA==}
|
||||
@ -2244,15 +2241,7 @@ snapshots:
|
||||
dependencies:
|
||||
eventemitter3: 5.0.1
|
||||
|
||||
'@kevisual/query@0.0.12(encoding@0.1.13)(ws@8.18.0)':
|
||||
dependencies:
|
||||
openai: 4.88.0(encoding@0.1.13)(ws@8.18.0)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- ws
|
||||
- zod
|
||||
|
||||
'@kevisual/query@0.0.13(encoding@0.1.13)(ws@8.18.0)':
|
||||
'@kevisual/query@0.0.15(encoding@0.1.13)(ws@8.18.0)':
|
||||
dependencies:
|
||||
openai: 4.88.0(encoding@0.1.13)(ws@8.18.0)
|
||||
transitivePeerDependencies:
|
||||
|
@ -65,7 +65,10 @@ const loginCommand = new Command('login')
|
||||
program.addCommand(loginCommand);
|
||||
|
||||
const showMe = async (show = true) => {
|
||||
const me = await queryLogin.getMe();
|
||||
let me = await queryLogin.getMe();
|
||||
if (me.code === 401) {
|
||||
me = await queryLogin.getMe();
|
||||
}
|
||||
if (show) {
|
||||
console.log('Me', me.data);
|
||||
}
|
||||
@ -84,7 +87,12 @@ const switchOrgCommand = new Command('switch').argument('<username>', 'Switch to
|
||||
program.addCommand(switchOrgCommand);
|
||||
|
||||
const command = new Command('me').description('').action(async () => {
|
||||
await showMe();
|
||||
try {
|
||||
const res = await showMe(false);
|
||||
console.log('me', res?.data);
|
||||
} catch (error) {
|
||||
console.log('me error', error);
|
||||
}
|
||||
});
|
||||
|
||||
program.addCommand(command);
|
||||
|
@ -12,7 +12,7 @@ const tokenList = new Command('list')
|
||||
.description('show token list')
|
||||
// .option('-r --remove <number>', 'remove token by number')
|
||||
.action(async (opts) => {
|
||||
const res = queryLogin.cache.cache.cacheData;
|
||||
const res = queryLogin.cacheStore.cacheData;
|
||||
console.log(util.inspect(res, { colors: true, depth: 4 }));
|
||||
});
|
||||
token.addCommand(tokenList);
|
||||
|
@ -1,19 +0,0 @@
|
||||
import { program as app, Command } from '@/program.ts';
|
||||
import { getConfig, writeConfig } from '@/module/index.ts';
|
||||
import {queryMe} from '../query/index.ts';
|
||||
|
||||
|
||||
// const command = new Command('me')
|
||||
// .description('')
|
||||
// .action(async () => {
|
||||
// const config = getConfig()
|
||||
// const res = await queryMe();
|
||||
// if(res.code===200) {
|
||||
// console.log('me', res.data)
|
||||
// } else {
|
||||
// console.log('not login')
|
||||
// writeConfig({ ...config, token: '' });
|
||||
// }
|
||||
// });
|
||||
|
||||
// app.addCommand(command);
|
@ -2,7 +2,6 @@ import { program } from '@/program.ts';
|
||||
import './command/login.ts';
|
||||
import './command/logout.ts';
|
||||
import './command/ls-token.ts';
|
||||
import './command/me.ts';
|
||||
import './command/deploy.ts';
|
||||
import './command/serve.ts';
|
||||
import './command/config.ts';
|
||||
|
@ -34,20 +34,13 @@ query.beforeRequest = async (config) => {
|
||||
};
|
||||
query.afterResponse = async (response, ctx) => {
|
||||
if (response.code === 401) {
|
||||
if (query.stop) {
|
||||
return {
|
||||
code: 500,
|
||||
message: '登录已过期',
|
||||
};
|
||||
}
|
||||
query.stop = true;
|
||||
const res = await queryLogin.afterCheck401ToRefreshToken(response, ctx);
|
||||
query.stop = false;
|
||||
return res;
|
||||
console.log('401 after', response);
|
||||
}
|
||||
return response as any;
|
||||
};
|
||||
export const queryLogin = new QueryLoginNode({
|
||||
query: query as any,
|
||||
onLoad: async () => {},
|
||||
onLoad: async () => {
|
||||
// console.log('onLoad');
|
||||
},
|
||||
});
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit af8ed90ab3f5a0b558c410f5a0f40d5fb7eaa6d6
|
||||
Subproject commit 54672a5574d359220e26ec17c69f567f130d9498
|
Loading…
x
Reference in New Issue
Block a user