-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOpenAI.js
1056 lines (1004 loc) · 48.6 KB
/
OpenAI.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: teal; icon-glyph: atom;
/**
* OpenAI account usage
*
* @version 1.0.0
* @author Honye
*/
/**
* 多语言国际化
* @param {{[language: string]: string} | [en:string, zh:string]} langs
*/
const i18n = (langs) => {
const language = Device.language();
if (Array.isArray(langs)) {
langs = {
en: langs[0],
zh: langs[1],
others: langs[0]
};
} else {
langs.others = langs.others || langs.en;
}
return langs[language] || langs.others
};
/**
* @param {...string} paths
*/
const joinPath = (...paths) => {
const fm = FileManager.local();
return paths.reduce((prev, curr) => {
return fm.joinPath(prev, curr)
}, '')
};
/**
* 规范使用 FileManager。每个脚本使用独立文件夹
*
* 注意:桌面组件无法写入 cacheDirectory 和 temporaryDirectory
* @param {object} options
* @param {boolean} [options.useICloud]
* @param {string} [options.basePath]
*/
const useFileManager = (options = {}) => {
const { useICloud, basePath } = options;
const fm = useICloud ? FileManager.iCloud() : FileManager.local();
const paths = [fm.documentsDirectory(), Script.name()];
if (basePath) {
paths.push(basePath);
}
const cacheDirectory = joinPath(...paths);
/**
* 删除路径末尾所有的 /
* @param {string} filePath
*/
const safePath = (filePath) => {
return fm.joinPath(cacheDirectory, filePath).replace(/\/+$/, '')
};
/**
* 如果上级文件夹不存在,则先创建文件夹
* @param {string} filePath
*/
const preWrite = (filePath) => {
const i = filePath.lastIndexOf('/');
const directory = filePath.substring(0, i);
if (!fm.fileExists(directory)) {
fm.createDirectory(directory, true);
}
};
const writeString = (filePath, content) => {
const nextPath = safePath(filePath);
preWrite(nextPath);
fm.writeString(nextPath, content);
};
/**
* @param {string} filePath
* @param {*} jsonData
*/
const writeJSON = (filePath, jsonData) => writeString(filePath, JSON.stringify(jsonData));
/**
* @param {string} filePath
* @param {Image} image
*/
const writeImage = (filePath, image) => {
const nextPath = safePath(filePath);
preWrite(nextPath);
return fm.writeImage(nextPath, image)
};
/**
* 文件不存在时返回 null
* @param {string} filePath
* @returns {string|null}
*/
const readString = (filePath) => {
const fullPath = fm.joinPath(cacheDirectory, filePath);
if (fm.fileExists(fullPath)) {
return fm.readString(
fm.joinPath(cacheDirectory, filePath)
)
}
return null
};
/**
* @param {string} filePath
*/
const readJSON = (filePath) => JSON.parse(readString(filePath));
/**
* @param {string} filePath
*/
const readImage = (filePath) => {
return fm.readImage(fm.joinPath(cacheDirectory, filePath))
};
return {
cacheDirectory,
writeString,
writeJSON,
writeImage,
readString,
readJSON,
readImage
}
};
/** 规范使用文件缓存。每个脚本使用独立文件夹 */
const useCache = () => useFileManager({ basePath: 'cache' });
/**
* 轻松实现桌面组件可视化配置
*
* - 颜色选择器及更多表单控件
* - 快速预览
*
* GitHub: https://github.com/honye
*
* @version 1.4.0
* @author Honye
*/
const fm = FileManager.local();
const fileName = 'settings.json';
const toast = (message) => {
const notification = new Notification();
notification.title = Script.name();
notification.body = message;
notification.schedule();
};
const isUseICloud = () => {
const ifm = useFileManager({ useICloud: true });
const filePath = fm.joinPath(ifm.cacheDirectory, fileName);
return fm.fileExists(filePath)
};
/** 查看配置文件可导出分享 */
const exportSettings = () => {
const scopedFM = useFileManager({ useICloud: isUseICloud() });
const filePath = fm.joinPath(scopedFM.cacheDirectory, fileName);
if (fm.isFileStoredIniCloud(filePath)) {
fm.downloadFileFromiCloud(filePath);
}
if (fm.fileExists(filePath)) {
QuickLook.present(filePath);
} else {
const alert = new Alert();
alert.message = i18n(['Using default configuration', '使用的默认配置,未做任何修改']);
alert.addCancelAction(i18n(['OK', '好的']));
alert.present();
}
};
const importSettings = async () => {
const alert1 = new Alert();
alert1.message = i18n([
'Will replace existing configuration',
'会替换已有配置,确认导入吗?可将现有配置导出备份后再导入其他配置'
]);
alert1.addAction(i18n(['Import', '导入']));
alert1.addCancelAction(i18n(['Cancel', '取消']));
const i = await alert1.present();
if (i === -1) return
const pathList = await DocumentPicker.open(['public.json']);
for (const path of pathList) {
const fileName = fm.fileName(path, true);
const scopedFM = useFileManager({ useICloud: isUseICloud() });
const destPath = fm.joinPath(scopedFM.cacheDirectory, fileName);
if (fm.fileExists(destPath)) {
fm.remove(destPath);
}
const i = destPath.lastIndexOf('/');
const directory = destPath.substring(0, i);
if (!fm.fileExists(directory)) {
fm.createDirectory(directory, true);
}
fm.copy(path, destPath);
}
const alert = new Alert();
alert.message = i18n(['Imported success', '导入成功']);
alert.addAction(i18n(['Restart', '重新运行']));
await alert.present();
const callback = new CallbackURL('scriptable:///run');
callback.addParameter('scriptName', Script.name());
callback.open();
};
/**
* @returns {Promise<Settings>}
*/
const readSettings = async () => {
const useICloud = isUseICloud();
console.log(`[info] use ${useICloud ? 'iCloud' : 'local'} settings`);
const fm = useFileManager({ useICloud });
const settings = fm.readJSON(fileName);
return settings
};
/**
* @param {Record<string, unknown>} data
* @param {{ useICloud: boolean; }} options
*/
const writeSettings = async (data, { useICloud }) => {
const fm = useFileManager({ useICloud });
fm.writeJSON(fileName, data);
};
const removeSettings = async (settings) => {
const cache = useFileManager({ useICloud: settings.useICloud });
fm.remove(
fm.joinPath(cache.cacheDirectory, fileName)
);
};
const moveSettings = (useICloud, data) => {
const localFM = useFileManager();
const iCloudFM = useFileManager({ useICloud: true });
const [i, l] = [
fm.joinPath(iCloudFM.cacheDirectory, fileName),
fm.joinPath(localFM.cacheDirectory, fileName)
];
try {
// 移动文件需要创建父文件夹,写入操作会自动创建文件夹
writeSettings(data, { useICloud });
if (useICloud) {
if (fm.fileExists(l)) fm.remove(l);
} else {
if (fm.fileExists(i)) fm.remove(i);
}
} catch (e) {
console.error(e);
}
};
/**
* @typedef {object} NormalFormItem
* @property {string} name
* @property {string} label
* @property {'text'|'number'|'color'|'select'|'date'|'cell'} [type]
* - HTML <input> type 属性
* - `'cell'`: 可点击的
* @property {{ label: string; value: unknown }[]} [options]
* @property {unknown} [default]
*/
/**
* @typedef {Pick<NormalFormItem, 'label'|'name'> & { type: 'group', items: FormItem[] }} GroupFormItem
*/
/**
* @typedef {Omit<NormalFormItem, 'type'> & { type: 'page' } & Pick<Options, 'formItems'|'onItemClick'>} PageFormItem 单独的页面
*/
/**
* @typedef {NormalFormItem|GroupFormItem|PageFormItem} FormItem
*/
/**
* @typedef {object} CommonSettings
* @property {boolean} useICloud
* @property {string} [backgroundImage] 背景图路径
* @property {string} [backgroundColorLight]
* @property {string} [backgroundColorDark]
*/
/**
* @typedef {CommonSettings & Record<string, unknown>} Settings
*/
/**
* @typedef {object} Options
* @property {(data: {
* settings: Settings;
* family?: typeof config.widgetFamily;
* }) => ListWidget | Promise<ListWidget>} render
* @property {string} [head] 顶部插入 HTML
* @property {FormItem[]} [formItems]
* @property {(item: FormItem) => void} [onItemClick]
* @property {string} [homePage] 右上角分享菜单地址
* @property {(data: any) => void} [onWebEvent]
*/
/**
* @template T
* @typedef {T extends infer O ? {[K in keyof O]: O[K]} : never} Expand
*/
const previewsHTML =
`<div class="actions">
<button class="preview" data-size="small"><i class="iconfont icon-yingyongzhongxin"></i>${i18n(['Small', '预览小号'])}</button>
<button class="preview" data-size="medium"><i class="iconfont icon-daliebiao"></i>${i18n(['Medium', '预览中号'])}</button>
<button class="preview" data-size="large"><i class="iconfont icon-dantupailie"></i>${i18n(['Large', '预览大号'])}</button>
</div>`;
const copyrightHTML =
`<footer>
<div class="copyright">© UI powered by <a href="javascript:invoke('safari','https://www.imarkr.com');">iMarkr</a>.</div>
</footer>`;
/**
* @param {Expand<Options>} options
* @param {boolean} [isFirstPage]
* @param {object} [others]
* @param {Settings} [others.settings]
* @returns {Promise<ListWidget|undefined>} 仅在 Widget 中运行时返回 ListWidget
*/
const present = async (options, isFirstPage, others = {}) => {
const {
formItems = [],
onItemClick,
render,
head,
homePage = 'https://www.imarkr.com',
onWebEvent
} = options;
const cache = useCache();
const settings = others.settings || await readSettings() || {};
/**
* @param {Parameters<Options['render']>[0]} param
*/
const getWidget = async (param) => {
const widget = await render(param);
const { backgroundImage, backgroundColorLight, backgroundColorDark } = settings;
if (backgroundImage && fm.fileExists(backgroundImage)) {
widget.backgroundImage = fm.readImage(backgroundImage);
}
if (!widget.backgroundColor || backgroundColorLight || backgroundColorDark) {
widget.backgroundColor = Color.dynamic(
new Color(backgroundColorLight || '#ffffff'),
new Color(backgroundColorDark || '#242426')
);
}
return widget
};
if (config.runsInWidget) {
const widget = await getWidget({ settings });
Script.setWidget(widget);
return widget
}
// ====== web start =======
const style =
`:root {
--color-primary: #007aff;
--divider-color: rgba(60,60,67,0.36);
--card-background: #fff;
--card-radius: 10px;
--list-header-color: rgba(60,60,67,0.6);
}
* {
-webkit-user-select: none;
user-select: none;
}
body {
margin: 10px 0;
-webkit-font-smoothing: antialiased;
font-family: "SF Pro Display","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
accent-color: var(--color-primary);
}
input {
-webkit-user-select: auto;
user-select: auto;
}
body {
background: #f2f2f7;
}
button {
font-size: 16px;
background: var(--color-primary);
color: #fff;
border-radius: 8px;
border: none;
padding: 0.24em 0.5em;
}
button .iconfont {
margin-right: 6px;
}
.list {
margin: 15px;
}
.list__header {
margin: 0 20px;
color: var(--list-header-color);
font-size: 13px;
}
.list__body {
margin-top: 10px;
background: var(--card-background);
border-radius: var(--card-radius);
border-radius: 12px;
overflow: hidden;
}
.form-item {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 16px;
min-height: 2em;
padding: 0.5em 20px;
position: relative;
}
.form-item--link .icon-arrow_right {
color: #86868b;
}
.form-item + .form-item::before {
content: "";
position: absolute;
top: 0;
left: 20px;
right: 0;
border-top: 0.5px solid var(--divider-color);
}
.form-item .iconfont {
margin-right: 4px;
}
.form-item input,
.form-item select {
font-size: 14px;
text-align: right;
}
.form-item input[type="checkbox"] {
width: 1.25em;
height: 1.25em;
}
input[type="number"] {
width: 4em;
}
input[type="date"] {
min-width: 6.4em;
}
input[type='checkbox'][role='switch'] {
position: relative;
display: inline-block;
appearance: none;
width: 40px;
height: 24px;
border-radius: 24px;
background: #ccc;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']::before {
content: '';
position: absolute;
left: 2px;
top: 2px;
width: 20px;
height: 20px;
border-radius: 50%;
background: #fff;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']:checked {
background: var(--color-primary);
}
input[type='checkbox'][role='switch']:checked::before {
transform: translateX(16px);
}
.actions {
margin: 15px;
}
.copyright {
margin: 15px;
margin-inline: 18px;
font-size: 12px;
color: #86868b;
}
.copyright a {
color: #515154;
text-decoration: none;
}
.preview.loading {
pointer-events: none;
}
.icon-loading {
display: inline-block;
animation: 1s linear infinite spin;
}
@keyframes spin {
0% {
transform: rotate(0);
}
100% {
transform: rotate(1turn);
}
}
@media (prefers-color-scheme: dark) {
:root {
--divider-color: rgba(84,84,88,0.65);
--card-background: #1c1c1e;
--list-header-color: rgba(235,235,245,0.6);
}
body {
background: #000;
color: #fff;
}
}
`;
const js =
`(() => {
const settings = ${JSON.stringify({
...settings,
useICloud: isUseICloud()
})}
const formItems = ${JSON.stringify(formItems)}
window.invoke = (code, data) => {
window.dispatchEvent(
new CustomEvent(
'JBridge',
{ detail: { code, data } }
)
)
}
const formData = {};
const createFormItem = (item) => {
const value = settings[item.name] ?? item.default ?? null
formData[item.name] = value;
const label = document.createElement("label");
label.className = "form-item";
const div = document.createElement("div");
div.innerText = item.label;
label.appendChild(div);
if (item.type === 'select') {
const select = document.createElement('select')
select.className = 'form-item__input'
select.name = item.name
select.value = value
for (const opt of (item.options || [])) {
const option = document.createElement('option')
option.value = opt.value
option.innerText = opt.label
option.selected = value === opt.value
select.appendChild(option)
}
select.addEventListener('change', (e) => {
formData[item.name] = e.target.value
invoke('changeSettings', formData)
})
label.appendChild(select)
} else if (
item.type === 'cell' ||
item.type === 'page'
) {
label.classList.add('form-item--link')
const icon = document.createElement('i')
icon.className = 'iconfont icon-arrow_right'
label.appendChild(icon)
label.addEventListener('click', () => {
const { name } = item
switch (name) {
case 'backgroundImage':
invoke('chooseBgImg')
break
case 'clearBackgroundImage':
invoke('clearBgImg')
break
case 'reset':
reset()
break
default:
invoke('itemClick', item)
}
})
} else {
const input = document.createElement("input")
input.className = 'form-item__input'
input.name = item.name
input.type = item.type || "text";
input.enterKeyHint = 'done'
input.value = value
// Switch
if (item.type === 'switch') {
input.type = 'checkbox'
input.role = 'switch'
input.checked = value
if (item.name === 'useICloud') {
input.addEventListener('change', (e) => {
invoke('moveSettings', e.target.checked)
})
}
}
if (item.type === 'number') {
input.inputMode = 'decimal'
}
if (input.type === 'text') {
input.size = 12
}
input.addEventListener("change", (e) => {
formData[item.name] =
item.type === 'switch'
? e.target.checked
: item.type === 'number'
? Number(e.target.value)
: e.target.value;
invoke('changeSettings', formData)
});
label.appendChild(input);
}
return label
}
const createList = (list, title) => {
const fragment = document.createDocumentFragment()
let elBody;
for (const item of list) {
if (item.type === 'group') {
const grouped = createList(item.items, item.label)
fragment.appendChild(grouped)
} else {
if (!elBody) {
const groupDiv = fragment.appendChild(document.createElement('div'))
groupDiv.className = 'list'
if (title) {
const elTitle = groupDiv.appendChild(document.createElement('div'))
elTitle.className = 'list__header'
elTitle.textContent = title
}
elBody = groupDiv.appendChild(document.createElement('div'))
elBody.className = 'list__body'
}
const label = createFormItem(item)
elBody.appendChild(label)
}
}
return fragment
}
const fragment = createList(formItems)
document.getElementById('settings').appendChild(fragment)
for (const btn of document.querySelectorAll('.preview')) {
btn.addEventListener('click', (e) => {
const target = e.currentTarget
target.classList.add('loading')
const icon = e.currentTarget.querySelector('.iconfont')
const className = icon.className
icon.className = 'iconfont icon-loading'
const listener = (event) => {
const { code } = event.detail
if (code === 'previewStart') {
target.classList.remove('loading')
icon.className = className
window.removeEventListener('JWeb', listener);
}
}
window.addEventListener('JWeb', listener)
invoke('preview', e.currentTarget.dataset.size)
})
}
const setFieldValue = (name, value) => {
const input = document.querySelector(\`.form-item__input[name="\${name}"]\`)
if (!input) return
if (input.type === 'checkbox') {
input.checked = value
} else {
input.value = value
}
}
const reset = (items = formItems) => {
for (const item of items) {
if (item.type === 'group') {
reset(item.items)
} else if (item.type === 'page') {
continue;
} else {
setFieldValue(item.name, item.default)
}
}
invoke('removeSettings', formData)
}
})()`;
const html =
`<html>
<head>
<meta name='viewport' content='width=device-width, user-scalable=no'>
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3772663_kmo790s3yfq.css" type="text/css">
<style>${style}</style>
</head>
<body>
${head || ''}
<section id="settings"></section>
${isFirstPage ? (previewsHTML + copyrightHTML) : ''}
<script>${js}</script>
</body>
</html>`;
const webView = new WebView();
await webView.loadHTML(html, homePage);
const clearBgImg = () => {
const { backgroundImage } = settings;
delete settings.backgroundImage;
if (backgroundImage && fm.fileExists(backgroundImage)) {
fm.remove(backgroundImage);
}
writeSettings(settings, { useICloud: settings.useICloud });
toast(i18n(['Cleared success!', '背景已清除']));
};
const chooseBgImg = async () => {
try {
const image = await Photos.fromLibrary();
cache.writeImage('bg.png', image);
const imgPath = fm.joinPath(cache.cacheDirectory, 'bg.png');
settings.backgroundImage = imgPath;
writeSettings(settings, { useICloud: settings.useICloud });
} catch (e) {
console.log('[info] 用户取消选择图片');
}
};
const injectListener = async () => {
const event = await webView.evaluateJavaScript(
`(() => {
const controller = new AbortController()
const listener = (e) => {
completion(e.detail)
controller.abort()
}
window.addEventListener(
'JBridge',
listener,
{ signal: controller.signal }
)
})()`,
true
).catch((err) => {
console.error(err);
throw err
});
const { code, data } = event;
switch (code) {
case 'preview': {
const widget = await getWidget({ settings, family: data });
webView.evaluateJavaScript(
'window.dispatchEvent(new CustomEvent(\'JWeb\', { detail: { code: \'previewStart\' } }))',
false
);
widget[`present${data.replace(data[0], data[0].toUpperCase())}`]();
break
}
case 'safari':
Safari.openInApp(data, true);
break
case 'changeSettings':
Object.assign(settings, data);
writeSettings(settings, { useICloud: settings.useICloud });
break
case 'moveSettings':
settings.useICloud = data;
moveSettings(data, settings);
break
case 'removeSettings':
Object.assign(settings, data);
clearBgImg();
removeSettings(settings);
break
case 'chooseBgImg':
chooseBgImg();
break
case 'clearBgImg':
clearBgImg();
break
case 'itemClick':
if (data.type === 'page') {
// `data` 经传到 HTML 后丢失了不可序列化的数据,因为需要从源数据查找
const item = (() => {
const find = (items) => {
for (const el of items) {
if (el.name === data.name) return el
if (el.type === 'group') {
const r = find(el.items);
if (r) return r
}
}
return null
};
return find(formItems)
})();
await present(item, false, { settings });
} else {
await onItemClick?.(data, { settings });
}
break
case 'native':
onWebEvent?.(data);
break
}
injectListener();
};
injectListener().catch((e) => {
console.error(e);
throw e
});
webView.present();
// ======= web end =========
};
/**
* @param {Options} options
*/
const withSettings = async (options) => {
const { formItems, onItemClick, ...restOptions } = options;
return present({
formItems: [
{
label: i18n(['Common', '通用']),
type: 'group',
items: [
{
label: i18n(['Sync with iCloud', 'iCloud 同步']),
type: 'switch',
name: 'useICloud',
default: false
},
{
label: i18n(['Background', '背景']),
type: 'page',
name: 'background',
formItems: [
{
label: i18n(['Background', '背景']),
type: 'group',
items: [
{
name: 'backgroundColorLight',
type: 'color',
label: i18n(['Background color (light)', '背景色(白天)']),
default: '#ffffff'
},
{
name: 'backgroundColorDark',
type: 'color',
label: i18n(['Background color (dark)', '背景色(夜间)']),
default: '#242426'
},
{
label: i18n(['Background image', '背景图']),
type: 'cell',
name: 'backgroundImage'
}
]
},
{
type: 'group',
items: [
{
label: i18n(['Clear background image', '清除背景图']),
type: 'cell',
name: 'clearBackgroundImage'
}
]
}
]
},
{
label: i18n(['Reset', '重置']),
type: 'cell',
name: 'reset'
}
]
},
{
type: 'group',
items: [
{
label: i18n(['Export settings', '导出配置']),
type: 'cell',
name: 'export'
},
{
label: i18n(['Import settings', '导入配置']),
type: 'cell',
name: 'import'
}
]
},
{
label: i18n(['Settings', '设置']),
type: 'group',
items: formItems
}
],
onItemClick: (item, ...args) => {
const { name } = item;
if (name === 'export') {
exportSettings();
}
if (name === 'import') {
importSettings().catch((err) => {
console.error(err);
throw err
});
}
onItemClick?.(item, ...args);
},
...restOptions
}, true)
};
const preference = {
apiKey: '',
titleColor: '#8e8e93',
titleColorDark: '#8e8e93',
contentColor: '#333333',
contentColorDark: '#ffffff'
};
const cache = useCache();
const getBalance = async () => {
const { apiKey } = preference;
const request = new Request('https://api.openai.com/dashboard/billing/credit_grants');
request.headers = {
Authorization: `Bearer ${apiKey}`
};
try {
const json = await request.loadJSON();
if (json.error) {
const notification = new Notification();
notification.title = Script.name();
notification.body = i18n(['Session has expired!', 'Session Key 已过期!']);
notification.openURL = 'https://platform.openai.com/account/usage';
notification.schedule();
throw new Error(json.error.message)
}
cache.writeJSON('credit_grants.json', json);
return json
} catch (e) {
const json = cache.readJSON('credit_grants.json');
return json
}
};
const genSmallBg = () => {
const image = Image.fromData(Data.fromBase64String(
'iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAD62SURBVHgB7X15jBzXfearruqj+pyDzWMkyxJj0bscB8lGih3b8WoEK5LpyLKcxRCIbGWVLJYCspAAC3YsOQHY/MPyiSiQEC9ELBDB2mgXM7trR1ZIS5HDkS3HsVdcB5uQC1M2TdkyDzXn6ruurn2/qq7uOl5VvVddQ/VQ9RHN7umqrunprq++3/049BbCgcPHyjmOz6ECQkXCdlXmubBjqIpk7pPP++6jDfZx7pF3HafHdcRu89nPfLSJIkLXde4TtR+UtHyjyKN0yvkeZI5PZ3S4d74qN9pHkEP/Xk1NcfAKIaW3fi7zmyu1W1UUEQu1E8L1+FDXo5fkWq3WZ3kt3j91anN/FmWmM0gURJRTMykllUZZ5359TbH9TVnPcfqqwjmedf2gqYrjMwn9gK4W3Pup5wutIlBjgMEjN1G2jiTOfXU50/7rI7/VQBGxWFsqSmK2LAyIIeJ/5PfhRwKTKDQkSWOSDH/gM43zktochyhx4cADx7LFfDqXmRFKKtd3nOp+ROkPCOChTnb0wE6StwRBgBy9GXF4hqpy1/y7C9EIYuwXQhKyipjP5LOacvRTt15GEbC4tMQLp6vTqmCeEFpacrxfElHiIImxn6Um+M/Xs+rG05++o40mBECW3HV8Rej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/qo+VltAQrZyFSz3qCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQIEGCBAkSJEiQgBn/HycwXZ5QH0dCAAAAAElFTkSuQmCC'
));
return image
};
const addItem = (container, data) => {
const {
titleColor, titleColorDark,
contentColor, contentColorDark
} = preference;
const { title, content } = data;
const titleText = container.addText(title);
titleText.textColor = Color.dynamic(
new Color(titleColor),
new Color(titleColorDark)
);
titleText.font = Font.systemFont(14);
container.addSpacer(2);
const contentText = container.addText(content);
contentText.textColor = Color.dynamic(
new Color(contentColor),
new Color(contentColorDark)
);
contentText.font = Font.mediumSystemFont(18);
};
const createWidget = async () => {
const widget = new ListWidget();
const bg = genSmallBg();
widget.backgroundImage = bg;
const { grants } = await getBalance();
const [data] = grants.data;
const { grant_amount, used_amount, expires_at } = data;