【每日阅读】2020年9月19日-结合scriptable整理IOS14桌面

今天花了点时间整理了一下手机,因为最近ios更新到14了,多了一个App资源库,所以桌面可以只留每天都用的App,把不经常用的都放进App资源库。首先先放几张图。

上面我主要想讲一下中间那个古诗词的桌面小组件。那其实是使用了scriptable这个软件,这个软件支持写javascript代码。上面我是调用了每日诗词的接口获取的诗词然后显示出来。代码如下:

const shici = await fetchShiCi()
const widget = createWidget()
Script.setWidget(widget)
Script.complete()
console.log("success")

function createWidget() {
  const w = new ListWidget()

  const bgColor = new LinearGradient()
  bgColor.colors = [new Color("#1c1c1c"), new Color("#29323c")]
  bgColor.locations = [0.0, 1.0]
  w.backgroundGradient = bgColor

  const firstLine = w.addText(`[????] ${shici}`)
  firstLine.textSize = 12
  firstLine.textColor = Color.white()

  return w
}

async function fetchShiCi() {
  const url = "https://v1.jinrishici.com/all.txt"
  const request = new Request(url)
  const resp = await request.loadString()

  return resp
}

背景的红黄渐变也是代码里写的,可定制程度非常高。如果有什么关心的数据,都可以写脚本显示在桌面。

原创文章,作者:geekgao,如若转载,请注明出处:https://www.geekgao.cn/archives/2461

(0)
geekgaogeekgao博主
上一篇 2020年9月18日 上午1:03
下一篇 2020年9月20日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

GitHub
分享本页
返回顶部

Warning: error_log(/usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/#log/log-2016.txt): failed to open stream: No such file or directory in /usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/spider.class.php on line 2900