fix: unable to delete subscription with trailing spaces #build

This commit is contained in:
Peng-YM 2022-06-21 17:02:27 +08:00
parent 89164c3e7a
commit 50a3eb5592
3 changed files with 18 additions and 14 deletions

View File

@ -56,16 +56,28 @@ const types = [
value: "ssr" value: "ssr"
}, },
{ {
name: "V2Ray", name: "VMess",
value: "vmess" value: "vmess"
}, },
{
name: "VLess",
value: "vless"
},
{ {
name: "Trojan", name: "Trojan",
value: "trojan" value: "trojan"
}, },
{ {
name: "HTTP", name: "HTTP(s)",
value: "http" value: "http"
},
{
name: "Socks5",
value: "socks5"
},
{
name: "Snell",
value: "snell"
} }
]; ];
export default { export default {

View File

@ -296,7 +296,7 @@ export default {
copy(artifact) { copy(artifact) {
if (artifact.url) { if (artifact.url) {
this.$clipboard(artifact.url + (isPlainName(artifact.name) ? '' : `#${artifact.name}`)); this.$clipboard(artifact.url);
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制配置链接"); this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制配置链接");
} }
}, },
@ -357,10 +357,6 @@ export default {
} }
} }
} }
function isPlainName(name) {
return /^[0-9a-zA-Z-_]*$/.test(name);
}
</script> </script>
<style scoped> <style scoped>

View File

@ -224,14 +224,14 @@ export default {
console.log(`${action} --> ${sub.name}`); console.log(`${action} --> ${sub.name}`);
switch (action) { switch (action) {
case 'COPY': case 'COPY':
this.$clipboard(`${this.subscriptionBaseURL}/download/${encodeURIComponent(sub.name)}${isPlainName(sub.name) ? '' : '#' + sub.name}`); this.$clipboard(`${this.subscriptionBaseURL}/download/${encodeURIComponent(sub.name)}`);
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接"); this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
break break
case 'EDIT': case 'EDIT':
this.$router.push(`/sub-edit/${encodeURIComponent(sub.name)}`); this.$router.push(`/sub-edit/${encodeURIComponent(sub.name)}`);
break break
case 'DELETE': case 'DELETE':
this.$store.dispatch("DELETE_SUBSCRIPTION", sub.name); this.$store.dispatch("DELETE_SUBSCRIPTION", encodeURIComponent(sub.name));
break break
} }
}, },
@ -239,7 +239,7 @@ export default {
console.log(`${action} --> ${collection.name}`); console.log(`${action} --> ${collection.name}`);
switch (action) { switch (action) {
case 'COPY': case 'COPY':
this.$clipboard(`${this.subscriptionBaseURL}/download/collection/${encodeURIComponent(collection.name)}${isPlainName(collection.name) ? '' : '#' + collection.name}`); this.$clipboard(`${this.subscriptionBaseURL}/download/collection/${encodeURIComponent(collection.name)}`);
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接"); this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
break break
case 'EDIT': case 'EDIT':
@ -278,10 +278,6 @@ export default {
} }
} }
} }
function isPlainName(name) {
return /^[0-9a-zA-Z-_]*$/.test(name);
}
</script> </script>
<style scoped> <style scoped>