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

TypeScript util-electron.isRenderer函数代码示例

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

本文整理汇总了TypeScript中eez-studio-shared/util-electron.isRenderer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isRenderer函数的具体用法?TypeScript isRenderer怎么用?TypeScript isRenderer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isRenderer函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: watch

export function watch(
    sourceId: string,
    filterSpecification: any,
    callback: (message: any) => void
) {
    let targetId = guid();

    // add target to this window
    targets.set(targetId, {
        sourceId,
        filterSpecification,
        callback
    });

    if (!filterSpecification || !filterSpecification.skipInitialQuery) {
        let source = sources.get(sourceId);
        if (source && source.onNewTarget) {
            source.onNewTarget(targetId, filterSpecification, true);
        }
    }

    // add target to other windows
    let targetWindowId: number;
    if (isRenderer()) {
        targetWindowId = EEZStudio.electron.remote.getCurrentWindow().id;
    } else {
        targetWindowId = -1;
    }

    getBrowserWindow()
        .getAllWindows()
        .forEach(window => {
            if (window.id !== targetWindowId) {
                sendNotifyWatch(window.webContents, {
                    sourceId,
                    filterSpecification,
                    targetId,
                    targetWindowId
                });
            }
        });

    if (isRenderer()) {
        sendNotifyWatch(EEZStudio.electron.ipcRenderer, {
            sourceId,
            filterSpecification,
            targetId,
            targetWindowId
        });
    }

    return targetId;
}
开发者ID:eez-open,项目名称:studio,代码行数:53,代码来源:notify.ts


示例2: getBrowserWindow

function getBrowserWindow() {
    if (isRenderer()) {
        return EEZStudio.electron.remote.BrowserWindow;
    } else {
        return require("electron").BrowserWindow;
    }
}
开发者ID:eez-open,项目名称:studio,代码行数:7,代码来源:notify.ts


示例3: function

ipc.on("notify/get-targets", function(event: any, windowId: number) {
    let targetWindowId: number;
    if (isRenderer()) {
        targetWindowId = EEZStudio.electron.remote.getCurrentWindow().id;
    } else {
        targetWindowId = -1;
    }
    targets.forEach((target, targetId) => {
        if (target.callback) {
            sendNotifyWatch(getBrowserWindow().fromId(windowId).webContents, {
                sourceId: target.sourceId,
                filterSpecification: target.filterSpecification,
                targetId,
                targetWindowId
            });
        }
    });
});
开发者ID:eez-open,项目名称:studio,代码行数:18,代码来源:notify.ts


示例4: values

import { stringCompare } from "eez-studio-shared/string";
import { beginTransaction, commitTransaction } from "eez-studio-shared/store";

import { IDesignerContext } from "eez-studio-designer/designer-interfaces";

import { loadInstrumentExtension } from "instrument/import";
import { instrumentStore, instruments } from "instrument/instrument-object";
import * as AddInstrumentDialogModule from "instrument/add-instrument-dialog";
import * as DeletedInstrumentsDialogModule from "instrument/deleted-instruments-dialog";
import { IInstrumentProperties } from "instrument/export";

import * as ConnectionModule from "instrument/connection/connection";

import { createInstrumentListStore } from "instrument/window/lists/store";

if (!isRenderer()) {
    createInstrumentListStore(null);
}

export interface IInstrumentExtensionProperties extends IExtensionProperties {
    properties: IInstrumentProperties;
}

export const instrumentExtensions = computed(() => {
    return values(extensions)
        .filter(extension => extension.type === "instrument")
        .sort((a, b) => stringCompare(a.displayName || a.name, b.displayName || b.name));
});

