From 69e8518790669a3ee99e3622c33e06addffceeda Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 13 Jan 2024 14:01:09 +0800 Subject: [PATCH] chroe: Script Example --- src/router/index.ts | 3 +++ src/views/editor/components/Script.vue | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/router/index.ts b/src/router/index.ts index a6ab4547e..997ba7a44 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,5 +1,6 @@ import { useEnvApi } from '@/api/env'; import { useSubsApi } from '@/api/subs'; +import { useFilesApi } from '@/api/files'; import AppLayout from '@/layout/AppLayout.vue'; import { useGlobalStore } from '@/store/global'; @@ -194,6 +195,8 @@ router.beforeResolve(async to => { await useSubsApi().getOne('sub', name); } else if (to.params.editType === 'collections') { await useSubsApi().getOne('collection', name); + }else if (to.params.editType === 'files') { + await useFilesApi().getOneFile(name); } } catch { router.replace('/404'); diff --git a/src/views/editor/components/Script.vue b/src/views/editor/components/Script.vue index 253bd8a01..f6c897e95 100644 --- a/src/views/editor/components/Script.vue +++ b/src/views/editor/components/Script.vue @@ -51,11 +51,27 @@ function filter(proxies, targetPlatform) { }); } `) : $t(`// Example: -// backend version(>2.14.147): +// backend version(>2.14.148): // $files: ['0', '1'] // $content: '0\\n1' +// produce proxies +let singboxProxies = JSON.parse(await produceArtifact({ + type: 'subscription', // type: 'subscription' 或 'collection' + name: 'sub', // subscription name + platform: 'sing-box' // target platform +})) + +let clashMetaProxies = ProxyUtils.yaml.safeLoad(await produceArtifact({ + type: 'subscription', + name: 'sub', + platform: 'ClashMeta' +})).proxies + +// YAML $content = ProxyUtils.yaml.safeDump({}) + +// JSON $content = JSON.stringify({}, null, 2) // { $content, $files } will be passed to the next operator