今天花了点时间整理了一下手机,因为最近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


微信
支付宝