本文整理匯總了TypeScript中electron.shell.openExternal方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript shell.openExternal方法的具體用法?TypeScript shell.openExternal怎麽用?TypeScript shell.openExternal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.shell
的用法示例。
在下文中一共展示了shell.openExternal方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildDefaultTemplate
buildDefaultTemplate() {
const templateDefault = [
{
label: "Help",
submenu: [
{
label: "Learn More",
click() {
shell.openExternal("http://getatmo.com");
}
},
{
label: "Documentation",
click() {
shell.openExternal(
"https://github.com/Raathigesh/atmo/blob/master/packages/app/docs/custom-script.md"
);
}
},
{
label: "Search Issues",
click() {
shell.openExternal("https://github.com/Raathigesh/atmo/issues");
}
}
]
}
];
return templateDefault;
}
示例2: buildDarwinTemplate
buildDarwinTemplate() {
const EditMenu = {
label: "Edit",
submenu: [
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ type: "separator" },
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{
label: "Select All",
accelerator: "CmdOrCtrl+A",
selector: "selectAll:"
},
{
label: "Quit",
accelerator: "Command+Q",
click: () => {
app.quit();
}
}
]
};
const subMenuHelp = {
label: "Help",
submenu: [
{
label: "Learn More",
click() {
shell.openExternal("http://getatmo.com");
}
},
{
label: "Documentation",
click() {
shell.openExternal(
"https://github.com/Raathigesh/atmo/blob/master/packages/app/docs/custom-script.md"
);
}
},
{
label: "Search Issues",
click() {
shell.openExternal("https://github.com/Raathigesh/atmo/issues");
}
}
]
};
return [EditMenu, subMenuHelp];
}
示例3: if
socket.on('shell-openExternal', (url, options, callback) => {
let success = false;
if (options && callback) {
success = shell.openExternal(url, options, (error) => {
socket.emit('shell-openExternalCallback', [url, error]);
});
} else if (options) {
success = shell.openExternal(url, options);
} else {
success = shell.openExternal(url);
}
socket.emit('shell-openExternalCompleted', success);
});
示例4: getHelpItems
/**
* Returns additional items for the help menu
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getHelpItems(): Array<MenuItemConstructorOptions> {
return [
{
type: 'separator'
},
{
label: 'Show Welcome Tour',
click() {
ipcMainManager.send(IpcEvents.SHOW_WELCOME_TOUR);
}
},
{
type: 'separator'
},
{
label: 'Toggle Developer Tools',
accelerator: 'CmdOrCtrl+Option+i',
click() {
const browserWindow = BrowserWindow.getFocusedWindow();
if (browserWindow && !browserWindow.isDestroyed()) {
browserWindow.webContents.openDevTools({ mode: 'bottom' });
}
}
},
{
type: 'separator'
},
{
label: 'Open Fiddle Repository...',
click() {
shell.openExternal('https://github.com/electron/fiddle');
}
},
{
label: 'Open Electron Repository...',
click() {
shell.openExternal('https://github.com/electron/electron');
}
},
{
label: 'Open Electron Issue Tracker...',
click() {
shell.openExternal('https://github.com/electron/electron/issues');
}
},
];
}
示例5: BrowserWindow
webContents.on('new-window', (event: any, url, _1, _2, options) => {
event.preventDefault()
if (/^(https:\/\/(mail|accounts)\.google\.com).*/.test(url)) {
// Center the new window on the screen
event.newGuest = new BrowserWindow({
...options,
x: null,
y: null
})
event.newGuest.webContents.on('dom-ready', () => {
addCustomCSS(event.newGuest)
})
event.newGuest.webContents.on(
'new-window',
(event: Event, url: string) => {
event.preventDefault()
shell.openExternal(url)
}
)
} else {
shell.openExternal(url)
}
})
示例6: downloadVideo
export function downloadVideo(url: string, removeOverlay: boolean = false) {
if (removeOverlay) {
const searchPageView = $('#downloadVideoView');
searchPageView && searchPageView.remove();
}
shell.openExternal(`https://ytmp3.cc/#v${url.split('?v=')[1]}`);
}
示例7: reportIssue
export function reportIssue(opts: ReportIssueOpts) {
if (typeof opts === "undefined") {
opts = {};
}
const log = opts.log;
let body = opts.body || "";
let type = opts.type || "Issue";
const repo = opts.repo || urls.itchRepo;
const before = opts.before || "";
if (typeof log !== "undefined") {
type = "Feedback";
body = `Event log:
\`\`\`
${log}
\`\`\`
`;
}
const platformEmoji = platformData[currentRuntime().platform].emoji;
const query = querystring.stringify({
title: `${platformEmoji} ${type} v${app.getVersion()}`,
body: before + body,
});
let url = `${repo}/issues/new?${query}`;
const maxLen = 2000;
if (url.length > maxLen) {
url = url.substring(0, maxLen);
}
shell.openExternal(url);
}
示例8: onClickContents
private onClickContents(event: MouseEvent) {
event.preventDefault();
if (event.target instanceof HTMLAnchorElement) {
const target = event.target as HTMLAnchorElement;
shell.openExternal(target.href);
}
}
示例9: navigate
export function navigate(url: string) {
try {
const parsed = URL.parse(url);
if (parsed.protocol === "emulator:") {
const params = QueryString.parse(parsed.query);
if (parsed.host === 'inspect') {
navigateInspectUrl(params);
} else if (parsed.host === 'appsettings') {
navigateAppSettingsUrl(params);
} else if (parsed.host === 'botcreds') {
navigateBotCredsUrl(params);
} else if (parsed.host === 'command') {
navigateCommandUrl(params);
}
} else if (parsed.protocol.startsWith(PaymentEncoder.PaymentEmulatorUrlProtocol)) {
navigatePaymentUrl(parsed.path);
} else if (parsed.protocol.startsWith(OAuthClientEncoder.OAuthEmulatorUrlProtocol)) {
navigateEmulatedOAuthUrl(url.substring(8));
} else if (parsed.protocol.startsWith(OAuthLinkEncoder.OAuthUrlProtocol)) {
navigateOAuthUrl(url.substring(12));
} else if (parsed.protocol.startsWith('file:')) {
// ignore
} else if (parsed.protocol.startsWith('javascript:')) {
// ignore
} else {
shell.openExternal(url, { activate: true });
}
} catch (e) {
log.error(e.message);
}
}
示例10: deferURL
export function deferURL(event: Event, url: string) {
event.preventDefault();
if (!url.startsWith("file:")) {
shell.openExternal(url);
} else if (url.endsWith(".ipynb")) {
launchIpynb(url);
}
}