• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript electron.remote.app类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript electron.remote.dialog类代码示例发布时间:2022-05-25
下一篇:
TypeScript electron.remote.Menu类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap