跳至主要内容

你的第一个 Spark

了解如何在几分钟内构建你的第一个 GitHub Spark 应用,无需编写任何代码。

谁可以使用此功能?

任何拥有 Copilot Pro+ 或 Copilot Enterprise 许可证的用户均可使用 Spark。

你是否曾经有一个很棒的应用想法,却没有工具来实现它?借助 AI 的帮助,你现在可以仅使用自然语言在几分钟内将应用创意变为现实。在本文中,我们将使用 GitHub Spark 来构建、改进并分享一个文字搜索应用,而无需自己编写任何代码。

注意

GitHub Spark 正处于公开预览阶段,提供数据保护,且可能会有变动。

创建你的应用原型

让我们先生成一个初始的、基本的应用版本,以便以后进行构建。

  1. 前往 https://github.com/spark

  2. 发送以下提示以生成你的应用的第一版

    Copilot 提示
    Please create a word search game. The game should take in a set of words from the user, then create a word search puzzle containing those words, as well as a word bank listing the words. Words in the puzzle can be horizontal, vertical, diagonal, forwards, and backwards, and are "found" when the user clicks and drags their mouse across them. Once all words are found, give the user the option to create a new puzzle.
    
  3. 观看 Spark 实时构建你的应用!当预览出现时,即表示应用已生成完成。

  4. 要测试你的应用,请使用预览创建并解答一个谜题。

改进你的应用

就这样,我们拥有了一个可运行的应用!不过,它仍需一些微调。让我们给 Spark 额外的提示来完善我们的项目。

  1. 在页面左侧的 Iterate(迭代)标签页中,发送以下提示

    Copilot 提示
    Please add a leaderboard and a timer to the game. The timer should start when the user generates a new puzzle, then stop when all words are found. The user should then be able to enter their name, and their name, time, and the number of words in their puzzle should be displayed on the leaderboard. The leaderboard should be sortable in ascending and descending order by each of the three categories.
    
  2. 应用更新后,创建并解答另一个谜题,以查看新功能的实际效果。

  3. 发挥创意,对应用进行自行改进!如果卡住了,可以选择 Spark 在提示框上方提供的建议之一。你也可以使用“主题”、“数据”和“提示”标签页中的可视化编辑控件进行更改,无需触及代码。

调试你的应用

在构建应用的过程中,你可能会遇到一些错误。通常,Spark 会识别这些问题并在提示框上方的 “Errors” 弹窗中列出。要修复错误,请点击 Fix all

Screenshot of errors identified by GitHub Spark. The "Fix all" button is outlined in orange.

如果你发现了 Spark 未标记的错误,请编写提示进行修复。为获得最佳效果,请提供错误的详细描述以及理想的修复状态。例如,如果你注意到添加超过一定字符数的单词会导致谜题渲染错误,请发送以下提示

Copilot 提示
Please prevent users from entering words longer than the number of rows or columns in the puzzle. Additionally, add an option to change the size of a puzzle. If the user tries to enter a word that's longer than the current size of the puzzle, display an error message telling them that provided words must be less than or equal to the size of the puzzle.

分享你的应用

现在你对应用满意了,让我们将其发布,以便与他人共享。你还可以选择将你的 Spark 设为 只读,这样其他用户可以查看你的应用内容,但无法编辑内容、删除文件或记录,或创建新项目。

注意

  • 如果你将 Spark 开放给所有 GitHub 用户,所有用户都将能够访问和编辑存储在你的 Spark 中的数据。请务必在向其他用户公开之前删除应用中的任何私人或敏感数据。此选项对受管用户帐户不可用
  1. 在页面右上角,点击 Publish(发布)。

  2. 默认情况下,你的 Spark 以私有方式发布,仅你本人可访问。若要让其他 GitHub 用户访问你的应用,请在发布下拉菜单的 Visibility(可见性)部分,选择 Organization,以使你的 Spark 对所选组织的所有成员可访问,或 All GitHub users(所有 GitHub 用户)。这将允许任何拥有 GitHub 账户的人访问你的 Spark。

    Screenshot of the GitHub Spark publication menu. The "All GitHub users" visibility option is outlined in orange.

  3. 如果你将 Spark 对其他用户可见(即除私有之外的任何设置),发布下拉菜单中会出现 “Data Access”(数据访问)选项。此选项让你可以控制谁有权限编辑 Spark 中的内容和数据。

    Screenshot of the GitHub Spark publication menu. The "Data Access" visibility option is outlined in orange.

    选择 只读 让其他人只能查看你的应用,且不能创建、编辑或删除任何内容或数据。选择 可写访问 以允许用户编辑并查看 Spark 中的内容和数据。

    例如,如果你创建了一个家庭日历应用并想展示它,但暂时不希望用户创建、编辑或删除日历事件,请选择 “只读”。

  4. 点击 查看站点以查看已部署的应用,然后复制并分享该应用的 URL。

后续步骤

我们刚刚创建了一个文字搜索应用,但 Spark 可以打造各种网页应用!尝试 自行创建新应用。如果需要灵感,这里有几个入门想法供你参考

  • 试着构建一个 新闻聚合应用智能食谱生成器
  • 构建一个 预算跟踪器,它允许你设定预算,输入支出清单,并显示剩余总预算。你可以为每笔支出指定类别和日期,然后按多种不同的类别对支出进行排序。

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.