當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript remote.getCurrentWindow方法代碼示例

本文整理匯總了TypeScript中electron.remote.getCurrentWindow方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript remote.getCurrentWindow方法的具體用法?TypeScript remote.getCurrentWindow怎麽用?TypeScript remote.getCurrentWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.remote的用法示例。


在下文中一共展示了remote.getCurrentWindow方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 document.addEventListener('contextmenu', function (e :any) {
     switch (e.target.nodeName) {
         case 'TEXTAREA':
         case 'INPUT':
             e.preventDefault();
             textEditingMenu.popup(remote.getCurrentWindow());
             break;
         default:
             if (isAnyTextSelected()) {
                 e.preventDefault();
                 normalMenu.popup(remote.getCurrentWindow());
             }
     }
 }, false);
開發者ID:frieck,項目名稱:WiN,代碼行數:14,代碼來源:context_menu.ts

示例2: showContextMenu

function showContextMenu(e) {
	e.preventDefault();

	const pid = parseInt(e.currentTarget.id);
	if (pid && typeof pid === 'number') {
		const menu = new remote.Menu();
		menu.append(new remote.MenuItem({
			label: localize('killProcess', "Kill Process"),
			click() {
				process.kill(pid, 'SIGTERM');
			}
		})
		);

		menu.append(new remote.MenuItem({
			label: localize('forceKillProcess', "Force Kill Process"),
			click() {
				process.kill(pid, 'SIGKILL');
			}
		})
		);

		menu.popup(remote.getCurrentWindow());
	}
}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:25,代碼來源:processExplorerMain.ts

示例3: async

    getCookie: async(name: string) => {
        const value = {
            name
        };
        const cookies = remote.getCurrentWindow().webContents.session.cookies;

        if (!name) {
            return new Promise((resolve, reject) => {
                cookies.get({ url: axios.defaults.baseURL }, (error, cookies) => {
                    let string = '';

                    if (error) {
                        return resolve('');
                    }

                    for (let i = cookies.length; --i >= 0;) {
                        const item = cookies[i];
                        string += `${item.name}=${item.value} ;`;
                    }

                    resolve(string);
                });
            });
        }

        return new Promise((resolve, reject) => {
            cookies.get(value, (err, cookies) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(cookies[0].value);
                }
            });
        });
    },
開發者ID:gjik911,項目名稱:git_01,代碼行數:35,代碼來源:helper_20180805185804.ts

示例4: _setup

function _setup() {
	const electron = require('electron');
	const win = electron.remote.getCurrentWindow();

	function getButtonAndBindClick(btn: string, fn: EventListener) {
		const elem = document.getElementById(`btn-${btn}`);
		elem.addEventListener('click', fn);
		return elem;
	}

	const btnMinimize = getButtonAndBindClick('minimize', () => win.minimize());
	const btnMaximize = getButtonAndBindClick('maximize', () => win.maximize());
	const btnRestore  = getButtonAndBindClick('restore' , () => win.restore());
	const btnClose    = getButtonAndBindClick('close'   , () => win.close());

	function updateButtons() {
		const isMax = win.isMaximized();
		btnMaximize.hidden = isMax;
		btnRestore.hidden = !isMax;
	}

	win.on('unmaximize', updateButtons);
	win.on('maximize', updateButtons);
	updateButtons();

	Keyboard.keydownOnce(['esc', 'alt'], (e: typeof KeyEvent) => {
		document.body.classList.toggle('paused');
	});
}
開發者ID:OlsonDev,項目名稱:Synergy,代碼行數:29,代碼來源:titlebar.ts

