Refine and clean files and variables (#10)
This commit is contained in:
1 parent
0e6018e9b2
commit
6e980c7c34
45 files changed
+98
-522
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { ITokenResponse, IToken, IOAuthTokenRequest, IOAuthTokenResponse } from './models';
|
||||
import { getBaseUrlAuth } from '@/utils';
|
||||
|
||||
class AuthOperator {
|
||||
async refreshToken(payload: IToken): Promise<AxiosResponse<ITokenResponse>> {
|
||||
@@ -11,7 +12,7 @@ class AuthOperator {
|
||||
class OAuthOperator {
|
||||
async token(payload: IOAuthTokenRequest): Promise<AxiosResponse<IOAuthTokenResponse>> {
|
||||
return httpClient.post('/token', payload, {
|
||||
baseURL: '/oauth2/v1'
|
||||
baseURL: `${getBaseUrlAuth()}/oauth2/v1`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import axios, { AxiosProgressEvent, AxiosResponse } from 'axios';
|
||||
import {
|
||||
IChatAskOptions,
|
||||
IChatAskRequest,
|
||||
@@ -18,7 +18,7 @@ class ChatOperator {
|
||||
},
|
||||
baseURL: options.endpoint,
|
||||
responseType: 'stream',
|
||||
onDownloadProgress: (event) => {
|
||||
onDownloadProgress: (event: AxiosProgressEvent) => {
|
||||
const response = event.target.response;
|
||||
const lines = response.split('\r\n').filter((line: string) => !!line);
|
||||
const lastLine = lines[lines.length - 1];
|
||||
|
||||
@@ -6,3 +6,4 @@ export * from './midjourney';
|
||||
export * from './usage';
|
||||
export * from './api';
|
||||
export * from './order';
|
||||
export * from './distribution';
|
||||
@@ -1,10 +1,11 @@
|
||||
import router, { ROUTE_AUTH_LOGIN } from '@/router';
|
||||
import store from '@/store';
|
||||
import { getBaseUrlData } from '@/utils';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
const httpClient: AxiosInstance = axios.create({
|
||||
baseURL: '/api/v1',
|
||||
baseURL: `${getBaseUrlData()}/api/v1`,
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
@@ -31,7 +32,7 @@ httpClient.interceptors.response.use(
|
||||
},
|
||||
(error) => {
|
||||
if (error?.response?.status === 401) {
|
||||
store.dispatch('common/resetAuth');
|
||||
store.dispatch('resetToken');
|
||||
router.push({
|
||||
name: ROUTE_AUTH_LOGIN,
|
||||
query: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface IUser {
|
||||
id: string;
|
||||
id?: string;
|
||||
username?: string;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
|
||||
Reference in new issue
Block a user