fix: 请求结果msg取多语言

This commit is contained in:
TsMask
2023-11-22 19:33:46 +08:00
parent 6ada29bc9b
commit 12499e78ea
8 changed files with 31 additions and 30 deletions

View File

@@ -3,7 +3,7 @@ import {
RESULT_CODE_SUCCESS,
RESULT_MSG_ERROR,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -48,7 +48,7 @@ export async function updateConfig(tag: string, data: Record<string, any>) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;

View File

@@ -4,8 +4,8 @@ import {
RESULT_MSG_ERROR,
RESULT_MSG_SUCCESS,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { parseFirstLower, parseObjLineToHump } from '@/utils/parse-utils';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
* 查询配置参数标签栏
@@ -335,7 +335,7 @@ export async function getParamConfigInfoForm(
result.data.data = dataArray;
// 无数据时,用于新增
result.data.dataRule = { title: `Index-0`, key: 0, record : ruleArr} ;
result.data.dataRule = { title: `Index-0`, key: 0, record: ruleArr };
}
return result;
}
@@ -457,7 +457,7 @@ export async function updateNeConfigReload(neType: string, neId: string) {
} else if (str.indexOf('success') !== -1) {
delete result.data;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;

View File

@@ -3,7 +3,7 @@ import {
RESULT_CODE_SUCCESS,
RESULT_MSG_ERROR,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -117,7 +117,7 @@ export async function sendNeSoftware(data: Record<string, any>) {
delete result.data;
return result;
}
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
/**
@@ -136,7 +136,7 @@ export async function runNeSoftware(data: Record<string, any>) {
delete result.data;
return result;
}
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
/**
@@ -155,7 +155,7 @@ export async function backNeSoftware(data: Record<string, any>) {
delete result.data;
return result;
}
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
/**

View File

@@ -4,7 +4,7 @@ import {
RESULT_MSG_ERROR,
RESULT_MSG_SUCCESS,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -63,7 +63,7 @@ export async function getAlarmSet() {
}
}
if (Object.keys(resultData).length === 0) {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: {} };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: {} };
}
return {
code: RESULT_CODE_SUCCESS,
@@ -117,7 +117,7 @@ export async function updateAlarmSet(data: Record<string, any>) {
}
// 无变更时
if (resultNum === 0) {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: 0 };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: 0 };
}
return {
code: RESULT_CODE_SUCCESS,
@@ -183,7 +183,7 @@ export async function updateForwardSet(data: Record<string, any>) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;

View File

@@ -4,7 +4,7 @@ import {
RESULT_MSG_ERROR,
RESULT_MSG_SUCCESS,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -53,7 +53,7 @@ export async function getLogSet() {
}
}
if (Object.keys(resultData).length === 0) {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: {} };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: {} };
}
return {
@@ -100,7 +100,7 @@ export async function updateLogSet(data: Record<string, any>) {
}
// 无变更时
if (resultNum === 0) {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: 0 };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: 0 };
}
return {
code: RESULT_CODE_SUCCESS,
@@ -161,7 +161,7 @@ export async function updateFtpLogSet(data: Record<string, any>) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;
@@ -216,7 +216,7 @@ export async function updateRemoteOut(data: Record<string, any>) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;
@@ -249,7 +249,7 @@ export async function exportLog(query: Record<string, any>) {
order begin_time,end_time`;
}
if (!querySQL) {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: [] };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: [] };
}
// 发起请求
const result = await request({
@@ -286,7 +286,7 @@ export async function backupLog(logType: string) {
result.data = v;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR, data: 0 };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language], data: 0 };
}
}
return result;

View File

@@ -3,7 +3,7 @@ import {
RESULT_CODE_SUCCESS,
RESULT_MSG_ERROR,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -55,7 +55,7 @@ export async function updateOperationSet(data: Record<string, any>) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;

View File

@@ -3,7 +3,7 @@ import {
RESULT_CODE_SUCCESS,
RESULT_MSG_ERROR,
} from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { language, request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';
/**
@@ -86,7 +86,7 @@ export async function logoutSession(id: string) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
}
return result;

View File

@@ -1,4 +1,5 @@
import { request } from '@/plugins/http-fetch';
import { RESULT_CODE_ERROR, RESULT_CODE_SUCCESS, RESULT_MSG_ERROR } from '@/constants/result-constants';
import { request, language } from '@/plugins/http-fetch';
import { encode } from 'js-base64';
/**
@@ -37,7 +38,7 @@ export async function downloadFileChunk(
async function sendRequest() {
const range = `bytes=${start}-${end}`;
const res = await downloadFile(filePath, range);
if (res.code === 200 && res.status === 206) {
if (res.code === RESULT_CODE_SUCCESS && res.status === 206) {
// 总大小
const contentRange = res.headers.get('content-range') || '0/0';
totalSize = parseInt(contentRange.split('/')[1]);
@@ -109,7 +110,7 @@ export async function uploadFileChunk(
// 检查是否已上传部分数据块
const resCheck = await chunkCheck(fileIdentifier, name);
if (resCheck.code !== 200) {
if (resCheck.code !== RESULT_CODE_SUCCESS) {
return resCheck;
}
@@ -130,7 +131,7 @@ export async function uploadFileChunk(
formData.append('identifier', fileIdentifier);
const resUpload = await chunkUpload(formData);
if (resUpload.code === 200) {
if (resUpload.code === RESULT_CODE_SUCCESS) {
uploadedSize += chunk.size;
uploadProgress = (uploadedSize / size) * 100;
console.log(`上传进度:${uploadProgress}%`);
@@ -144,7 +145,7 @@ export async function uploadFileChunk(
if (uploadedSize === size) {
return await chunkMerge(fileIdentifier, name, subPath);
}
return { code: 500, msg: '上传出错,请重试' };
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR[language] };
}
/**