本文整理汇总了TypeScript中common/actions.actions.proxySettingsDetected方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.proxySettingsDetected方法的具体用法?TypeScript actions.proxySettingsDetected怎么用?TypeScript actions.proxySettingsDetected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.proxySettingsDetected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
//.........这里部分代码省略.........
`There was an error with the certificate for ` +
`\`${certificate.subjectName}\` issued by \`${
certificate.issuerName
}\`.\n\n` +
`Please check your proxy configuration and try again.`,
detail: `If you ignore this error, the rest of the app might not work correctly.`,
buttons: [
{
label: "Ignore and continue",
className: "secondary",
},
{
label: ["menu.file.quit"],
action: actions.quit({}),
},
],
widgetParams: null,
})
)
);
}
);
logger.debug(`Set up certificate error handler`);
} catch (e) {
logger.error(
`Could not set up certificate error handler: ${e.stack ||
e.message ||
e}`
);
}
try {
const { session } = require("electron");
const netSession = session.fromPartition(NET_PARTITION_NAME, {
cache: false,
});
const envSettings: string =
process.env.https_proxy ||
process.env.HTTPS_PROXY ||
process.env.http_proxy ||
process.env.HTTP_PROXY;
let proxySettings = {
proxy: null as string,
source: "os" as ProxySource,
};
if (envSettings) {
logger.info(`Got proxy settings from environment: ${envSettings}`);
proxySettings = {
proxy: envSettings,
source: "env",
};
testProxy = true;
store.dispatch(actions.proxySettingsDetected(proxySettings));
}
await applyProxySettings(netSession, proxySettings);
} catch (e) {
logger.warn(
`Could not detect proxy settings: ${e ? e.message : "unknown error"}`
);
}
store.dispatch(actions.boot({}));
dispatchedBoot = true;
if (env.production && env.appName === "itch") {
try {
app.setAsDefaultProtocolClient("itchio");
app.setAsDefaultProtocolClient("itch");
} catch (e) {
logger.error(
`Could not set app as default protocol client: ${e.stack ||
e.message ||
e}`
);
}
}
if (process.platform === "win32") {
try {
await visualElements.createIfNeeded(new MinimalContext());
} catch (e) {
logger.error(
`Could not run visualElements: ${e.stack || e.message || e}`
);
}
}
} catch (e) {
throw e;
} finally {
const t2 = Date.now();
logger.info(`preboot ran in ${elapsed(t1, t2)}`);
}
if (!dispatchedBoot) {
store.dispatch(actions.boot({}));
}
});
示例2: async
watcher.on(actions.preboot, async (store, action) => {
let t1 = Date.now();
try {
const system: SystemState = {
appName: app.getName(),
appVersion: app.getVersion().replace(/\-.*$/, ""),
platform: itchPlatform(),
arch: arch(),
macos: process.platform === "darwin",
windows: process.platform === "win32",
linux: process.platform === "linux",
sniffedLanguage: app.getLocale(),
homePath: app.getPath("home"),
userDataPath: app.getPath("userData"),
proxy: null,
proxySource: null,
quitting: false,
};
store.dispatch(actions.systemAssessed({ system }));
try {
await loadPreferences(store);
} catch (e) {
logger.error(
`Could not load preferences: ${e.stack || e.message || e}`
);
}
try {
const netSession = session.fromPartition(NET_PARTITION_NAME, {
cache: false,
});
const envSettings: string =
process.env.https_proxy ||
process.env.HTTPS_PROXY ||
process.env.http_proxy ||
process.env.HTTP_PROXY;
let proxySettings = {
proxy: null as string,
source: "os" as ProxySource,
};
if (envSettings) {
logger.info(`Got proxy settings from environment: ${envSettings}`);
proxySettings = {
proxy: envSettings,
source: "env",
};
testProxy = true;
store.dispatch(actions.proxySettingsDetected(proxySettings));
}
await applyProxySettings(netSession, proxySettings);
} catch (e) {
logger.warn(
`Could not detect proxy settings: ${e ? e.message : "unknown error"}`
);
}
if (env.production && env.appName === "itch") {
try {
app.setAsDefaultProtocolClient("itchio");
app.setAsDefaultProtocolClient("itch");
} catch (e) {
logger.error(
`Could not set app as default protocol client: ${e.stack ||
e.message ||
e}`
);
}
}
} catch (e) {
throw e;
} finally {
const t2 = Date.now();
logger.info(`preboot ran in ${elapsed(t1, t2)}`);
}
store.dispatch(actions.prebootDone({}));
let devtoolsPath = process.env.ITCH_REACT_DEVTOOLS_PATH;
if (!devtoolsPath && env.development) {
let reactDevtoolsId = "fmkadmapgofadopljbjfkapdkoienihi";
let devtoolsFolder = path.join(
app.getPath("home"),
"AppData",
"Local",
"Google",
"Chrome",
"User Data",
"Default",
"Extensions",
reactDevtoolsId
);
try {
const files = fs.readdirSync(devtoolsFolder);
let version = files[0];
if (version) {
devtoolsPath = path.join(devtoolsFolder, version);
//.........这里部分代码省略.........