吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2207|回复: 1
收起左侧

[讨论] 一个小白关于ios软件Scriptable的编程的疑惑

[复制链接]
ycshm 发表于 2020-10-24 19:56
最近ios 14 更新了。小组件的应用,使苹果卓里卓气了。
于是最近去找了个脚本。研究了下并不会
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: quote-right;

// Change these to your usernames!
const user = "spencer"

const jike = "4DDA0425-FB41-4188-89E4-952CA15E3C5E"
const telegram = "realSpencerWoo"
const github = "spencerwooo"
const sspai = "spencerwoo"
——以上应该是定义了几个常量——
const data = await fetchData()
const widget = createWidget(data)
Script.setWidget(widget)
Script.complete()

function createWidget(data) {
  console.log(data)
  const w = new ListWidget()
  const bgColor = new LinearGradient()
  bgColor.colors = [new Color("#29323c"), new Color("#1c1c1c")]
  bgColor.locations = [0.0, 1.0]
  w.backgroundGradient = bgColor
  w.setPadding(12, 15, 15, 12)
  w.spacing = 6
——这里应该是设置字体的颜色部分——
  const time = new Date()
  const dfTime = new DateFormatter()
  dfTime.locale = "en"
  dfTime.useMediumDateStyle()
  dfTime.useNoTimeStyle()

  const firstLine = w.addText(`[] ${user} ~$ now`)
  firstLine.textColor = Color.white()
  firstLine.textOpacity = 0.7
  firstLine.font = new Font("Menlo", 11)
  ——这里应该是定义时间——
  const timeLine = w.addText(`[🖥] ${dfTime.string(time)}`)
  timeLine.textColor = Color.white()
  timeLine.font = new Font("Menlo", 11)
  const batteryLine = w.addText(`[] ${renderBattery()}`)
  batteryLine.textColor = new Color("#6ef2ae")
  batteryLine.font = new Font("Menlo", 11)
  const jikeLine = w.addText(`[🤖] Jike: ${data.jikeFollower}`)
  jikeLine.textColor = new Color("#ffcc66")
  jikeLine.font = new Font("Menlo", 11)
  const telegramLine = w.addText(`[️️] Telegram: ${data.telegram}`)
  telegramLine.textColor = new Color("#7dbbae")
  telegramLine.font = new Font("Menlo", 11)
  const githubLine = w.addText(`[] GitHub: ${data.github}`)
  githubLine.textColor = new Color("#ff9468")
  githubLine.font = new Font("Menlo", 11)
  const sspaiLine = w.addText(`[🐡] SSPAI: ${data.sspai}`)
  sspaiLine.textColor = new Color("#ffa7d3")
  sspaiLine.font = new Font("Menlo", 11)
  return w
——这里应该是定义颜色和要显示的数据对应值——
}

async function fetchData() {
  const url = `https://api.spencerwoo.com/subst ... eFollower&queryKey=${jike}`
    + `&source=telegram&queryKey=${telegram}`
    + `&source=github&queryKey=${github}`
    + `&source=sspai&queryKey=${sspai}`
  const request = new Request(url)
  const res = await request.loadJSON()
  return res.data.subsInEachSource
}
——这里是利用API 查询需要的粉丝数或者点赞数——
function renderBattery() {
  const batteryLevel = Device.batteryLevel()
  const juice = "#".repeat(Math.floor(batteryLevel * 8))
  const used = ".".repeat(8 - juice.length)
  const batteryAscii = `[${juice}${used}] ${Math.round(batteryLevel * 100)}%`
  return batteryAscii
}

——这一栏是显示电池电量——
我只理解了这些代码的大概目的。但是我想进行DIY 修改成我自己的就无从下手了。
试着把API换成我的,但是貌似我替换的是B站的API ,不是电报,关键词不一样。(参考的是这个教程:https://www.bilibili.com/read/cv3178336/)还有这个教程(https://www.tenlonstudio.com/3365.html
搞到这一步我就懵逼无法进行下一步了。小白不懂。。。
尴尬。
求懂的大佬指一个方向、

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

a1209489180 发表于 2020-10-24 20:43
别搞ios了   在搞就彻底卓化了  
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-1 10:38

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表