Commit 964e596f authored by “yiyousong”'s avatar “yiyousong”

perf: 优化

parent 833601d9
......@@ -185,18 +185,18 @@ export default {
if (this.userData.admin || this.userData.id == 1) {
event.preventDefault();
let redirectUrl = "";
let hash = "";
let redirect = await this.getFinalRedirect(modelUrl);
if (!modelUrl.includes("http")) {
let index = modelUrl.indexOf("/");
hash = modelUrl.slice(index + 1);
}
if (redirect) {
redirectUrl = redirect + hash;
} else {
redirectUrl = modelUrl;
}
// let redirectUrl = "";
// let hash = "";
// let redirect = await this.getFinalRedirect(modelUrl);
// if (!modelUrl.includes("http")) {
// let index = modelUrl.indexOf("/");
// hash = modelUrl.slice(index + 1);
// }
// if (redirect) {
// redirectUrl = redirect + hash;
// } else {
// redirectUrl = modelUrl;
// }
this.$notification.open({
message: "跳转链接",
......@@ -205,7 +205,7 @@ export default {
description: (
<div>
<div class="notif-name">{modelName}-完整链接:</div>
<div>{redirectUrl + params}</div>
<div>{modelUrl + params}</div>
<div class="notif-name">链接参数:</div>
<div>{params}</div>
</div>
......@@ -275,19 +275,19 @@ export default {
},
// 获取重定向地址
getFinalRedirect(url) {
return fetch(url, { method: "GET", redirect: "follow" })
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.url;
})
.catch((error) => {
console.error("Error:", error);
return null;
});
},
// getFinalRedirect(url) {
// return fetch(url, { method: "GET", redirect: "follow" })
// .then((response) => {
// if (!response.ok) {
// throw new Error("Network response was not ok");
// }
// return response.url;
// })
// .catch((error) => {
// console.error("Error:", error);
// return null;
// });
// },
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment