원클릭으로
axios
蓝鲸双协议兼容的 Axios 封装,自动处理旧版和新版 HTTP 协议
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
蓝鲸双协议兼容的 Axios 封装,自动处理旧版和新版 HTTP 协议
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
Archive multiple completed changes at once. Use when archiving several parallel changes.
Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
| id | eng-api-standard |
| name | 统一网络请求封装 (Axios) |
| category | engineering |
| description | 蓝鲸双协议兼容的 Axios 封装,自动处理旧版和新版 HTTP 协议 |
| tags | ["axios","http","api","request","blueking"] |
| updated_at | "2026-01-16T00:00:00.000Z" |
蓝鲸体系处于 HTTP 协议升级过渡期,本封装自动兼容 旧版协议 和 新版协议。
src/api/http.ts 的实例发起data 字段// src/api/http.ts
import axios from 'axios';
import { Message } from 'bkui-vue';
const http = axios.create({ baseURL: '/api', timeout: 60000 });
http.interceptors.response.use(
(res) => {
const { data } = res;
// 旧版协议(有 code 字段)
if (data.code !== undefined) {
if (data.code !== 0) {
Message({ theme: 'error', message: data.message });
return Promise.reject(new Error(data.message));
}
return data.data;
}
return data.data ?? data;
},
(error) => {
if (error.response?.status === 401) window.location.href = '/login';
Message({ theme: 'error', message: error.message });
return Promise.reject(error);
}
);
export default http;
| 错误 | 解决 |
|---|---|
| 401 循环跳转 | 登录页排除拦截器 |
| 数据双层嵌套 | 删除多余的 .data |
| 资源 | URI |
|---|---|
| 完整实现 | skill://api-standard/references/full-implementation.md |
| 协议迁移 | skill://api-standard/references/protocol-migration.md |
skill://api-standard/references/full-implementation.mdskill://api-standard/references/protocol-migration.mdskill://api-standard/assets/http.ts根据 SKILL.md 中的 IF-THEN 规则判断是否需要加载