Sketch 插件 Webview 模板使用教程
1. 项目的目录结构及介绍
sketchplugin-webview-template/
├── Contents/
│ ├── Sketch/
│ │ └── manifest.json
│ └── Resources/
│ ├── app.js
│ └── ui.html
├── LICENSE
├── README.md
├── appcast.xml
└── template.gif
- Contents/: 主要文件夹,包含 Sketch 插件的核心文件。
- Sketch/: 包含插件的元数据文件
manifest.json
。 - Resources/: 包含插件的资源文件,如
app.js
和ui.html
。
- Sketch/: 包含插件的元数据文件
- LICENSE: 项目的许可证文件。
- README.md: 项目的说明文档。
- appcast.xml: 插件更新配置文件。
- template.gif: 项目演示动画。
2. 项目的启动文件介绍
- app.js: 这是插件的主要脚本文件,负责创建和管理 Webview 窗口,并处理与 UI 的交互。
3. 项目的配置文件介绍
- manifest.json: 这是 Sketch 插件的元数据文件,包含插件的基本信息,如名称、作者、版本等。
{
"name": "Webview Template",
"identifier": "com.example.sketch.webview-template",
"version": "1.0",
"description": "A simple template for building Sketch plugins using a HTML page as user interface.",
"author": "Jacopo Colò",
"authorEmail": "jacopo.colo@example.com",
"commands": [
{
"name": "Open Webview",
"identifier": "openWebview",
"script": "app.js",
"handler": "onRun"
}
],
"menu": {
"title": "Webview Template",
"items": [
"openWebview"
]
}
}
- appcast.xml: 这是插件的更新配置文件,用于自动更新插件。
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Webview Template Changelog</title>
<link>https://example.com/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 1.0</title>
<description>Initial release.</description>
<pubDate>2023-01-01T00:00:00+00:00</pubDate>
<enclosure url="https://example.com/WebviewTemplate-1.0.zip" sparkle:version="1.0" length="1024" type="application/octet-stream"/>
</item>
</channel>
</rss>
以上是基于 jacopocolo/sketchplugin-webview-template
项目的详细教程。希望对您有所帮助!