-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
40 lines (35 loc) · 1.08 KB
/
Copy pathindex.tsx
File metadata and controls
40 lines (35 loc) · 1.08 KB
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
import { Intent, Navigation, Script } from "scripting"
import { HomeView } from "./components/HomeView"
import { runShortcutUpdate } from "./utils/shortcut_update"
function hasShortcutInput(): boolean {
return !!(
Intent.shortcutParameter ||
Intent.textsParameter?.length ||
Intent.urlsParameter?.length ||
Intent.fileURLsParameter?.length
)
}
async function run() {
if (hasShortcutInput()) {
try {
console.log("[Surge模块管理][Intent] handled by index.tsx")
const result = await runShortcutUpdate({
shortcutParameter: Intent.shortcutParameter,
textsParameter: Intent.textsParameter,
})
Script.exit(Intent.text(result.text))
return
} catch (e: any) {
const message = String(e?.stack ?? e?.message ?? e)
console.log(`[Surge模块管理][Intent] index fatal: ${message}`)
Script.exit(Intent.text(`Surge 模块更新失败:${message}`))
return
}
}
await Navigation.present({
element: <HomeView />,
})
// 视图关闭后退出脚本(Scripting 推荐模式)
Script.exit()
}
run()