-
Notifications
You must be signed in to change notification settings - Fork 145
/
EnvExample.js
88 lines (73 loc) · 2.09 KB
/
EnvExample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: pink; icon-glyph: keyboard;
/**
* Author: GideonSenku
* Github: https://github.com/GideonSenku
*/
const { createWidget } = require("./Env")
// init
// importModule all of Env
const $ = importModule('Env')
/**
* importModule part of Env
* example:
* get(opts) for HTTP GET Methods
*/
const { get, post, msg } = importModule('Env')
msg('title','message','option')
// require some file,if file is JS and support module you can use it dirtctly
const opts = {
moduleName: "vue",
url: "https://cdn.jsdelivr.net/npm/[email protected]"
/** option:foreceDownload type:bool
*/
}
const Vue = await $.require(opts)
const fileName = $.initFile('Env')
log(fileName)
// wirteFile
$.writeFile('nihao.txt',`
const name = Senku,
const age = 18
const height = 1.88
`)
// readFile
const filedata = $.readFile('nihao.txt')
log(filedata)
// getStr and callback headers
const url = `https://github.com/GideonSenku/Scriptable/blob/master/READMEEN.md`
const res = $.getStr({url},(headers) => {
log(headers)
})
log(res)
// input, value为input的默认值,可选,默认为null
const inputValue = await $.input('title', 'message', 'placehoder','value')
const inputValue1 = await $.input('title', 'message', 'placehoder')
/**
*
* 示例:$.time('yyyy-MM-dd qq HH:mm:ss.S')
* :$.time('yyyyMMddHHmmssS')
* y:年 M:月 d:日 q:季 H:时 m:分 s:秒 S:毫秒
* 其中y可选0-4位占位符、S可选0-1位占位符,其余可选0-2位占位符
* @param {*} fmt 格式化参数
* @param {*} ts 时间戳 13位
*/
const time = $.time('yyyy-MM-dd HH:mm:ss')
const time = $.time('MMdd HH:mm:ss',1599124137000)
console.log(time)
// 模版创建小组件
await $.createWidget({
title: 'demo', // 必须
texts: { // 可选
one: '1',
one0: '2',
one1: '3',
one2: '4',
one3: '5',
one4: '5',
updateTime: 'true' // 可选参数,提供则添加更新时间线
},
spacing: 1, // 可选参数,设置每行的间隙
preview: 'large' // 可选参数,默认small,预览显小组件大小
})