你是否曾经有过一个很棒的应用想法,却没有工具来构建它呢? 借助 AI,现在你只需使用自然语言,就能在几分钟内将自己的应用想法变为现实。 在本文中,我们将使用 GitHub Spark 来构建、改进并分享一个单词搜索应用,全程无需自己编写任何代码。
注意
GitHub Spark 为公共预览版,可能发生更改。
创建应用的原型
让我们先生成一个初始的、基础版本的应用,之后我们可以在此基础上进行扩展。
-
发送以下提示,为你的应用生成第一个迭代版本:
Text 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.
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.
-
见证 Spark 实时构建你的应用吧! 当预览界面出现时,就说明应用生成完成了。
-
要测试你的应用,请使用预览功能创建并解决一个谜题。
改进应用
就像这样,我们的应用已经可以运行了! 但它仍需要进行一些调整。 让我们为 Spark 提供一些额外提示,以完善我们的项目。
-
在页面左侧的“Iterate”选项卡中,发送以下提示****:
Text 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.
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.
-
更新应用后,创建并解决另一个谜题,以查看正在运行的新功能。
-
发挥创意,自行改进这个应用吧! 如果你感到卡住了,可以从 Spark 在提示框上方提供的建议中选择一个。 你也可以通过“Theme”、“Data”和“Prompts”这几个选项卡中的可视化编辑控件进行修改,完全无需接触代码。
调试应用
在构建应用的过程中,你可能会遇到一些错误。 Spark 通常会识别这些问题,并在提示输入框上方以弹出形式显示在“Errors”窗口中。 要修复这些错误,请单击“Fix all”****。
如果发现了 Spark 自身没有标记的错误,可以写一条提示来修复它。 为获得最佳结果,请提供错误的详细描述以及理想的修复状态。 例如,如果你发现添加超过某个字符数的词语会导致谜题显示异常,可以发送以下提示:
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.
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.
共享应用
对你的应用感到满意后,就可以部署应用,以便与其他人共享。
注意
如果使所有 GitHub 用户都可以访问你的 spark,则所有用户都可以访问和编辑存储在你 spark 中的数据。 在使其他用户能够访问应用之前,请确保删除应用中的任何私密或敏感数据。
-
在页面右上角,单击“Publish”****。 默认情况下,你的 spark 部署为私密状态,仅你自己可访问。 要让其他 GitHub 用户能够访问你的应用,在发布下拉菜单的“Visibility”部分,选择 “All GitHub users”即可********。 这样,拥有 GitHub 帐户的任何人都可以访问你的 Spark。
-
单击“View site” ,查看已部署的应用,然后复制并共享应用的 URL****。
后续步骤
我们刚刚创建了一个单词搜索应用,但 Spark 可以制作各种类型的 Web 应用! 试着自己创建一个新应用吧。 如果你需要一些灵感,以下是几个入门的创意点子:
- 试着构建一个新闻聚合应用或一个智能食谱生成器********。
- 构建一个预算追踪器,以便设定预算、录入支出清单,并显示剩余预算总额****。 你可以为每笔支出添加类别和日期,然后按不同类别对支出进行排序。