function createInstrument(extension: IExtension) {
    return {
开发者ID:eez-open,项目名称:studio,代码行数:31,代码来源:instrument-extension.ts


示例5: function

import Database from "better-sqlite3";
import { isRenderer } from "eez-studio-shared/util-electron";

import * as MainSettingsModule from "main/settings";

export let getDbPath: () => string;
export let setDbPath: (dbPath: string) => void;

if (isRenderer()) {
    getDbPath = function() {
        return EEZStudio.electron.ipcRenderer.sendSync("getDbPath");
    };

    setDbPath = function(dbPath: string) {
        EEZStudio.electron.ipcRenderer.send("setDbPath", dbPath);
    };
} else {
    ({ getDbPath, setDbPath } = require("main/settings") as typeof MainSettingsModule);
}

export let db = new Database(getDbPath());
db.defaultSafeIntegers();

// // DB query is executed in Main process
// if (!isRenderer()) {
//     const { ipcMain } = require("electron");

//     ipcMain.on(
//         "dbQueryTask",
//         (event: Electron.Event, taskId: string, query: string, ...args: any[]) => {
//             try {
开发者ID:eez-open,项目名称:studio,代码行数:31,代码来源:db.ts


示例6: loadInstrumentExtension

export async function loadInstrumentExtension(extensionFolderPath: string) {
    try {
        let idfFilePath = await findIdfFile(extensionFolderPath);
        if (!idfFilePath) {
            throw "IDF file not found";
        }

        if (isRenderer()) {
            let idfXmlAsString = await readTextFile(idfFilePath);
            let idf = parseXmlString(idfXmlAsString);
            let ScpiConfiguration = $(idf).find(">ScpiConfigurations");
            if (ScpiConfiguration.length && ScpiConfiguration.attr("guid")) {
                let id = ScpiConfiguration.attr("guid")!;

                let name = ScpiConfiguration.attr("name") || "Unknown name";
                let version = ScpiConfiguration.attr("firmwareVersion") || "Unknown version";

                let properties: IInstrumentExtensionProperties;
                let isEditable: boolean;
                let downloadUrl: string | undefined;
                let sha256: string | undefined;
                let moreDescription: string | undefined;

                let packageJsonFilePath = extensionFolderPath + "/package.json";
                if (await fileExists(packageJsonFilePath)) {
                    const packageJson = await readPackageJson(packageJsonFilePath);
                    version = packageJson.version;
                    properties = packageJson["eez-studio"];
                    isEditable = await fileExists(extensionFolderPath + "/.editable");
                    downloadUrl = packageJson.download;
                    sha256 = packageJson.sha256;
                    moreDescription = properties.moreDescription;
                } else {
                    properties = EMPTY_INSTRUMENT_PROPERTIES;
                    isEditable = true;

                    await writeBinaryData(extensionFolderPath + "/.editable", "");

                    await writeJsObjectToFile(packageJsonFilePath, {
                        name,
                        version,
                        "eez-studio": properties
                    });

                    downloadUrl = undefined;
                }

                const isDirty =
                    isEditable &&
                    ((await fileExists(extensionFolderPath + "/package.json")) ||
                        (await fileExists(extensionFolderPath + "/image.png")));

                const extension: IExtension = observable(
                    {
                        id,
                        type: "instrument",
                        name,
                        description:
                            ScpiConfiguration.attr("description") || "Unknown description.",
                        moreDescription,
                        version,
                        author: ScpiConfiguration.attr("author") || "Unknown author",
                        image: "",
                        renderPropertiesComponent: () => {
                            const {
                                renderPropertiesComponent
                            } = require("instrument/properties-component") as typeof PropertiesComponentModule;

                            return new Promise<JSX.Element>(resolve => {
                                resolve(renderPropertiesComponent(extension));
                            });
                        },
                        properties,
                        isEditable,
                        isDirty,

                        shortName: ScpiConfiguration.attr("shortName") || "",
                        revisionNumber: ScpiConfiguration.attr("revisionNumber") || "",
                        supportedModels: ScpiConfiguration.attr("supportedModels") || "",
                        revisionComments: ScpiConfiguration.attr("revisionComments") || ""
                    },
                    {
                        properties: observable.shallow
                    }
                );

                const imageFilePath = extensionFolderPath + "/" + "image.png";
                if (await fileExists(imageFilePath)) {
                    extension.image = localPathToFileUrl(imageFilePath);
                } else {
                    extension.image = INSTRUMENT_NO_IMAGE;
                }

                extension.download = downloadUrl;
                extension.sha256 = sha256;

                extension.installationFolderPath = extensionFolderPath;

                return extension;
            }
//.........这里部分代码省略.........
开发者ID:eez-open,项目名称:studio,代码行数:101,代码来源:import.ts



注:本文中的eez-studio-shared/util-electron.isRenderer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript egg.Application类代码示例发布时间:2022-05-25
下一篇:
TypeScript store.IStore类代码示例发布时间: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