本文整理汇总了TypeScript中common/format/datetime.elapsed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript elapsed函数的具体用法?TypeScript elapsed怎么用?TypeScript elapsed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elapsed函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: loginSucceeded
async function loginSucceeded(store: Store, profile: Profile) {
logger.info(`Login succeeded, setting up session`);
try {
const userId = profile.id;
const partition = partitionForUser(String(userId));
const customSession = session.fromPartition(partition, { cache: true });
logger.info(`Registering itch protocol for session ${partition}`);
registerItchProtocol(store, customSession);
} catch (e) {
logger.warn(`Could not register itch protocol for session: ${e.stack}`);
}
try {
logger.info(`Restoring tabs...`);
await restoreTabs(store, profile);
} catch (e) {
logger.warn(`Could not restore tabs: ${e.stack}`);
}
logger.info(`Dispatching login succeeded`);
store.dispatch(actions.loginSucceeded({ profile }));
try {
logger.info(`Fetching owned keys...`);
let t1 = Date.now();
await mcall(
messages.FetchProfileOwnedKeys,
{
profileId: profile.id,
fresh: true,
limit: 1,
},
convo => {
hookLogging(convo, logger);
}
);
let t2 = Date.now();
logger.info(`Fetched owned keys in ${elapsed(t1, t2)}`);
store.dispatch(actions.ownedKeysFetched({}));
} catch (e) {
logger.warn(`In initial owned keys fetch: ${e.stack}`);
}
}
开发者ID:itchio,项目名称:itch,代码行数:43,代码来源:login.ts
示例2: 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({}));
}
});
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:preboot.ts
示例3: 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);
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:preboot.ts
示例4: async
watcher.on(actions.loginWithPassword, async (store, action) => {
const { username, password } = action.payload;
logger.info(`Attempting password login for user ${username}`);
store.dispatch(actions.attemptLogin({}));
try {
// integration tests for the integration test goddess
if (username === "#api-key") {
logger.info(`Doing direct API key login...`);
const t1 = Date.now();
const { profile } = await withTimeout(
"API key login",
LOGIN_TIMEOUT,
mcall(messages.ProfileLoginWithAPIKey, {
apiKey: password,
})
);
const t2 = Date.now();
logger.debug(
`ProfileLoginWithAPIKey call succeeded in ${elapsed(t1, t2)}`
);
await loginSucceeded(store, profile);
return;
}
logger.info(`Doing username/password login...`);
const t1 = Date.now();
const { profile, cookie } = await mcall(
messages.ProfileLoginWithPassword,
{
username,
password,
},
client => {
logger.debug(`Setting up handlers for TOTP & captcha`);
client.on(
messages.ProfileRequestCaptcha,
async ({ recaptchaUrl }) => {
logger.info(`Showing captcha`);
const modalRes = await promisedModal(
store,
modals.recaptchaInput.make({
wind: "root",
title: "Captcha",
message: "",
widgetParams: {
url: recaptchaUrl || urls.itchio + "/captcha",
},
fullscreen: true,
})
);
if (modalRes) {
logger.info(`Captcha solved`);
return { recaptchaResponse: modalRes.recaptchaResponse };
} else {
// abort
logger.info(`Captcha cancelled`);
return { recaptchaResponse: null };
}
}
);
client.on(messages.ProfileRequestTOTP, async () => {
logger.info(`Showing TOTP`);
const modalRes = await promisedModal(
store,
modals.twoFactorInput.make({
wind: "root",
title: ["login.two_factor.title"],
message: "",
widgetParams: {
username,
},
})
);
if (modalRes) {
logger.info(`TOTP answered`);
return { code: modalRes.totpCode };
} else {
// abort
logger.info(`TOTP cancelled`);
return { code: null };
}
});
}
);
if (cookie) {
try {
logger.info(`Setting cookies...`);
await setCookie(profile, cookie);
} catch (e) {
logger.error(`Could not set cookie: ${e.stack}`);
}
}
await loginSucceeded(store, profile);
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:login.ts
注:本文中的common/format/datetime.elapsed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论