Commit 2d90bc5b by linjinhong

fix:修改网络捕获错误

parent 8ef3db90
......@@ -39,31 +39,38 @@ function getCurrentDesktopDevice() {
return version;
}
async function readEnv() {
function readEnv() {
// 不需要async了
let exePath, configPath;
if (process.env.NODE_ENV === "development") {
configPath = path.join(__dirname, "../config/env.json");
} else {
exePath = path.dirname(app.getPath("exe")).replace(/\\/g, "/");
console.log("exePath", exePath);
configPath = `${exePath}/config/env.json`;
}
console.log("configPath", configPath);
await fs.readFile(configPath, "utf-8", async (err, data) => {
if (err) {
console.error("读取配置文件失败:", err);
return;
try {
if (process.env.NODE_ENV === "development") {
configPath = path.join(__dirname, "../config/env.json");
} else {
exePath = path.dirname(app.getPath("exe")).replace(/\\/g, "/");
configPath = `${exePath}/config/env.json`;
}
console.log("configPath", configPath);
// ✅ 改用同步读取,确保配置加载完成
const data = fs.readFileSync(configPath, "utf-8");
const config = JSON.parse(data);
config.configPath = configPath;
await setApi(config);
setApi(config); // 如果setApi是异步的,这里需要改成同步,或用await(但readEnv要加async)
console.log(53, config);
// 此时赋值一定完成
fileEnv = config.fileApiUrl;
env = config.apiApiHost;
visionUrl = config.visionUrl;
});
console.log("配置加载完成:", { fileEnv, env, visionUrl });
} catch (err) {
console.error("读取配置文件失败:", err);
// 配置加载失败时,可设置默认值或抛出错误
fileEnv = "https://factory.jomalls.com/upload/factory";
env = "https://factory.jomalls.com/api";
visionUrl = "https://console.jomalls.com";
throw new Error(`配置文件加载失败:${err.message}`);
}
}
readEnv();
export default {
......
import axios from "axios";
import Vue from "vue";
import { Loading } from "element-ui";
const { getHostApi } = require("@/server/utils/store");
// create an axios instance
const service = axios.create({
baseURL: "http://localhost:3000", // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 50000000, // request timeout
timeout: 12600000, // request timeout
});
let loading;
......@@ -28,17 +26,6 @@ function endLoading() {
service.interceptors.request.use(
(config) => {
const user = Vue.prototype.$dataStore.get("user");
// const isFullUrl = /^https?:\/\//i.test(config.url);
// console.log(33, config.url);
// if (!isFullUrl) {
// if (process.env.NODE_ENV === "development") {
// config.baseURL = "http://localhost:3000";
// } else {
// config.baseURL = config.baseURL = getHostApi().apiApiHost;
// }
// }
if (user) {
config.headers["jwt-token"] = user.token;
}
......@@ -54,16 +41,6 @@ service.interceptors.request.use(
// Add a response interceptor
service.interceptors.response.use(
/**
* If you want to get http information such as headers or status
* Please return response => response
*/
/**
* Determine the request status by custom code
* Here is just an example
* You can also judge the status by HTTP Status Code
*/
async (response) => {
// do something with response data
const res = response.data;
......
......@@ -1849,7 +1849,8 @@ export default {
detail &&
detail.mssWidth &&
detail.mssHeight &&
selectImgList.length
selectImgList.length &&
!detail?.saveImgList.some((el) => el.isCut)
"
>
<b style="color: green" v-if="hasSize"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment