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


TypeScript electron.remote.app類代碼示例

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


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

示例1: function

    highlight: function(code: string, lang: string): string {
        if (lang === undefined) {
            return code;
        }

        if (lang === 'mermaid') {
            if (!loaded_mermaid) {
                const script = document.createElement('script');
                script.src = 'file://' + remote.app.getAppPath() + '/bower_components/mermaid/dist/mermaid.min.js';
                script.onload = () => {
                    mermaid.init(undefined, 'div.mermaid');
                };
                document.head.appendChild(script);

                loaded_mermaid = true;
            }
            return '<div class="mermaid">' + he.encode(code) + '</div>';
        }

        if (lang === 'katex') {
            return '<div class="katex">' + katex.renderToString(code, {displayMode: true}) + '</div>';
        }

        try {
            return highlight(lang, code).value;
        } catch (e) {
            console.log('Error on highlight: ' + e.message);
            return code;
        }
    },
開發者ID:WondermSwift,項目名稱:Shiba,代碼行數:30,代碼來源:markdown-preview.ts

示例2: prepareIpc

        editor.on('process-attached', () => {
            const client = editor.getClient();

            client.listRuntimePaths()
                  .then((rtp: string[]) => {
                      component_loader.loadFromRTP(rtp);
                      component_loader.initially_loaded = true;
                  });

            runtime_api.subscribe(client);

            element.addEventListener('drop', e => {
                e.preventDefault();
                const f = e.dataTransfer.files[0];
                if (f) {
                    client.command('edit! ' + f.path);
                }
            });

            remote.app.on('open-file', (e: Event, p: string) => {
                e.preventDefault();
                client.command('edit! ' + p);
            });

            prepareIpc(client);
        });
開發者ID:haifengkao,項目名稱:NyaoVim-Unofficial,代碼行數:26,代碼來源:nyaovim-app.ts

示例3: getHistoryModel

export function getHistoryModel(
    options,
    basePath = remote.app.getPath('userData')
) {
    let buffer: any[] = []
    let promise = q()
    const fileName = basePath + '/' + options.file
    const history = {
        push(item) {
            promise = promise.then(() => {
                buffer.splice(0, 0, item)
                if (buffer.length > options.max) {
                    buffer = buffer.slice(0, options.min)
                }
                return q.nfcall(
                    writeFile,
                    fileName,
                    buffer.map(obj => JSON.stringify(obj)).join(',')
                )
            })
            return promise
        },
        list: () => buffer,
    }
    return q.nfcall(readFile, fileName).then(
        content => {
            buffer = JSON.parse('[' + content + ']')
            return history
        },
        () => history
    )
}
開發者ID:jakobrun,項目名稱:gandalf,代碼行數:32,代碼來源:history.ts

示例4: cwdKernelFallback

export function cwdKernelFallback() {
  // HACK: If we see they're at /, we assume that was the OS launching the Application
  //       from a launcher (launchctl on macOS)
  if (process.cwd() === "/") {
    return remote.app.getPath("home");
  }
  return process.cwd();
}
開發者ID:nteract,項目名稱:nteract,代碼行數:8,代碼來源:menu.ts

示例5: test

 test("replaces the user directory with ~", () => {
   const fixture = path.join(remote.app.getPath("home"), "test-notebooks");
   const result = nativeWindow.tildify(fixture);
   if (process.platform === "win32") {
     expect(result).toBe(fixture);
   } else {
     expect(result).toContain("~");
   }
 });
開發者ID:nteract,項目名稱:nteract,代碼行數:9,代碼來源:native-window.spec.ts

示例6: writeFile

export const saveSettings = (
    settings: ISettings,
    baseDir = remote.app.getPath('userData')
) => {
    const fileName = baseDir + '/settings.json'
    writeFile(fileName, JSON.stringify(settings, null, 4), err => {
        if (err) {
            console.log('error saving settings', err.message)
        }
    })
}
開發者ID:jakobrun,項目名稱:gandalf,代碼行數:11,代碼來源:settings.ts

示例7: function

 value: function() {
     // Note: First and second arguments are related to Electron
     const a = remote.process.argv.slice(2);
     a.push(
         '--cmd', `let\ g:nyaovim_version="${remote.app.getVersion()}"`,
         '--cmd', `set\ rtp+=${join(__dirname, '..', 'runtime').replace(' ', '\ ')}`
     );
     // XXX:
     // Swap files are disabled because it shows message window on start up but frontend can't detect it.
     a.push('-n');
     return a;
 },
開發者ID:munyari,項目名稱:NyaoVim,代碼行數:12,代碼來源:nyaovim-app.ts

示例8: if

export const getPath = (...relativePaths: string[]) => {
  let path: string;

  if (remote) {
    path = remote.app.getPath('userData');
  } else if (app) {
    path = app.getPath('userData');
  } else {
    return null;
  }

  return resolve(path, ...relativePaths).replace(/\\/g, '/');
};
開發者ID:laquereric,項目名稱:wexond,代碼行數:13,代碼來源:paths.ts

示例9: function

 value: function() {
     // Note:
     // First and second arguments are related to Electron
     // XXX:
     // Spectron additionally passes many specific arguments to process and 'nvim' process
     // will fail because of them.  As a workaround, we stupidly ignore arguments on E2E tests.
     const a = process.env.NYAOVIM_E2E_TEST_RUNNING ? [] : remote.process.argv.slice(2);
     a.push(
         '--cmd', `let\ g:nyaovim_version="${remote.app.getVersion()}"`,
         '--cmd', `set\ rtp+=${join(__dirname, '..', 'runtime').replace(' ', '\ ')}`,
     );
     // XXX:
     // Swap files are disabled because it shows message window on start up but frontend can't detect it.
     a.push('-n');
     return a;
 },
開發者ID:haifengkao,項目名稱:NyaoVim-Unofficial,代碼行數:16,代碼來源:nyaovim-app.ts

示例10: getSettings

export function getSettings(
    baseDir = remote.app.getPath('userData')
): Promise<ISettings> {
    const fileName = baseDir + '/settings.json'
    return new Promise((resolve, reject) => {
        readFile(fileName, (_, data) => {
            if (data) {
                resolve(data)
            } else {
                const str = JSON.stringify(defaultSettings)
                writeFile(fileName, str, writeErr => {
                    if (writeErr) {
                        reject(writeErr)
                    } else {
                        resolve(str)
                    }
                })
            }
        })
    }).then(JSON.parse)
}
開發者ID:jakobrun,項目名稱:gandalf,代碼行數:21,代碼來源:settings.ts


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