本文整理汇总了TypeScript中eez-studio-shared/service.service函数的典型用法代码示例。如果您正苦于以下问题:TypeScript service函数的具体用法?TypeScript service怎么用?TypeScript service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了service函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
import { service } from "eez-studio-shared/service";
import { db } from "eez-studio-shared/db";
export default service<void, void>("db-services/vacuum", async () => {
db.exec("VACUUM");
});
开发者ID:eez-open,项目名称:studio,代码行数:7,代码来源:vacuum.ts
示例2: serviceImplementation
import { service } from "eez-studio-shared/service";
import { FontProperties } from "font-services/interfaces";
import * as FreeTypeModule from "font-services/freetype";
interface Params {
font: FontProperties;
projectFilePath: string;
}
function serviceImplementation(data: Params) {
const { rebuildFont } = require("font-services/freetype") as typeof FreeTypeModule;
return rebuildFont(data.font, data.projectFilePath);
}
export default service("font-services/font-rebuild", serviceImplementation, true);
开发者ID:eez-open,项目名称:studio,代码行数:17,代码来源:font-rebuild.ts
示例3: service
import { service } from "eez-studio-shared/service";
export default service("pdf-services/pdf-to-png", async (data: string) => {
const pdfjsLib = require("../../libs/pdfjs/build/pdf.js");
pdfjsLib.GlobalWorkerOptions.workerSrc = "../../libs/pdfjs/build/pdf.worker.js";
var pdfDocument = await pdfjsLib.getDocument(data);
var page = await pdfDocument.getPage(1);
var viewport = page.getViewport(1.0);
var canvas = document.createElement("canvas");
canvas.height = viewport.height;
canvas.width = viewport.width;
var context = canvas.getContext("2d");
var renderContext = {
canvasContext: context,
viewport: viewport
};
await page.render(renderContext);
return canvas.toDataURL();
});
开发者ID:eez-open,项目名称:studio,代码行数:27,代码来源:pdf-to-png.ts
示例4: require
if (path.extname(data.relativeFilePath) == ".bdf") {
const { extractBdfFont } = require("font-services/bdf") as typeof BdfModule;
return extractBdfFont(
data.name,
data.absoluteFilePath,
data.relativeFilePath,
data.bpp,
data.createGlyphs,
data.fromEncoding,
data.toEncoding,
data.createBlankGlyphs || false
);
} else {
const { extractFreeTypeFont } = require("font-services/freetype") as typeof FreeTypeModule;
return extractFreeTypeFont(
data.name,
data.absoluteFilePath,
data.relativeFilePath,
data.bpp,
data.size,
data.threshold,
data.createGlyphs,
data.fromEncoding,
data.toEncoding,
data.createBlankGlyphs || false
);
}
}
export default service("font-services/font-extract", serviceImplementation, true);
开发者ID:eez-open,项目名称:studio,代码行数:30,代码来源:font-extract.ts
示例5: async
import { service } from "eez-studio-shared/service";
import { db } from "eez-studio-shared/db";
interface Params {
query: string;
args: any[];
}
interface Result {
err: any;
rows: any[];
}
export default service<Params, Result>("db-services/query", async (inputParams: Params) => {
try {
const rows = db.prepare(inputParams.query).all(...inputParams.args);
return {
err: null,
rows
};
} catch (err) {
return {
err,
rows: []
};
}
});
开发者ID:eez-open,项目名称:studio,代码行数:28,代码来源:query.ts
注:本文中的eez-studio-shared/service.service函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论