🚸 optimized error response
This commit is contained in:
@@ -53,7 +53,7 @@ export const useCommentStore = defineStore(
|
||||
commentList.value = {} as Comment;
|
||||
// 获取评论列表
|
||||
const result: any = await commentListApi(data);
|
||||
if (result.code === 200 && result.data) {
|
||||
if (result && result.code === 200) {
|
||||
commentList.value = result.data;
|
||||
if (Array.isArray(commentList.value.comments)) {
|
||||
commentList.value.comments.map((item: any) => {
|
||||
@@ -116,7 +116,7 @@ export const useCommentStore = defineStore(
|
||||
async function getReplyList(data: any) {
|
||||
// 获取评论列表
|
||||
const result: any = await replyListApi(data);
|
||||
if (result.code === 200 && result.data) {
|
||||
if (result && result.code === 200) {
|
||||
if (replyVisibility.value[data.comment_id].data !== result.data) {
|
||||
replyVisibility.value[data.comment_id].data = result.data;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ export const useCommentStore = defineStore(
|
||||
topic_id: data.topic_id,
|
||||
};
|
||||
const result: any = await commentLikeApi(params);
|
||||
if (result.code !== 200) {
|
||||
if (result && result.code !== 200) {
|
||||
message.error(result.message);
|
||||
return false;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ export const useCommentStore = defineStore(
|
||||
topic_id: data.topic_id,
|
||||
};
|
||||
const result: any = await cancelCommentLikeApi(params);
|
||||
if (result.code !== 200) {
|
||||
if (result && result.code !== 200) {
|
||||
message.error(result.message);
|
||||
return false;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ export const useCommentStore = defineStore(
|
||||
*/
|
||||
async function getSlideCaptchaData(): Promise<boolean> {
|
||||
const res: any = await getSlideCaptchaDataApi();
|
||||
if (res.code == 200 && res.data) {
|
||||
if (res && res.code === 200) {
|
||||
const {key, image, thumb, thumb_width, thumb_height, thumb_x, thumb_y} = res.data;
|
||||
slideCaptchaData.captKey = key;
|
||||
slideCaptchaData.image = image;
|
||||
|
@@ -31,7 +31,7 @@ export const useAuthStore = defineStore(
|
||||
*/
|
||||
async function getGithubRedirectUrl() {
|
||||
const res: any = await getGithubUrl(clientId.value);
|
||||
if (res.code === 200 && res.data) {
|
||||
if (res && res.code === 200 && res.data) {
|
||||
githubRedirectUrl.value = res.data;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export const useAuthStore = defineStore(
|
||||
*/
|
||||
async function getGiteeRedirectUrl() {
|
||||
const res: any = await getGiteeUrl();
|
||||
if (res.code === 200 && res.data) {
|
||||
if (res && res.code === 200) {
|
||||
giteeRedirectUrl.value = res.data;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export const useAuthStore = defineStore(
|
||||
*/
|
||||
async function getQQRedirectUrl() {
|
||||
const res: any = await getQQUrl(clientId.value);
|
||||
if (res.code === 200 && res.data) {
|
||||
if (res && res.code === 200) {
|
||||
qqRedirectUrl.value = res.data;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export const useAuthStore = defineStore(
|
||||
*/
|
||||
async function getClientId() {
|
||||
const res: any = await generateClientId();
|
||||
if (res.code === 200 && res.data) {
|
||||
if (res && res.code === 200) {
|
||||
clientId.value = res.data;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export const useAuthStore = defineStore(
|
||||
const messageHandler = async (e: any) => {
|
||||
if (typeof e.data === 'string') {
|
||||
const res: any = JSON.parse(e.data);
|
||||
if (res.code === 200 && res.data) {
|
||||
if (res && res.code === 200) {
|
||||
user.uid = res.data.uid;
|
||||
user.access_token = res.data.access_token;
|
||||
user.username = res.data.username;
|
||||
@@ -84,7 +84,7 @@ export const useAuthStore = defineStore(
|
||||
message.success(t('login.loginSuccess'));
|
||||
window.removeEventListener("message", messageHandler);
|
||||
setTimeout(() => {
|
||||
router.push('/main');
|
||||
router.push('/main/photo/all');
|
||||
}, 1000);
|
||||
} else {
|
||||
message.error(t('login.loginError'));
|
||||
|
Reference in New Issue
Block a user