Skip to content

Commit dd8b21c

Browse files
committed
fix: typescript error
1 parent c1871ce commit dd8b21c

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/services/codingServer.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export default class CodingServer {
3838

3939
async getUserInfo(team: string, token: string = this._session?.accessToken || ``) {
4040
try {
41-
const result = await axios.get(`https://${team}.coding.net/api/current_user`, {
41+
const result = await axios({
42+
method: 'get',
43+
url: `https://${team}.coding.net/api/current_user`,
4244
params: {
4345
access_token: token,
4446
},
@@ -60,10 +62,11 @@ export default class CodingServer {
6062
project: string = this._repo.project,
6163
repo: string = this._repo.repo,
6264
) {
63-
return MOCK.MR_LIST.data.list;
6465
try {
6566
const url = `https://${team}.coding.net/api/user/${team}/project/${project}/depot/${repo}/git/merges/query`;
66-
const result = await axios.get(url, {
67+
const result = await axios({
68+
method: 'get',
69+
url,
6770
params: {
6871
status: `open`,
6972
sort: `action_at`,
@@ -80,9 +83,10 @@ export default class CodingServer {
8083
}
8184

8285
async getDepotList(team: string = this._repo.team, project: string = this._repo.project) {
83-
return MOCK.DEPOT_LIST.data.depots;
8486
try {
85-
const result = await axios.get(`https://${team}.coding.net/api/user/${team}/project/${project}/repos`, {
87+
const result = await axios({
88+
method: 'get',
89+
url: `https://${team}.coding.net/api/user/${team}/project/${project}/repos`,
8690
params: {
8791
access_token: this._session.accessToken,
8892
},
@@ -102,7 +106,7 @@ export default class CodingServer {
102106
const result = await axios({
103107
method: 'post',
104108
url: `https://${team}.coding.net/api/user/${team}/project/${project}/depot?access_token=${this._session.accessToken}`,
105-
header: {
109+
headers: {
106110
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
107111
},
108112
data: qs.stringify({

src/utils/axios.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const handleError = (error: any) => {
1010
};
1111

1212
interface Instance extends AxiosInstance {
13-
(config: AxiosRequestConfig): Promise<any>
13+
(config: AxiosRequestConfig): Promise<any>;
1414
}
1515

16-
const createInstance = (): any => {
16+
const createInstance = (): Instance => {
1717
const instance = axios.create();
1818
instance.interceptors.response.use(handleResponse, handleError);
1919
return instance;
2020
};
2121

22-
export default createInstance();
22+
export default createInstance();

src/utils/repo.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
import { IRepoInfo, IMRItem, IDepot } from '../typings/common'
1+
import { IRepoInfo, IMRItem, IDepot } from '../typings/common';
22

33
export function parseCloneUrl(url: string): IRepoInfo | null {
4-
const reg = /^(https:\/\/|git@)e\.coding\.net(\/|:)(.*)\.git$/i
5-
const result = url.match(reg)
6-
console.log('1')
4+
const reg = /^(https:\/\/|git@)e\.coding\.net(\/|:)(.*)\.git$/i;
5+
const result = url.match(reg);
76

87
if (!result) {
9-
return null
8+
return null;
109
}
1110

12-
const str = result.pop()
11+
const str = result.pop();
1312
if (!str || !str?.includes(`/`)) {
14-
return null
13+
return null;
1514
}
1615

17-
const [team, project, repo] = str.split(`/`)
18-
return { team, project, repo: repo || project }
16+
const [team, project, repo] = str.split(`/`);
17+
return { team, project, repo: repo || project };
1918
}
2019

2120
export function getMRUrl(team: string, mrItem: IMRItem): string {
22-
return `https://${team}.coding.net${mrItem.path}`
21+
return `https://${team}.coding.net${mrItem.path}`;
2322
}
2423

2524
export function getDepotUrl(team: string, depot: IDepot): string {
26-
return `https://${team}.coding.net${depot.depotPath}`
25+
return `https://${team}.coding.net${depot.depotPath}`;
2726
}

0 commit comments

Comments
 (0)