support multi urls in text area

This commit is contained in:
Stille 2022-07-11 13:16:52 +08:00
parent 5bb2743cb8
commit 3d5054182b
2 changed files with 23 additions and 55 deletions

View File

@ -2,29 +2,14 @@
<div class="box"> <div class="box">
<form method="post" action="#"> <form method="post" action="#">
<div class="row gtr-uniform gtr-50"> <div class="row gtr-uniform gtr-50">
<span v-for="(item, index) in inputs" :key="item" class="col-12 row"> <div class="col-12">
<div <textarea
class="col-10 col-10-mobilep" id="message"
style="text-align: center; padding-top: 10px" v-model.trim="inputs.inputValue"
> :placeholder="inputs.placeholder"
<input rows="3"
type="text" ></textarea>
v-model.trim="item.inputValue" </div>
:placeholder="item.placeholder"
/>
</div>
<div
class="col-2 col-2-mobilep"
style="text-align: center; padding-top: 10px"
>
<input
type="button"
:value="item.buttonValue"
:class="item.buttonClass"
@click="addLinks(index)"
/>
</div>
</span>
<div <div
class="col-4 col-4-mobilep list" class="col-4 col-4-mobilep list"
style="text-align: center; padding-top: 20px" style="text-align: center; padding-top: 20px"
@ -178,14 +163,12 @@ export default {
{ value: 'default', text: process.env.VUE_APP_BASE_API_URL }, { value: 'default', text: process.env.VUE_APP_BASE_API_URL },
{ value: 'manual', text: '自定义后端 API 地址' }, { value: 'manual', text: '自定义后端 API 地址' },
], ],
inputs: [ inputs: {
{ buttonClass: '',
buttonClass: '', inputValue: '',
buttonValue: '添加', placeholder:
inputValue: '', '多订阅链接或节点请确保每行一条\n支持手动使用"|"分割多链接或节点',
placeholder: '订阅地址', },
},
],
targetType: 'clash', targetType: 'clash',
targetTypes: [ targetTypes: [
{ value: 'clash', text: 'Clash' }, { value: 'clash', text: 'Clash' },
@ -221,17 +204,6 @@ export default {
resetDialog() { resetDialog() {
this.dialogVisible = false; this.dialogVisible = false;
}, },
addLinks(index) {
if (index == 0) {
this.inputs.push({
buttonClass: 'alt',
buttonValue: '移除',
placeholder: '订阅地址',
});
} else {
this.inputs.splice(index, 1);
}
},
selectApi(event) { selectApi(event) {
if (event.target.value == 'manual') { if (event.target.value == 'manual') {
this.isManualApi = false; this.isManualApi = false;
@ -243,18 +215,13 @@ export default {
this.targetType = event.target.value; this.targetType = event.target.value;
}, },
checkUrls() { checkUrls() {
this.urls = []; if (this.inputs.inputValue == '') {
for (const i in this.inputs) { this.dialogMessage = '请填写正确的订阅地址';
if (utils.regexCheck(this.inputs[i].inputValue)) { this.dialogVisible = true;
this.urls.push(this.inputs[i].inputValue); return false;
if (Number(i) + 1 == this.inputs.length) { } else {
return true; this.urls = this.inputs.inputValue;
} return true;
} else {
this.dialogMessage = '请填写正确的订阅地址';
this.dialogVisible = true;
return false;
}
} }
}, },
checkApi() { checkApi() {

View File

@ -5,7 +5,8 @@ const getSubLink = function (
isShowMoreConfig, isShowMoreConfig,
moreConfig moreConfig
) { ) {
let link = links.join('|'); let linkLst = links.split('\n');
let link = linkLst.join('|');
let finalUrl = let finalUrl =
apiUrl + '/sub?target=' + targetType + '&url=' + encodeURIComponent(link); apiUrl + '/sub?target=' + targetType + '&url=' + encodeURIComponent(link);
if (isShowMoreConfig) { if (isShowMoreConfig) {