Skip to content

Commit

Permalink
chroe: Script Example
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 13, 2024
1 parent 8bb8e83 commit 69e8518
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
Expand Down
18 changes: 17 additions & 1 deletion src/views/editor/components/Script.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69e8518

Please sign in to comment.