代码拉取完成,页面将自动刷新
同步操作将从 rubickCenter/rubick-ui-plugin-saladic 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const shell = require("electron").shell;
const url = require('url').URL
//打开外部链接
window.openExternal = function (url) {
shell.openExternal(url);
};
//处理请求自定义cookie问题
const adapter = require("axios/lib/adapters/http");
const axiosCookieJarSupport = require("axios-cookiejar-support").default;
const tough = require("tough-cookie");
const CookieJar = new tough.CookieJar();
const axios = require("axios").create({
adapter,
headers:{
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
},
jar: CookieJar,
// proxy: {
// host: "localhost",
// port: 8888,
// },
withCredentials:true
});
tough._CookieJar = CookieJar;
// function setCookie(cookieStr, url){
// return new Promise((res, rej)=>{
// CookieJar.setCookie(cookieStr, url)
// })
// }
axiosCookieJarSupport(axios);
axios.interceptors.request.use(
(config) => {
//处理腾讯翻译君bug
let targetURl = new url(config.url)
let urlOrigin = targetURl.origin
config.headers.referer = urlOrigin;
// config.headers.origin = urlOrigin;
return config;
},
(error) => {
return Promise.reject(error);
}
);
axios.interceptors.response.use(
async (response) => {
// console.log("🚀 ~ file: preload.js ~ line 36 ~ response", response)
//处理有道翻译bug
let {headers, config} = response
let resSetCookie = headers['set-cookie']
if(resSetCookie && resSetCookie.length){
cookies = resSetCookie.map(tough.Cookie.parse);
for (let i of cookies){
await CookieJar.setCookie(i, config.url)
}
}
return response;
},
(error) => {
// console.log("🚀 ~ file: preload.js ~ line 40 ~ error", error)
return Promise.reject(error);
}
);
window.axios = axios;
window.tough = tough;
window.navigator.product === "NativeScript";
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。