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


TypeScript clipboard.writeBookmark方法代碼示例

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


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

示例1:

 socket.on('clipboard-writeBookmark', (title, url, type) => {
     clipboard.writeBookmark(title, url, type);
 });
開發者ID:E024,項目名稱:Electron.NET,代碼行數:3,代碼來源:clipboard.ts

示例2: t

  wc.on("context-menu", (e, props) => {
    const { i18n } = store.getState();
    const editFlags = props.editFlags;
    const hasText = props.selectionText.trim().length > 0;
    const can = (type: string) =>
      ((editFlags as any)[`can${type}`] as boolean) && hasText;

    let menuTpl: Electron.MenuItemConstructorOptions[] = [
      {
        type: "separator",
      },
      {
        id: "cut",
        label: t(i18n, _("web.context_menu.cut")),
        // needed because of macOS limitation:
        // https://github.com/electron/electron/issues/5860
        role: can("Cut") ? "cut" : null,
        enabled: can("Cut"),
        visible: props.isEditable,
      },
      {
        id: "copy",
        label: t(i18n, _("web.context_menu.copy")),
        role: can("Copy") ? "copy" : null,
        enabled: can("Copy"),
        visible: props.isEditable || hasText,
      },
      {
        id: "paste",
        label: t(i18n, _("web.context_menu.paste")),
        role: editFlags.canPaste ? "paste" : null,
        enabled: editFlags.canPaste,
        visible: props.isEditable,
      },
      {
        type: "separator",
      },
    ];

    if (props.linkURL && props.mediaType === "none") {
      menuTpl = [];
      if (store.getState().preferences.enableTabs) {
        menuTpl = [
          ...menuTpl,
          {
            type: "separator",
          },
          {
            id: "openInNewTab",
            label: t(i18n, _("web.context_menu.open_in_new_tab")),
            click() {
              store.dispatch(
                actions.navigate({
                  wind,
                  url: props.linkURL,
                  background: true,
                })
              );
            },
          },
        ];
      }

      menuTpl = [
        ...menuTpl,
        {
          type: "separator",
        },
        {
          id: "copyLink",
          label: t(i18n, _("web.context_menu.copy_link")),
          click() {
            if (process.platform === "darwin") {
              electron.clipboard.writeBookmark(props.linkText, props.linkURL);
            } else {
              electron.clipboard.writeText(props.linkURL);
            }
          },
        },
        {
          type: "separator",
        },
      ];
    }

    // filter out leading/trailing separators
    // TODO: https://github.com/electron/electron/issues/5869
    menuTpl = delUnusedElements(menuTpl);

    if (env.development) {
      menuTpl.push({
        id: "inspect",
        label: t(i18n, _("web.context_menu.inspect")),
        click() {
          store.dispatch(
            actions.inspect({
              webContentsId: wc.id,
              x: props.x,
              y: props.y,
            })
//.........這裏部分代碼省略.........
開發者ID:itchio,項目名稱:itch,代碼行數:101,代碼來源:web-contents-context-menu.ts


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