From 02c1574b5b375082f34dd2be2fdab8197c061664 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 2 Jan 2025 21:46:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Daxios=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEheader=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/preload.js | 16 ++++++++++++++-- src/components/popup/ResultMenu.vue | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin/preload.js b/plugin/preload.js index 1667bbb..e98a674 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -8,6 +8,7 @@ const electron = require("electron"); const path = require("path"); const axios = require("axios"); const http = require("http"); +const https = require("https"); const url = require("url"); const crypto = require("crypto"); require("ses"); @@ -79,7 +80,18 @@ window.multiProcessDetection = () => { return false; }; -// axios.defaults.adapter = require('axios/lib/adapters/http') +/** + * 忘了为什么之前注释下面的语句了 -_-!,保留浏览器的 axios + * axios.defaults.adapter = require('axios/lib/adapters/http') + * 另外创建一个 node 的 axios + */ +const nodeAxios = axios.create({ + httpAgent: new http.Agent(), + httpsAgent: new https.Agent({ + rejectUnauthorized: false, + }), +}); +nodeAxios.defaults.adapter = "http"; if (!window.utools.isWindows()) process.env.PATH = `/usr/local/bin:/usr/local/sbin:${process.env.PATH}`; @@ -111,7 +123,7 @@ let getSandboxFuns = () => { fetch: fetch.bind(window), utools: window.getuToolsLite(), electron, - axios, + axios: nodeAxios, Audio, AbortController, AbortSignal, diff --git a/src/components/popup/ResultMenu.vue b/src/components/popup/ResultMenu.vue index 5a6c0a5..0ebcddb 100644 --- a/src/components/popup/ResultMenu.vue +++ b/src/components/popup/ResultMenu.vue @@ -16,7 +16,6 @@ >