mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-30 16:38:30 +00:00
Added support for non-ascii characters in subscriptions, collections and artifacts
This commit is contained in:
1 parent
4dbafb77c5
commit
e28e440dc5
9 files changed
+80
-106
No files matched your search
+1
-1
@@ -6,7 +6,7 @@
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @updated: 2022/5/26 上午11:17:01
|
||||
* @updated: 2022/5/30 下午1:47:20
|
||||
* @version: 1.6
|
||||
* @author: Peng-YM
|
||||
* @github: https://github.com/Peng-YM/Sub-Store
|
||||
|
||||
@@ -30,7 +30,8 @@ export default function register($app) {
|
||||
}
|
||||
|
||||
async function getArtifact(req, res) {
|
||||
const name = req.params.name;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
const action = req.query.action;
|
||||
const allArtifacts = $.read(ARTIFACTS_KEY);
|
||||
const artifact = allArtifacts[name];
|
||||
@@ -61,14 +62,15 @@ async function getArtifact(req, res) {
|
||||
console.log(JSON.stringify(artifact, null, 2));
|
||||
try {
|
||||
const resp = await syncArtifact({
|
||||
[artifact.name]: { content: output },
|
||||
[encodeURIComponent(artifact.name)]: {
|
||||
content: output,
|
||||
},
|
||||
});
|
||||
artifact.updated = new Date().getTime();
|
||||
const body = JSON.parse(resp.body);
|
||||
artifact.url = body.files[artifact.name].raw_url.replace(
|
||||
/\/raw\/[^/]*\/(.*)/,
|
||||
'/raw/$1',
|
||||
);
|
||||
artifact.url = body.files[
|
||||
encodeURIComponent(artifact.name)
|
||||
].raw_url.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1');
|
||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||
res.json({
|
||||
status: 'success',
|
||||
@@ -104,25 +106,19 @@ function createArtifact(req, res) {
|
||||
message: `远程配置${artifact.name}已存在!`,
|
||||
});
|
||||
} else {
|
||||
if (/^[\w-_.]*$/.test(artifact.name)) {
|
||||
allArtifacts[artifact.name] = artifact;
|
||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: artifact,
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: `远程配置名称 ${artifact.name} 中含有非法字符!名称中只能包含英文字母、数字、下划线、横杠。`,
|
||||
});
|
||||
}
|
||||
allArtifacts[artifact.name] = artifact;
|
||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: artifact,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateArtifact(req, res) {
|
||||
const allArtifacts = $.read(ARTIFACTS_KEY);
|
||||
const oldName = req.params.name;
|
||||
let oldName = req.params.name;
|
||||
oldName = decodeURIComponent(oldName);
|
||||
const artifact = allArtifacts[oldName];
|
||||
if (artifact) {
|
||||
$.info(`正在更新远程配置:${artifact.name}`);
|
||||
@@ -215,7 +211,8 @@ async function cronSyncArtifacts(_, res) {
|
||||
}
|
||||
|
||||
async function deleteArtifact(req, res) {
|
||||
const name = req.params.name;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
$.info(`正在删除远程配置:${name}`);
|
||||
const allArtifacts = $.read(ARTIFACTS_KEY);
|
||||
try {
|
||||
@@ -223,10 +220,11 @@ async function deleteArtifact(req, res) {
|
||||
if (!artifact) throw new Error(`远程配置:${name}不存在!`);
|
||||
if (artifact.updated) {
|
||||
// delete gist
|
||||
await syncArtifact({
|
||||
filename: name,
|
||||
const files = {};
|
||||
files[encodeURIComponent(artifact.name)] = {
|
||||
content: '',
|
||||
});
|
||||
};
|
||||
await syncArtifact(files);
|
||||
}
|
||||
// delete local cache
|
||||
delete allArtifacts[name];
|
||||
@@ -235,9 +233,7 @@ async function deleteArtifact(req, res) {
|
||||
status: 'success',
|
||||
});
|
||||
} catch (err) {
|
||||
// delete local cache
|
||||
delete allArtifacts[name];
|
||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||
$.error(`无法删除远程配置:${name},原因:${err}`);
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: `无法删除远程配置:${name}, 原因:${err}`,
|
||||
|
||||
@@ -20,7 +20,9 @@ export default function register($app) {
|
||||
|
||||
// collection API
|
||||
async function downloadCollection(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
|
||||
const { raw } = req.query || 'false';
|
||||
const platform =
|
||||
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
||||
@@ -90,24 +92,17 @@ function createCollection(req, res) {
|
||||
message: `订阅集${collection.name}已存在!`,
|
||||
});
|
||||
}
|
||||
// validate name
|
||||
if (/^[\w-_]*$/.test(collection.name)) {
|
||||
allCol[collection.name] = collection;
|
||||
$.write(allCol, COLLECTIONS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: collection,
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: `订阅集名称 ${collection.name} 中含有非法字符!名称中只能包含英文字母、数字、下划线、横杠。`,
|
||||
});
|
||||
}
|
||||
allCol[collection.name] = collection;
|
||||
$.write(allCol, COLLECTIONS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: collection,
|
||||
});
|
||||
}
|
||||
|
||||
function getCollection(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
const collection = $.read(COLLECTIONS_KEY)[name];
|
||||
if (collection) {
|
||||
res.json({
|
||||
@@ -123,7 +118,8 @@ function getCollection(req, res) {
|
||||
}
|
||||
|
||||
function updateCollection(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
let collection = req.body;
|
||||
const allCol = $.read(COLLECTIONS_KEY);
|
||||
if (allCol[name]) {
|
||||
@@ -149,7 +145,8 @@ function updateCollection(req, res) {
|
||||
}
|
||||
|
||||
function deleteCollection(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
$.info(`正在删除组合订阅:${name}`);
|
||||
let allCol = $.read(COLLECTIONS_KEY);
|
||||
delete allCol[name];
|
||||
|
||||
@@ -17,7 +17,9 @@ export default function register($app) {
|
||||
|
||||
// subscriptions API
|
||||
async function downloadSubscription(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
|
||||
const { raw } = req.query || 'false';
|
||||
const platform =
|
||||
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
||||
@@ -80,24 +82,17 @@ function createSubscription(req, res) {
|
||||
message: `订阅${sub.name}已存在!`,
|
||||
});
|
||||
}
|
||||
// validate name
|
||||
if (/^[\w-_]*$/.test(sub.name)) {
|
||||
allSubs[sub.name] = sub;
|
||||
$.write(allSubs, SUBS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: sub,
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: `订阅名称 ${sub.name} 中含有非法字符!名称中只能包含英文字母、数字、下划线、横杠。`,
|
||||
});
|
||||
}
|
||||
allSubs[sub.name] = sub;
|
||||
$.write(allSubs, SUBS_KEY);
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: sub,
|
||||
});
|
||||
}
|
||||
|
||||
function getSubscription(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
const sub = $.read(SUBS_KEY)[name];
|
||||
if (sub) {
|
||||
res.json({
|
||||
@@ -113,7 +108,8 @@ function getSubscription(req, res) {
|
||||
}
|
||||
|
||||
function updateSubscription(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
let sub = req.body;
|
||||
const allSubs = $.read(SUBS_KEY);
|
||||
if (allSubs[name]) {
|
||||
@@ -152,7 +148,8 @@ function updateSubscription(req, res) {
|
||||
}
|
||||
|
||||
function deleteSubscription(req, res) {
|
||||
const { name } = req.params;
|
||||
let { name } = req.params;
|
||||
name = decodeURIComponent(name);
|
||||
$.info(`删除订阅:${name}...`);
|
||||
// delete from subscriptions
|
||||
let allSubs = $.read(SUBS_KEY);
|
||||
|
||||
Vendored
+2
-2
@@ -6,11 +6,11 @@
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @updated: 2022/5/26 上午11:17:01
|
||||
* @updated: 2022/5/30 下午1:47:20
|
||||
* @version: 1.6
|
||||
* @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 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 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(a)return o?-1:k(t).length;e=(""+e).toLowerCase(),a=!0}}function u(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(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:f(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):f(t,[e],n,o,a);throw new TypeError("val must be string, number or Buffer")}function f(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 p=-1;for(a=r;a<s;a++)if(u(t,a)===u(e,-1===p?0:a-p)){if(-1===p&&(p=a),a-p+1===c)return p*i}else-1!==p&&(a-=a-p),p=-1}else for(r+c>s&&(r=s-c),a=r;a>=0;a--){for(var f=!0,l=0;l<c;l++)if(u(t,a+l)!==u(e,l)){f=!1;break}if(f)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(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 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
|
||||
@@ -48,7 +48,7 @@ const router = new Router({
|
||||
name: "collection-edit",
|
||||
component: SubEditor,
|
||||
props: {isCollection: true},
|
||||
meta: {title: "订阅编辑"}
|
||||
meta: {title: "组合订阅编辑"}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
+10
-9
@@ -27,7 +27,6 @@
|
||||
<v-text-field
|
||||
v-model="currentArtifact.name"
|
||||
:disabled="editing"
|
||||
:rules="validations.nameRules"
|
||||
clear-icon="clear"
|
||||
clearable
|
||||
label="配置名称"
|
||||
@@ -155,7 +154,7 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-list dense>
|
||||
<v-list-item v-if="artifact.url" @click="copy(artifact.url)">
|
||||
<v-list-item v-if="artifact.url" @click="copy(artifact)">
|
||||
<v-list-item-title>复制</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item @click="editArtifact(artifact)">
|
||||
@@ -200,10 +199,6 @@ export default {
|
||||
editing: null,
|
||||
formValid: false,
|
||||
validations: {
|
||||
nameRules: [
|
||||
v => !!v || "订阅名称不能为空!",
|
||||
v => /^[\w-_.]*$/.test(v) || "订阅名称只能包含英文字符、横杠、点和下划线!"
|
||||
],
|
||||
required: [
|
||||
v => !!v || "不能为空!"
|
||||
]
|
||||
@@ -299,9 +294,11 @@ export default {
|
||||
this.editing = false;
|
||||
},
|
||||
|
||||
copy(url) {
|
||||
this.$clipboard(url);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制配置链接");
|
||||
copy(artifact) {
|
||||
if (artifact.url) {
|
||||
this.$clipboard(artifact.url + (isPlainName(artifact.name) ? '' : `#${artifact.name}`));
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制配置链接");
|
||||
}
|
||||
},
|
||||
|
||||
preview(name) {
|
||||
@@ -360,6 +357,10 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isPlainName(name) {
|
||||
return /^[\w-_]*$/.test(name);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<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
|
||||
<v-text-field v-model="options.name" class="mt-2" clear-icon="clear" clearable
|
||||
label="订阅名称" placeholder="填入订阅名称,名称需唯一" required />
|
||||
<!--For Subscription-->
|
||||
<v-radio-group v-if="!isCollection" v-model="options.source" class="mt-0 mb-0">
|
||||
@@ -20,7 +20,7 @@
|
||||
<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
|
||||
<v-textarea v-if="!isCollection && 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">
|
||||
@@ -300,10 +300,6 @@ export default {
|
||||
imported: "",
|
||||
dialog: false,
|
||||
validations: {
|
||||
nameRules: [
|
||||
v => !!v || "订阅名称不能为空!",
|
||||
v => /^[\w-_]*$/.test(v) || "订阅名称只能包含英文字符、横杠和下划线!"
|
||||
],
|
||||
urlRules: [
|
||||
v => this.options.source === 'remote' && (!!v || "订阅链接不能为空!"),
|
||||
v => this.options.source === 'remote' && (/^https?:\/\//.test(v) || "订阅链接不合法!")
|
||||
@@ -335,7 +331,7 @@ export default {
|
||||
},
|
||||
|
||||
created() {
|
||||
const name = this.$route.params.name;
|
||||
const name = decodeURIComponent(this.$route.params.name);
|
||||
let source;
|
||||
if (this.isCollection) {
|
||||
source = (typeof name === 'undefined' || name === 'UNTITLED') ? {} : this.$store.state.collections[name];
|
||||
|
||||
@@ -195,19 +195,7 @@ export default {
|
||||
{
|
||||
title: "删除",
|
||||
action: "DELETE"
|
||||
},
|
||||
// {
|
||||
// title: "副本",
|
||||
// action: "DUPLICATE"
|
||||
// }
|
||||
// {
|
||||
// title: "上移",
|
||||
// action: "MOVE_UP"
|
||||
// },
|
||||
// {
|
||||
// title: "下移",
|
||||
// action: "MOVE_DOWN"
|
||||
// }
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -236,27 +224,22 @@ export default {
|
||||
console.log(`${action} --> ${sub.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/${sub.name}`);
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/${encodeURIComponent(sub.name)}${isPlainName(sub.name) ? '' : '#' + sub.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
this.$router.push(`/sub-edit/${sub.name}`);
|
||||
this.$router.push(`/sub-edit/${encodeURIComponent(sub.name)}`);
|
||||
break
|
||||
case 'DELETE':
|
||||
this.$store.dispatch("DELETE_SUBSCRIPTION", sub.name);
|
||||
break
|
||||
case 'MOVE_UP':
|
||||
this.moveUpSubscription(sub.name);
|
||||
break
|
||||
case 'MOVE_DOWN':
|
||||
break
|
||||
}
|
||||
},
|
||||
collectionMenu(action, collection) {
|
||||
console.log(`${action} --> ${collection.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/collection/${collection.name}`);
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/collection/${encodeURIComponent(collection.name)}${isPlainName(collection.name) ? '' : '#' + collection.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
@@ -269,10 +252,10 @@ export default {
|
||||
},
|
||||
preview(item, type = 'sub') {
|
||||
if (type === 'sub') {
|
||||
this.url = `${BACKEND_BASE}/download/${item.name}`;
|
||||
this.url = `${BACKEND_BASE}/download/${encodeURIComponent(item.name)}`;
|
||||
this.sub = item.url;
|
||||
} else {
|
||||
this.url = `${BACKEND_BASE}/download/collection/${item.name}`
|
||||
this.url = `${BACKEND_BASE}/download/collection/${encodeURIComponent(item.name)}`
|
||||
}
|
||||
this.showProxyList = true;
|
||||
},
|
||||
@@ -295,6 +278,10 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isPlainName(name) {
|
||||
return /^[\w-_]*$/.test(name);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in new issue
Block a user