本文整理匯總了TypeScript中common/actions.actions.systemAssessed方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript actions.systemAssessed方法的具體用法?TypeScript actions.systemAssessed怎麽用?TypeScript actions.systemAssessed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common/actions.actions
的用法示例。
在下文中一共展示了actions.systemAssessed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
watcher.on(actions.preboot, async (store, action) => {
let dispatchedBoot = false;
let t1 = Date.now();
try {
const system: ISystemState = {
appName: app.getName(),
appVersion: app.getVersion().replace(/\-.*$/, ""),
platform: os.itchPlatform(),
arch: os.arch(),
macos: os.platform() === "darwin",
windows: os.platform() === "win32",
linux: os.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 {
app.on(
"certificate-error",
(ev, webContents, url, error, certificate, callback) => {
// do not trust
callback(false);
logger.error(
`Certificate error: ${error} issued by ${
certificate.issuerName
} for ${certificate.subjectName}`
);
// TODO: that's super annoying as a modal.
store.dispatch(
actions.openModal(
modalWidgets.naked.make({
window: "root",
title: `Certificate error: ${error}`,
message:
`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) {
//.........這裏部分代碼省略.........
示例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);
//.........這裏部分代碼省略.........