Added support for local subscription

This commit is contained in:
Peng-YM committed 2022-05-25 17:32:05 +08:00
1 parent 8c7e8f01ee
commit 7b4f75fddc
4 files changed
+125 -168

No files matched your search

+15 -12
View File
@@ -265,15 +265,18 @@ async function syncArtifact(files) {
return manager.upload(files);
}
async function produceArtifact(
{ type, item, platform, noProcessor } = {
platform: 'JSON',
noProcessor: false,
},
) {
async function produceArtifact({ type, item, platform, noProcessor }) {
platform = platform || 'JSON';
noProcessor = noProcessor || false;
if (type === 'subscription') {
const sub = item;
const raw = await download(sub.url, sub.ua);
let raw;
if (sub.source === 'local') {
raw = sub.content;
} else {
raw = await download(sub.url, sub.ua);
}
// parse proxies
let proxies = ProxyUtils.parse(raw);
if (!noProcessor) {
@@ -306,12 +309,12 @@ async function produceArtifact(
} else if (type === 'collection') {
const allSubs = $.read(SUBS_KEY);
const collection = item;
const subs = collection['subscriptions'];
const subnames = collection['subscriptions'];
const results = {};
let processed = 0;
await Promise.all(
subs.map(async (name) => {
subnames.map(async (name) => {
const sub = allSubs[name];
try {
$.info(`正在处理子订阅:${sub.name}...`);
@@ -330,7 +333,7 @@ async function produceArtifact(
processed++;
$.info(
`✅ 子订阅:${sub.name}加载成功,进度--${
100 * (processed / subs.length).toFixed(1)
100 * (processed / subnames.length).toFixed(1)
}% `,
);
} catch (err) {
@@ -339,7 +342,7 @@ async function produceArtifact(
`❌ 处理组合订阅中的子订阅: ${
sub.name
}时出现错误:${err},该订阅已被跳过!进度--${
100 * (processed / subs.length).toFixed(1)
100 * (processed / subnames.length).toFixed(1)
}%`,
);
}
@@ -349,7 +352,7 @@ async function produceArtifact(
// merge proxies with the original order
let proxies = Array.prototype.concat.apply(
[],
subs.map((name) => results[name]),
subnames.map((name) => results[name]),
);
if (!noProcessor) {
+6 -4
View File
@@ -35,10 +35,12 @@ async function downloadSubscription(req, res) {
noProcessor: raw,
});
// forward flow headers
const flowInfo = await getFlowHeaders(sub.url);
if (flowInfo) {
res.set('subscription-userinfo', flowInfo);
if (sub.source !== 'local') {
// forward flow headers
const flowInfo = await getFlowHeaders(sub.url);
if (flowInfo) {
res.set('subscription-userinfo', flowInfo);
}
}
if (platform === 'JSON') {
+2 -2
View File
@@ -6,11 +6,11 @@
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
* @updated: 2022/5/25 下午1:39:08
* @updated: 2022/5/25 下午5:13:43
* @version: 1.5.1
* @author: Peng-YM
* @github: https://github.com/Peng-YM/Sub-Store
* @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46
*/
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|c(e,n),a=t(o),i=a.write(e,n);return i!==o&&(a=a.slice(0,i)),a}(e,n);if(ArrayBuffer.isView(e))return i(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(N(e,ArrayBuffer)||e&&N(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var a=e.valueOf&&e.valueOf();if(null!=a&&a!==e)return r.from(a,n,o);var u=function(e){if(r.isBuffer(e)){var n=0|s(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?t(0):i(e):"Buffer"===e.type&&Array.isArray(e.data)?i(e.data):void 0}(e);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(e){return o(e),t(e<0?0:0|s(e))}function i(e){for(var r=e.length<0?0:0|s(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function s(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function c(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return C(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return P(t).length;default:if(a)return o?-1:C(t).length;e=(""+e).toLowerCase(),a=!0}}function u(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function f(t,e,n,o,a){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=a?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(a)return-1;n=t.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:p(t,e,n,o,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,o,a);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,o){var a,i=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,s/=2,c/=2,r/=2}function u(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){var f=-1;for(a=r;a<s;a++)if(u(t,a)===u(e,-1===f?0:a-f)){if(-1===f&&(f=a),a-f+1===c)return f*i}else-1!==f&&(a-=a-f),f=-1}else for(r+c>s&&(r=s-c),a=r;a>=0;a--){for(var p=!0,l=0;l<c;l++)if(u(t,a+l)!==u(e,l)){p=!1;break}if(p)return a}return-1}function l(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var a=e.length;n>a/2&&(n=a/2);for(var i=0;i<n;++i){var s=parseInt(e.substr(2*i,2),16);if(j(s))return i;t[r+i]=s}return i}function _(t,e,r,n){return I(C(e,t.length-r),t,r,n)}function h(t,e,r,n){return I(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return h(t,e,r,n)}function y(t,e,r,n){return I(P(e),t,r,n)}function v(t,e,r,n){return I(function(t,e){for(var r,n,o,a=[],i=0;i<t.length&&!((e-=2)<0);++i)n=(r=t.charCodeAt(i))>>8Line truncated
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return i(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|c(e,n),i=t(o),a=i.write(e,n);return a!==o&&(i=i.slice(0,a)),i}(e,n);if(ArrayBuffer.isView(e))return a(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(N(e,ArrayBuffer)||e&&N(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return r.from(i,n,o);var u=function(e){if(r.isBuffer(e)){var n=0|s(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?t(0):a(e):"Buffer"===e.type&&Array.isArray(e.data)?a(e.data):void 0}(e);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function i(e){return o(e),t(e<0?0:0|s(e))}function a(e){for(var r=e.length<0?0:0|s(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function s(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function c(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return P(t).length;default:if(i)return o?-1:k(t).length;e=(""+e).toLowerCase(),i=!0}}function u(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function l(t,e,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:f(t,e,n,o,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):f(t,[e],n,o,i);throw new TypeError("val must be string, number or Buffer")}function f(t,e,r,n,o){var i,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var l=-1;for(i=r;i<s;i++)if(u(t,i)===u(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*a}else-1!==l&&(i-=i-l),l=-1}else for(r+c>s&&(r=s-c),i=r;i>=0;i--){for(var f=!0,p=0;p<c;p++)if(u(t,i+p)!==u(e,p)){f=!1;break}if(f)return i}return-1}function p(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(j(s))return a;t[r+a]=s}return a}function _(t,e,r,n){return I(k(e,t.length-r),t,r,n)}function h(t,e,r,n){return I(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return h(t,e,r,n)}function y(t,e,r,n){return I(P(e),t,r,n)}function m(t,e,r,n){return I(function(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8Line truncated
+102 -150
View File
@@ -3,72 +3,47 @@
<v-card class="mb-4">
<v-subheader>订阅配置</v-subheader>
<v-form v-model="formState.basicValid" class="pl-4 pr-4 pb-0">
<v-text-field
v-model="options.name"
:rules="validations.nameRules"
class="mt-2"
clear-icon="clear"
clearable
label="订阅名称"
placeholder="填入订阅名称,名称需唯一"
required
/>
<v-text-field v-model="options.name" :rules="validations.nameRules" class="mt-2" clear-icon="clear" clearable
label="订阅名称" placeholder="填入订阅名称,名称需唯一" required />
<!--For Subscription-->
<v-textarea
v-if="!isCollection"
v-model="options.url"
:rules="validations.urlRules"
auto-grow
class="mt-2"
clear-icon="clear"
clearable
label="订阅链接"
placeholder="填入机场原始订阅链接"
required
rows="2"
/>
<v-radio-group v-if="!isCollection" v-model="options.source" class="mt-0 mb-0">
<template v-slot:label>
<div style="font-size: 2px">订阅来源</div>
</template>
<v-row dense>
<v-col>
<v-radio label="远程" value="remote" />
</v-col>
<v-col>
<v-radio label="本地" value="local" />
</v-col>
<v-col></v-col>
</v-row>
</v-radio-group>
<v-textarea v-if="options.source !== 'local'" v-model="options.url" :rules="validations.urlRules" auto-grow
class="mt-0" clear-icon="clear" clearable label="订阅链接" placeholder="填入机场原始订阅链接" required rows="2" />
<v-textarea v-if="options.source === 'local'" v-model="options.content" clear-icon="clear" clearable
label="订阅内容" placeholder="填入原始订阅内容" autogrow rows="5" row-height="15" class="mt-0">
</v-textarea>
<v-textarea v-if="!isCollection && options.source !== 'local'" v-model="options.ua" auto-grow class="mt-2"
clear-icon="clear" clearable label="User-Agent" placeholder="自定义下载订阅使用的User-Agent,可选。" rows="2" />
<!--For Collection-->
<v-list
v-if="isCollection"
dense
>
<v-list v-if="isCollection" dense>
<v-subheader class="pl-0">包含的订阅</v-subheader>
<v-list-item v-for="sub in availableSubs" :key="sub.name">
<v-list-item-avatar>
<v-icon v-if="!sub.icon" color="teal darken-1">mdi-cloud</v-icon>
<v-img v-else :class="getIconClass(sub.icon)" :src="sub.icon"/>
<v-img v-else :class="getIconClass(sub.icon)" :src="sub.icon" />
</v-list-item-avatar>
<v-list-item-content>
{{ sub.name }}
</v-list-item-content>
<v-spacer></v-spacer>
<v-checkbox
v-model="selected"
:value="sub.name"
class="pr-1"
/>
<v-checkbox v-model="selected" :value="sub.name" class="pr-1" />
</v-list-item>
</v-list>
<v-textarea
v-model="options.ua"
auto-grow
class="mt-2"
clear-icon="clear"
clearable
label="User-Agent"
placeholder="自定义下载订阅使用的User-Agent,可选。"
rows="2"
/>
<v-textarea
v-model="options.icon"
auto-grow
class="mt-2"
clear-icon="clear"
clearable
label="图标链接"
placeholder="填入想要展示的图标链接,可选。"
rows="2"
/>
<v-textarea v-model="options.icon" auto-grow class="mt-2" clear-icon="clear" clearable label="图标链接"
placeholder="填入想要展示的图标链接,可选。" rows="2" />
</v-form>
<v-card-actions>
<v-spacer></v-spacer>
@@ -76,7 +51,7 @@
<v-icon>save_alt</v-icon>
</v-btn>
<v-dialog v-model="showShareDialog" max-width="400px">
<template #activator="{on}">
<template #activator="{ on }">
<v-btn v-on="on" icon>
<v-icon>cloud_circle</v-icon>
</v-btn>
@@ -85,20 +60,13 @@
<v-card-title>
<v-icon left>cloud_circle</v-icon>
配置导入
<v-spacer/>
<v-spacer />
<v-btn icon @click="share">
<v-icon small>share</v-icon>
</v-btn>
</v-card-title>
<v-textarea
v-model="imported"
:rules="validations.importRules"
clear-icon="clear"
clearable
label="粘贴配置以导入"
rows="5"
solo
/>
<v-textarea v-model="imported" :rules="validations.importRules" clear-icon="clear" clearable label="粘贴配置以导入"
rows="5" solo />
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" text @click="importConf">确认</v-btn>
@@ -113,93 +81,73 @@
<v-subheader>常用选项</v-subheader>
<v-form class="pl-4 pr-4">
<v-item-group>
<v-radio-group
v-model="options.useless"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options.useless" class="mt-0 mb-0" dense>
过滤非法节点
<v-row>
<v-col>
<v-radio label="保留" value="KEEP"/>
<v-radio label="保留" value="KEEP" />
</v-col>
<v-col>
<v-radio label="删除" value="REMOVE"/>
<v-radio label="删除" value="REMOVE" />
</v-col>
<v-col></v-col>
</v-row>
</v-radio-group>
<v-radio-group
v-model="options.udp"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options.udp" class="mt-0 mb-0" dense>
UDP转发
<v-row>
<v-col>
<v-radio label="默认" value="DEFAULT"/>
<v-radio label="默认" value="DEFAULT" />
</v-col>
<v-col>
<v-radio label="强制开启" value="FORCE_OPEN"/>
<v-radio label="强制开启" value="FORCE_OPEN" />
</v-col>
<v-col>
<v-radio label="强制关闭" value="FORCE_CLOSE"/>
<v-radio label="强制关闭" value="FORCE_CLOSE" />
</v-col>
</v-row>
</v-radio-group>
<v-radio-group
v-model="options['skip-cert-verify']"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options['skip-cert-verify']" class="mt-0 mb-0" dense>
跳过证书验证
<v-row>
<v-col>
<v-radio label="默认" value="DEFAULT"/>
<v-radio label="默认" value="DEFAULT" />
</v-col>
<v-col>
<v-radio label="强制跳过" value="FORCE_OPEN"/>
<v-radio label="强制跳过" value="FORCE_OPEN" />
</v-col>
<v-col>
<v-radio label="强制验证" value="FORCE_CLOSE"/>
<v-radio label="强制验证" value="FORCE_CLOSE" />
</v-col>
</v-row>
</v-radio-group>
<v-radio-group
v-model="options.tfo"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options.tfo" class="mt-0 mb-0" dense>
TCP Fast Open
<v-row>
<v-col>
<v-radio label="默认" value="DEFAULT"/>
<v-radio label="默认" value="DEFAULT" />
</v-col>
<v-col>
<v-radio label="强制开启" value="FORCE_OPEN"/>
<v-radio label="强制开启" value="FORCE_OPEN" />
</v-col>
<v-col>
<v-radio label="强制关闭" value="FORCE_CLOSE"/>
<v-radio label="强制关闭" value="FORCE_CLOSE" />
</v-col>
</v-row>
</v-radio-group>
<v-radio-group
v-model="options['vmess-aead']"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options['vmess-aead']" class="mt-0 mb-0" dense>
Vmess AEAD
<v-row>
<v-col>
<v-radio label="默认" value="DEFAULT"/>
<v-radio label="默认" value="DEFAULT" />
</v-col>
<v-col>
<v-radio label="强制开启" value="FORCE_OPEN"/>
<v-radio label="强制开启" value="FORCE_OPEN" />
</v-col>
<v-col>
<v-radio label="强制关闭" value="FORCE_CLOSE"/>
<v-radio label="强制关闭" value="FORCE_CLOSE" />
</v-col>
</v-row>
</v-radio-group>
@@ -210,21 +158,17 @@
<v-card class="mb-4">
<v-subheader>Surge 选项</v-subheader>
<v-form class="pl-4 pr-4">
<v-radio-group
v-model="options['surge-hybrid']"
class="mt-0 mb-0"
dense
>
<v-radio-group v-model="options['surge-hybrid']" class="mt-0 mb-0" dense>
Hybrid 策略
<v-row>
<v-col>
<v-radio label="默认" value="DEFAULT"/>
<v-radio label="默认" value="DEFAULT" />
</v-col>
<v-col>
<v-radio label="强制开启" value="FORCE_OPEN"/>
<v-radio label="强制开启" value="FORCE_OPEN" />
</v-col>
<v-col>
<v-radio label="强制关闭" value="FORCE_CLOSE"/>
<v-radio label="强制关闭" value="FORCE_CLOSE" />
</v-col>
</v-row>
</v-radio-group>
@@ -235,7 +179,7 @@
节点操作
<v-spacer></v-spacer>
<v-dialog v-model="dialog" scrollable>
<template #activator="{on}">
<template #activator="{ on }">
<v-btn v-on="on" icon>
<v-icon color="primary">add_circle</v-icon>
</v-btn>
@@ -246,7 +190,7 @@
<v-card-text>
<v-radio-group v-model="selectedProcess" dense>
<v-radio v-for="(k, idx) in Object.keys(availableProcessors)" :key="idx"
:label="availableProcessors[k].name" :value="k"></v-radio>
:label="availableProcessors[k].name" :value="k"></v-radio>
</v-radio-group>
</v-card-text>
<v-card-actions>
@@ -259,22 +203,15 @@
</v-subheader>
<v-divider></v-divider>
<component :is="p.component"
v-for="p in processors"
:key="p.id"
:args="p.args"
@dataChanged="dataChanged"
@deleteProcess="deleteProcess"
@down="moveDown"
@up="moveUp"
>
<component :is="p.component" v-for="p in processors" :key="p.id" :args="p.args" @dataChanged="dataChanged"
@deleteProcess="deleteProcess" @down="moveDown" @up="moveUp">
</component>
</v-card>
</v-container>
</template>
<script>
import {showError, showInfo} from "@/utils";
import { showError, showInfo } from "@/utils";
import TypeFilter from "@/components/TypeFilter";
import RegionFilter from "@/components/RegionFilter";
import RegexFilter from "@/components/RegexFilter";
@@ -368,8 +305,8 @@ export default {
v => /^[\w-_]*$/.test(v) || "订阅名称只能包含英文字符、横杠和下划线!"
],
urlRules: [
v => !!v || "订阅链接不能为空!",
v => /^https?:\/\//.test(v) || "订阅链接不合法!"
v => this.options.source === 'remote' && (!!v || "订阅链接不能为空!"),
v => this.options.source === 'remote' && (/^https?:\/\//.test(v) || "订阅链接不合法!")
],
importRules: [
v => !!v || "不能导入空配置!"
@@ -380,7 +317,9 @@ export default {
},
options: {
name: "",
source: "",
url: "",
content: "",
icon: "",
ua: "",
useless: "KEEP",
@@ -408,7 +347,7 @@ export default {
this.$store.commit("SET_NAV_TITLE", source.name ? `订阅编辑 ➤ ${source.name}` : "新建订阅");
}
this.name = source.name;
const {options, process} = loadProcess(this.options, source);
const { options, process } = loadProcess(this.options, source);
this.options = options;
this.process = process;
},
@@ -442,13 +381,15 @@ export default {
output.subscriptions = this.selected;
} else {
output.url = this.options.url;
output.source = this.options.source;
output.content = this.options.content;
}
// assign user-agent, if ua is set
let ua = this.options.ua;
if (typeof ua != "undefined" && ua != null && ua.trim().length > 0) {
output.ua = ua;
}else{
output.ua=""
} else {
output.ua = ""
}
// useless filter
if (this.options.useless === 'REMOVE') {
@@ -461,7 +402,7 @@ export default {
if (this.options[opt] !== 'DEFAULT') {
output.process.push({
type: "Set Property Operator",
args: {key: opt, value: this.options[opt] === 'FORCE_OPEN'}
args: { key: opt, value: this.options[opt] === 'FORCE_OPEN' }
});
}
}
@@ -498,25 +439,33 @@ export default {
}
} else {
console.log("Saving subscription...");
if (this.options.name && this.options.url) {
if (this.$route.params.name !== "UNTITLED") {
this.$store.dispatch("UPDATE_SUBSCRIPTION", {
name: this.$route.params.name,
sub: this.config
}).then(() => {
showInfo(`成功保存订阅:${this.options.name}!`);
}).catch(() => {
showError(`发生错误,无法保存订阅!`);
});
} else {
this.$store.dispatch("NEW_SUBSCRIPTION", this.config).then(() => {
showInfo(`成功创建订阅:${this.options.name}!`);
this.$router.back();
}).catch(() => {
showError(`发生错误,无法创建订阅!`);
});
}
if (!this.options.name) {
showError(`订阅名字不能为空!`);
return;
}
if (this.options.source === 'remote' && !this.options.url) {
showError(`订阅链接不能为空!`);
return;
}
if (this.$route.params.name !== "UNTITLED") {
this.$store.dispatch("UPDATE_SUBSCRIPTION", {
name: this.$route.params.name,
sub: this.config
}).then(() => {
showInfo(`成功保存订阅:${this.options.name}!`);
}).catch(() => {
showError(`发生错误,无法保存订阅!`);
});
} else {
this.$store.dispatch("NEW_SUBSCRIPTION", this.config).then(() => {
showInfo(`成功创建订阅:${this.options.name}!`);
this.$router.back();
}).catch(() => {
showError(`发生错误,无法创建订阅!`);
});
}
}
},
@@ -537,9 +486,10 @@ export default {
importConf() {
if (this.imported) {
const sub = JSON.parse(this.imported);
const {options, process} = loadProcess(this.options, sub);
const { options, process } = loadProcess(this.options, sub);
delete options.name;
delete options.url;
delete options.content;
Object.assign(this.options, options);
this.process = process;
@@ -562,7 +512,7 @@ export default {
},
addProcess(type) {
this.process.push({type, id: uuidv4()});
this.process.push({ type, id: uuidv4() });
this.dialog = false;
},
@@ -616,6 +566,8 @@ function loadProcess(options, source, isCollection = false) {
options.subscriptions = source.subscriptions;
} else {
options.url = source.url;
options.source = source.source || "remote";
options.content = source.content;
}
let process = []
@@ -633,7 +585,7 @@ function loadProcess(options, source, isCollection = false) {
process.push(p);
}
}
return {options, process};
return { options, process };
}
function uuidv4() {