mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-25 16:19:20 -04:00
Copy info to clipboard (#2480)
Co-authored-by: Opender Singh <opender94@gmail.com> Co-authored-by: John <john_v@outlook.co.nz>
This commit is contained in:
1 file changed
+50
-18
@@ -13,9 +13,10 @@ import {
|
||||
MNEMONIC_SYM,
|
||||
} from '../common/constants';
|
||||
import * as misc from '../common/misc';
|
||||
import * as os from 'os';
|
||||
import { docsBase } from '../common/documentation';
|
||||
|
||||
const { app, Menu, BrowserWindow, shell, dialog } = electron;
|
||||
const { app, Menu, BrowserWindow, shell, dialog, clipboard } = electron;
|
||||
|
||||
// So we can use native modules in renderer
|
||||
// NOTE: This will be deprecated in Electron 10 and impossible in 11
|
||||
@@ -121,9 +122,6 @@ export function createWindow() {
|
||||
const applicationMenu = {
|
||||
label: `${MNEMONIC_SYM}Application`,
|
||||
submenu: [
|
||||
...(isMac()
|
||||
? [{ label: `A${MNEMONIC_SYM}bout ${getAppName()}`, role: 'about' }, { type: 'separator' }]
|
||||
: []),
|
||||
{
|
||||
label: `${MNEMONIC_SYM}Preferences`,
|
||||
click: function(menuItem, window, e) {
|
||||
@@ -294,24 +292,58 @@ export function createWindow() {
|
||||
],
|
||||
};
|
||||
|
||||
if (!isMac()) {
|
||||
const aboutDetail = [
|
||||
`OS ${os.type()} ${os.arch()} ${os.release()}`,
|
||||
`Version ${getAppLongName()} ${getAppVersion()}`,
|
||||
`Shell ${process.versions.electron}`,
|
||||
`Node ${process.versions.node}`,
|
||||
`V8 ${process.versions.v8}`,
|
||||
`Architecture ${process.arch}`,
|
||||
Curl.getVersion(),
|
||||
].join('\n');
|
||||
|
||||
const aboutMsgOptions = {
|
||||
type: 'info',
|
||||
title: getAppName(),
|
||||
message: getAppLongName(),
|
||||
detail: aboutDetail,
|
||||
noLink: true,
|
||||
};
|
||||
|
||||
if (isMac()) {
|
||||
applicationMenu.submenu.unshift(
|
||||
{
|
||||
label: `A${MNEMONIC_SYM}bout ${getAppName()}`,
|
||||
click: async () => {
|
||||
const buttons = ['OK', 'Copy'];
|
||||
const msgBox = await dialog.showMessageBox({
|
||||
...aboutMsgOptions,
|
||||
buttons: buttons,
|
||||
defaultId: buttons.indexOf('OK'),
|
||||
cancelId: buttons.indexOf('OK'),
|
||||
});
|
||||
|
||||
if (msgBox.response === buttons.indexOf('Copy')) {
|
||||
clipboard.writeText(aboutDetail);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
);
|
||||
} else {
|
||||
helpMenu.submenu.unshift({
|
||||
label: `${MNEMONIC_SYM}About`,
|
||||
click: async () => {
|
||||
await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: getAppName(),
|
||||
message: getAppLongName(),
|
||||
detail: [
|
||||
'Version ' + getAppVersion(),
|
||||
'Shell ' + process.versions.electron,
|
||||
'Node ' + process.versions.node,
|
||||
'V8 ' + process.versions.v8,
|
||||
'Architecture ' + process.arch,
|
||||
'', // Blank line before libcurl
|
||||
Curl.getVersion(),
|
||||
].join('\n'),
|
||||
const buttons = ['Copy', 'OK'];
|
||||
const msgBox = await dialog.showMessageBox({
|
||||
...aboutMsgOptions,
|
||||
buttons: buttons,
|
||||
defaultId: buttons.indexOf('OK'),
|
||||
cancelId: buttons.indexOf('OK'),
|
||||
});
|
||||
if (msgBox.response === buttons.indexOf('Copy')) {
|
||||
clipboard.writeText(aboutDetail);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user