mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
统一api错误提示
This commit is contained in:
parent
0927682abf
commit
1695b8c0fe
|
@ -129,7 +129,7 @@ export default (app: Router) => {
|
|||
if (config.writePathList.every((x) => !path.startsWith(x))) {
|
||||
return res.send({
|
||||
code: 430,
|
||||
data: '文件路径禁止访问',
|
||||
message: '文件路径禁止访问',
|
||||
});
|
||||
}
|
||||
if (!originFilename) {
|
||||
|
|
|
@ -10,7 +10,7 @@ app.get('/api/public/panel/log', (req, res) => {
|
|||
'pm2 logs panel --lines 500 --nostream --timestamp',
|
||||
(err, stdout, stderr) => {
|
||||
if (err || stderr) {
|
||||
return res.send({ code: 400, data: err || stderr });
|
||||
return res.send({ code: 400, message: (err && err.message) || stderr });
|
||||
}
|
||||
return res.send({ code: 200, data: stdout });
|
||||
},
|
||||
|
|
|
@ -52,7 +52,7 @@ export default class SystemService {
|
|||
});
|
||||
return { code: 200, data: { ...result, code } };
|
||||
} else {
|
||||
return { code: 400, data: '通知发送失败,请检查参数' };
|
||||
return { code: 400, message: '通知发送失败,请检查参数' };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ export default class SystemService {
|
|||
} catch (error: any) {
|
||||
return {
|
||||
code: 400,
|
||||
data: error.message,
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +169,9 @@ export default class SystemService {
|
|||
public async notify({ title, content }: { title: string; content: string }) {
|
||||
const isSuccess = await this.notificationService.notify(title, content);
|
||||
if (isSuccess) {
|
||||
return { code: 200, data: '通知发送成功' };
|
||||
return { code: 200, message: '通知发送成功' };
|
||||
} else {
|
||||
return { code: 400, data: '通知发送失败,请检查参数' };
|
||||
return { code: 400, message: '通知发送失败,请检查系统设置/通知配置' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ export default class UserService {
|
|||
});
|
||||
return { code: 200, data: { ...result, code } };
|
||||
} else {
|
||||
return { code: 400, data: '通知发送失败,请检查参数' };
|
||||
return { code: 400, message: '通知发送失败,请检查参数' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -531,8 +531,8 @@ main() {
|
|||
local diff_time=$(($(date +%s -d "$end_time") - $(date +%s -d "$begin_time")))
|
||||
if [[ $p1 != "repo" ]] && [[ $p1 != "raw" ]]; then
|
||||
echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" >>$log_path
|
||||
cat $log_path
|
||||
fi
|
||||
cat $log_path
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
@ -101,7 +101,7 @@ export default function (props: any) {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (systemInfo && systemInfo.isInitialized && !user) {
|
||||
if (systemInfo && systemInfo.isInitialized && !user.username) {
|
||||
getUser();
|
||||
}
|
||||
}, [props.location.pathname]);
|
||||
|
|
|
@ -11,7 +11,7 @@ const time = Date.now();
|
|||
const errorHandler = function (error: any) {
|
||||
if (error.response) {
|
||||
const msg = error.data
|
||||
? error.data.message || error.data
|
||||
? error.data.message || error.message || error.data
|
||||
: error.response.statusText;
|
||||
const responseStatus = error.response.status;
|
||||
if ([502, 504].includes(responseStatus)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user