diff --git a/src/views/home/HomeForm.vue b/src/views/home/HomeForm.vue
index d6edcb7..c76084a 100644
--- a/src/views/home/HomeForm.vue
+++ b/src/views/home/HomeForm.vue
@@ -11,7 +11,7 @@
>
+
@@ -50,7 +65,7 @@
class="col-12"
style="text-align: center; padding-top: 0px"
>
-
+
-
-
+
@@ -192,7 +190,7 @@ export default {
apiUrl: window.config.apiUrl,
shortUrl: window.config.shortUrl,
manualApiUrl: '',
- isManualApi: true,
+ isShowManualApiUrl: false,
api: 'default',
apis: [
{ value: 'default', text: window.config.apiUrl },
@@ -236,23 +234,45 @@ export default {
this.isShowMoreConfig = true;
}
},
+ showDialog(msg) {
+ this.dialogMessage = msg;
+ this.dialogVisible = true;
+ },
resetDialog() {
this.dialogVisible = false;
},
selectApi(event) {
if (event.target.value == 'manual') {
- this.isManualApi = false;
+ this.isShowManualApiUrl = true;
} else {
- this.isManualApi = true;
+ this.isShowManualApiUrl = false;
}
},
selectTarget(event) {
this.targetType = event.target.value;
},
+ toCopy(url, title) {
+ if (!url) {
+ this.showDialog('复制失败 内容为空');
+ } else {
+ var copyInput = document.createElement('input');
+ copyInput.setAttribute('value', url);
+ document.body.appendChild(copyInput);
+ copyInput.select();
+ try {
+ var copyed = document.execCommand('copy');
+ if (copyed) {
+ document.body.removeChild(copyInput);
+ this.showDialog(title + ' 复制成功');
+ }
+ } catch {
+ this.showDialog('复制失败 请检查浏览器兼容');
+ }
+ }
+ },
checkUrls() {
if (this.inputs.inputValue == '') {
- this.dialogMessage = '请填写正确的订阅地址';
- this.dialogVisible = true;
+ this.showDialog('请填写正确的订阅地址');
return false;
} else {
this.urls = this.inputs.inputValue;
@@ -265,8 +285,7 @@ export default {
if (apiSelect.options[i].value == 'manual') {
this.apiUrl = this.manualApiUrl;
if (!utils.regexCheck(this.apiUrl)) {
- this.dialogMessage = '请填写正确的 API 地址';
- this.dialogVisible = true;
+ this.showDialog('请填写正确的 API 地址');
return false;
} else if (this.apiUrl.split('').slice(-1) == '/') {
this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1);
@@ -293,54 +312,35 @@ export default {
this.getFinalUrl();
}
},
- toCopy(url, title) {
- if (!url) {
- this.dialogMessage = '内容为空,请先订阅转换.';
- this.dialogVisible = true;
- } else {
- var copyInput = document.createElement('input');
- copyInput.setAttribute('value', url);
- document.body.appendChild(copyInput);
- copyInput.select();
- try {
- var copyed = document.execCommand('copy');
- if (copyed) {
- document.body.removeChild(copyInput);
- this.dialogMessage = title + '复制成功';
- this.dialogVisible = true;
- }
- } catch {
- this.dialogMessage = '复制失败,请检查浏览器兼容.';
- this.dialogVisible = true;
- }
+ getSubUrl() {
+ this.checkAll();
+ if (!this.returnUrl == '') {
+ this.toCopy(this.returnUrl, '订阅链接');
}
},
getShortUrl() {
if (this.returnUrl == '') {
- this.dialogMessage = '内容为空,请先订阅转换.';
- this.dialogVisible = true;
- } else {
- let data = new FormData();
- data.append('longUrl', btoa(this.returnUrl));
- request({
- method: 'post',
- url: this.shortUrl + '/short',
- header: {
- 'Content-Type': 'application/form-data; charset=utf-8',
- },
- data: data,
- })
- .then((res) => {
- if (res.data.Code === 1 && res.data.ShortUrl !== '') {
- this.returnShortUrl = res.data.ShortUrl;
- this.toCopy(res.data.ShortUrl, '短链接');
- }
- })
- .catch(() => {
- this.dialogMessage = '短链接生成失败';
- this.dialogVisible = true;
- });
+ this.checkAll();
}
+ let data = new FormData();
+ data.append('longUrl', btoa(this.returnUrl));
+ request({
+ method: 'post',
+ url: this.shortUrl + '/short',
+ header: {
+ 'Content-Type': 'application/form-data; charset=utf-8',
+ },
+ data: data,
+ })
+ .then((res) => {
+ if (res.data.Code === 1 && res.data.ShortUrl !== '') {
+ this.returnShortUrl = res.data.ShortUrl;
+ this.toCopy(res.data.ShortUrl, '短链接');
+ }
+ })
+ .catch(() => {
+ this.showDialog('短链接生成失败 请检查短链接服务是否可用');
+ });
},
},
};