mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 14:44:42 -05:00
update: 补全短链解析配置
This commit is contained in:
parent
1c5e17a4ab
commit
3d058066b9
@ -47,7 +47,6 @@
|
|||||||
<label for="apiLink">解析链接:</label>
|
<label for="apiLink">解析链接:</label>
|
||||||
<div class="input-group mb-2">
|
<div class="input-group mb-2">
|
||||||
<input class="form-control" id="urlInput" type="text" placeholder="通过生成的链接重新填写下方设置" />
|
<input class="form-control" id="urlInput" type="text" placeholder="通过生成的链接重新填写下方设置" />
|
||||||
<input class="form-control" id="urlshortLinkPasswdInput" type="text" placeholder="短链密码" />
|
|
||||||
<button class="btn btn-primary" onclick="parseInputURL()" type="button">
|
<button class="btn btn-primary" onclick="parseInputURL()" type="button">
|
||||||
解析
|
解析
|
||||||
</button>
|
</button>
|
||||||
|
@ -157,10 +157,8 @@ function generateURI() {
|
|||||||
async function parseInputURL() {
|
async function parseInputURL() {
|
||||||
// 获取输入框中的 URL
|
// 获取输入框中的 URL
|
||||||
const inputURL = document.getElementById("urlInput").value;
|
const inputURL = document.getElementById("urlInput").value;
|
||||||
const urlshortLinkPasswdInput = document.getElementById(
|
// 清除现有的输入框值
|
||||||
"urlshortLinkPasswdInput"
|
clearExistingValues();
|
||||||
).value;
|
|
||||||
|
|
||||||
if (!inputURL) {
|
if (!inputURL) {
|
||||||
alert("请输入有效的链接!");
|
alert("请输入有效的链接!");
|
||||||
return;
|
return;
|
||||||
@ -176,19 +174,20 @@ async function parseInputURL() {
|
|||||||
if (url.pathname.includes("/s/")) {
|
if (url.pathname.includes("/s/")) {
|
||||||
let hash = url.pathname.substring(url.pathname.lastIndexOf("/s/") + 3);
|
let hash = url.pathname.substring(url.pathname.lastIndexOf("/s/") + 3);
|
||||||
let q = new URLSearchParams();
|
let q = new URLSearchParams();
|
||||||
|
let password = url.searchParams.get("password");
|
||||||
q.append("hash", hash);
|
q.append("hash", hash);
|
||||||
q.append("password", urlshortLinkPasswdInput);
|
q.append("password", password);
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("./short?" + q.toString());
|
const response = await axios.get("./short?" + q.toString());
|
||||||
url = new URL(window.location.href + response.data);
|
url = new URL(window.location.href + response.data);
|
||||||
|
document.querySelector("#apiShortLink").value = inputURL;
|
||||||
|
document.querySelector("#password").value = password;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
alert("获取短链失败,请检查密码!");
|
alert("获取短链失败,请检查密码!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let params = new URLSearchParams(url.search);
|
let params = new URLSearchParams(url.search);
|
||||||
// 清除现有的输入框值
|
|
||||||
clearExistingValues();
|
|
||||||
|
|
||||||
// 分配值到对应的输入框
|
// 分配值到对应的输入框
|
||||||
const pathSections = url.pathname.split("/");
|
const pathSections = url.pathname.split("/");
|
||||||
|
Loading…
Reference in New Issue
Block a user