chore(http): 请求日志改为JSON字符串输出

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
郭鸿轩 2026-07-28 10:34:23 +08:00
parent e1ac017a3c
commit 0e105c78e1

View File

@ -24,9 +24,14 @@ const install = (Vue, vm) => {
Vue.prototype.$u.http.interceptor.request = (req) => { Vue.prototype.$u.http.interceptor.request = (req) => {
const reqUrl = req && req.url ? String(req.url) : ''; const reqUrl = req && req.url ? String(req.url) : '';
const isAbsolute = /^https?:\/\//i.test(reqUrl); const isAbsolute = /^https?:\/\//i.test(reqUrl);
console.log('request', req); const fullUrl = isAbsolute ? reqUrl : (vm.$store.state.apiurl + reqUrl);
console.log('baseUrl', vm.$store.state.apiurl); // 用 JSON 字符串输出,避免 HBuilderX 控制台对象被截断、点击 URL 跳浏览器
console.log('完整URL', isAbsolute ? reqUrl : (vm.$store.state.apiurl + reqUrl)); console.log('request => ' + JSON.stringify({
url: fullUrl,
method: req.method,
data: req.data,
header: req.header
}, null, 2));
if (!req.header){ if (!req.header){
req.header = []; req.header = [];
} }