示例5: createTextMenu

  event => {
    const element = event.target as HTMLElement;

    copyContext = '';

    if (element.nodeName === 'TEXTAREA' || element.nodeName === 'INPUT') {
      event.preventDefault();

      createTextMenu();
      textMenu.popup({window: remote.getCurrentWindow()});
    } else if (element.classList.contains('image-element') || element.classList.contains('detail-view-image')) {
      event.preventDefault();
      const elementSource = (element as HTMLImageElement).src;
      const parentElement = element.closest('.message-body') as HTMLDivElement;
      const timeElement = parentElement.getElementsByTagName('time')[0];
      if (timeElement) {
        const imageTimestamp = timeElement.dataset['timestamp'];
        imageMenu.timestamp = imageTimestamp;
      }
      imageMenu.image = elementSource;
      imageMenu.popup({window: remote.getCurrentWindow()});
    } else if (element.nodeName === 'A') {
      event.preventDefault();

      const elementHref = (element as HTMLLinkElement).href;
      copyContext = elementHref.replace(/^mailto:/, '');
      defaultMenu.popup({window: remote.getCurrentWindow()});
    } else if (element.classList.contains('text')) {
      event.preventDefault();

      copyContext = window.getSelection().toString() || element.innerText.trim();
      defaultMenu.popup({window: remote.getCurrentWindow()});
    } else {
      // Maybe we are in a code block _inside_ an element with the 'text' class?
      // Code block can consist of many tags: CODE, PRE, SPAN, etc.
      let parentNode = element.parentNode;
      while (parentNode && parentNode !== document && !(parentNode as HTMLElement).classList.contains('text')) {
        parentNode = parentNode.parentNode;
      }
      if (parentNode !== document) {
        event.preventDefault();
        copyContext = window.getSelection().toString() || (parentNode as HTMLElement).innerText.trim();
        defaultMenu.popup({window: remote.getCurrentWindow()});
      }
    }
  },
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:46,代碼來源:context.ts

示例6: showCommitContextMenu

export function showCommitContextMenu(store: AppStore, commit: Commit) {
  const template = getCommitMenuTemplate(store, commit);
  if (template.length === 0) {
    return;
  }
  const menu = Menu.buildFromTemplate(template);
  menu.popup({ window: remote.getCurrentWindow() });
}
開發者ID:wonderful-panda,項目名稱:inazuma,代碼行數:8,代碼來源:index.ts

示例7: function

 document.getElementById("max-btn").addEventListener("click", function (e) {
   var window: Electron.BrowserWindow = remote.getCurrentWindow();
   
   if(window.isMaximized())
     window.unmaximize();
   else
     window.maximize();        
 });
開發者ID:zsvanderlaan,項目名稱:aurelia-electron-typescript,代碼行數:8,代碼來源:app-window.ts

示例8:

        logOutWindow.webContents.on("did-finish-load", (event: any, oldUrl: string, newUrl: string) => {
            window.localStorage.removeItem("id_token");
            window.localStorage.removeItem("access_token");

            logOutWindow.destroy();

            remote.getCurrentWindow().reload();
        });
開發者ID:Gabriel0402,項目名稱:angular2-O365-desktop-app,代碼行數:8,代碼來源:authenticate.ts

示例9: showContextMenu

function showContextMenu(e) {
	e.preventDefault();

	const menu = new remote.Menu();

	const pid = parseInt(e.currentTarget.id);
	if (pid && typeof pid === 'number') {
		menu.append(new remote.MenuItem({
			label: localize('killProcess', "Kill Process"),
			click() {
				process.kill(pid, 'SIGTERM');
			}
		}));

		menu.append(new remote.MenuItem({
			label: localize('forceKillProcess', "Force Kill Process"),
			click() {
				process.kill(pid, 'SIGKILL');
			}
		}));

		menu.append(new remote.MenuItem({
			type: 'separator'
		}));

		menu.append(new remote.MenuItem({
			label: localize('copy', "Copy"),
			click() {
				const row = document.getElementById(pid.toString());
				if (row) {
					clipboard.writeText(row.innerText);
				}
			}
		}));

		menu.append(new remote.MenuItem({
			label: localize('copyAll', "Copy All"),
			click() {
				const processList = document.getElementById('process-list');
				if (processList) {
					clipboard.writeText(processList.innerText);
				}
			}
		}));
	} else {
		menu.append(new remote.MenuItem({
			label: localize('copyAll', "Copy All"),
			click() {
				const processList = document.getElementById('process-list');
				if (processList) {
					clipboard.writeText(processList.innerText);
				}
			}
		}));
	}

	menu.popup({ window: remote.getCurrentWindow() });
}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:58,代碼來源:processExplorerMain.ts

示例10: require

export const isomorphicReload = () => {
  if (isElectron) {
    const { remote } = require('electron');

    remote.getCurrentWindow().reload();
  } else {
    window.location.reload();
  }
};
開發者ID:Gisto,項目名稱:Gisto,代碼行數:9,代碼來源:isomorphic.ts


注:本文中的electron.remote.getCurrentWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。