Skip to content

Commit 75daa08

Browse files
author
veedrin
committed
修复创建工作空间时如果项目已存在不提示的问题
1 parent ac02e12 commit 75daa08

File tree

4 files changed

+13
-23
lines changed

4 files changed

+13
-23
lines changed

app/dashboard/api/axios.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ axios.get = (url, overrideHeaders = {}) => {
3030
}).then(res => {
3131
return res.json();
3232
}).catch(err => {
33-
notify({ message: err, notifyType: NOTIFY_TYPE.ERROR });
33+
notify({ message: String(err), notifyType: NOTIFY_TYPE.ERROR });
3434
});
3535
}
3636

@@ -41,9 +41,11 @@ axios.post = (url, data, overrideHeaders = {}) => {
4141
headers: { ...headers, ...overrideHeaders },
4242
body: parseFormdata(data),
4343
}).then(res => {
44-
return res.json();
44+
if (res.status !== 204) {
45+
return res.json();
46+
}
4547
}).catch(err => {
46-
notify({ message: err, notifyType: NOTIFY_TYPE.ERROR });
48+
notify({ message: String(err), notifyType: NOTIFY_TYPE.ERROR });
4749
});
4850
}
4951

@@ -56,7 +58,7 @@ axios.put = (url, data, overrideHeaders = {}) => {
5658
}).then(res => {
5759
return res.json();
5860
}).catch(err => {
59-
notify({ message: err, notifyType: NOTIFY_TYPE.ERROR });
61+
notify({ message: String(err), notifyType: NOTIFY_TYPE.ERROR });
6062
});
6163
}
6264

@@ -69,7 +71,7 @@ axios.delete = (url, data, overrideHeaders = {}) => {
6971
}).then(res => {
7072
return res.json();
7173
}).catch(err => {
72-
notify({ message: err, notifyType: NOTIFY_TYPE.ERROR });
74+
notify({ message: String(err), notifyType: NOTIFY_TYPE.ERROR });
7375
});
7476
}
7577

app/dashboard/api/global.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ export const markReaded = (data) => {
1515
export const getMessage = () => {
1616
return axios.get('/workspaces/message?page=1&pageSize=10');
1717
}
18+
19+
export const logout = () => {
20+
return axios.get('/logout', { 'Accept': 'application/vnd.coding.v1+json' });
21+
}

app/dashboard/api/ws.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ export const getSSHPublicKey = () => {
4444
return axios.get('/user/public_key', { 'Accept': 'application/vnd.coding.v1+json' });
4545
}
4646

47-
export const logout = () => {
48-
return axios.get('/logout', { 'Accept': 'application/vnd.coding.v1+json' });
49-
}
50-
5147
export const getCodingProject = () => {
5248
return axios.get('/projects?page=1&pageSize=1000&type=all&source=Coding', { 'Accept': 'application/vnd.coding.v1+json' });
5349
}

app/dashboard/view/create/coding/Coding.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ class Coding extends Component {
150150
api.syncProject().then(res => {
151151
this.setState({ isSync: false });
152152
this.props.fetchCodingProject();
153-
}).catch(err => {
154-
this.setState({ isSync: false });
155-
this.props.fetchCodingProject();
156153
});
157154
}
158155

@@ -218,17 +215,8 @@ class Coding extends Component {
218215
this.handleCreateWorkspace(workspaceOption);
219216
} else {
220217
hideLoading();
221-
let message;
222-
if (res.msg) {
223-
const msg = res.msg;
224-
if (typeof msg === 'object') {
225-
message = msg[Object.keys(msg)[0]];
226-
} else {
227-
message = res.msg;
228-
}
229-
} else {
230-
message = 'Failed to create project';
231-
}
218+
const msg = res.msg || 'Failed to create project';
219+
const message = typeof msg === 'object' ? msg[Object.keys(msg)[0]] : res.msg;
232220
notify({ notifyType: NOTIFY_TYPE.ERROR, message });
233221
}
234222
});

0 commit comments

Comments
 (0)