Add centralized API client with axios interceptors, remove vue-axios

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 12:44:33 +08:00
parent 6af7253d08
commit 147b16ca34
29 changed files with 301 additions and 270 deletions

View File

@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import moment from "moment";
import { Decimal } from 'decimal.js';
import abbreviateNumber from '@/module/abbreviateNumber.js';
import apiClient from "@/api/client.js";
import apiError from '@/module/apiError.js';
export default defineStore('conformanceStore', {
@@ -201,7 +202,7 @@ export default defineStore('conformanceStore', {
api = `/api/log-checks/params?log_id=${logId}`;
}
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
this.allConformanceTask = response.data.tasks;
this.allCfmSeqStart = response.data.sources;
this.allCfmSeqEnd = response.data.sinks;
@@ -230,7 +231,7 @@ export default defineStore('conformanceStore', {
}
try {
const response = await this.$axios.post(api, data);
const response = await apiClient.post(api, data);
if(filterId !== null) {
this.conformanceFilterTempCheckId = response.data.id;
}
@@ -266,7 +267,7 @@ export default defineStore('conformanceStore', {
api = `/api/log-checks/${logCreateCheckId}`;
}
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
if(!getRouteFile) {
this.allConformanceTempReportData = response.data
} else {
@@ -302,7 +303,7 @@ export default defineStore('conformanceStore', {
}
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
this.allIssueTraces = response.data.traces;
} catch(error) {
apiError(error, 'Failed to Get the detail of a temporary log conformance issue.');
@@ -336,7 +337,7 @@ export default defineStore('conformanceStore', {
}
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
this.allTaskSeq = response.data.task_seq;
this.allCases = response.data.cases;
return response.data.cases;
@@ -366,7 +367,7 @@ export default defineStore('conformanceStore', {
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/loops/${loopNo}`;
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
this.allLoopTraces = response.data.traces;
} catch(error) {
apiError(error, 'Failed to Get the detail of a temporary log conformance loop.');
@@ -392,7 +393,7 @@ export default defineStore('conformanceStore', {
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
try {
const response = await this.$axios.get(api);
const response = await apiClient.get(api);
this.allLoopTaskSeq = response.data.task_seq;
this.allLoopCases = response.data.cases;
return response.data.cases;
@@ -422,7 +423,7 @@ export default defineStore('conformanceStore', {
else api = `/api/log-checks?log_id=${logId}`;
try {
const response = await this.$axios.post(api, data);
const response = await apiClient.post(api, data);
if(filterId !== null) {
this.conformanceFilterCreateCheckId = response.data.id;
this.conformanceFilterTempCheckId = null;
@@ -449,7 +450,7 @@ export default defineStore('conformanceStore', {
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}`;
try {
const response = await this.$axios.put(api, data);
const response = await apiClient.put(api, data);
this.isUpdateConformance = response.status === 200;
this.conformanceLogTempCheckId = null;
this.conformanceFilterTempCheckId = null;