修改获取的请求地址

v1.4.0
于肖磊 2025-08-08 18:39:16 +08:00
parent 46d65c4ca5
commit 381abcea60
1 changed files with 10 additions and 6 deletions

View File

@ -19,16 +19,18 @@ export const font_weight = [
// 截取document.location.search字符串内id/后面的所有字段
export const get_id = () => {
let new_id = '';
if (document.location.search.indexOf('id/') != -1) {
new_id = document.location.search.substring(document.location.search.indexOf('id/') + 3);
// 去除origin的数据
const url = document.location.href.replace(document.location.origin, '');
if (url.indexOf('id/') != -1) {
new_id = url.substring(url.indexOf('id/') + 3);
// 去除字符串的.html
let html_index = new_id.indexOf('.html');
if (html_index != -1) {
new_id = new_id.substring(0, html_index);
}
return new_id;
} else if (document.location.search.indexOf('shop-diy-saveinfo') != -1) {
new_id = document.location.search.substring(document.location.search.indexOf('shop-diy-saveinfo-') + 18);
} else if (url.indexOf('shop-diy-saveinfo') != -1) {
new_id = url.substring(url.indexOf('shop-diy-saveinfo-') + 18);
// 去除字符串的.html
const dot_data = new_id.split('.')[0];
if (dot_data != '') {
@ -42,8 +44,10 @@ export const get_id = () => {
export const get_type = () => {
let new_type = '';
if (document.location.search.indexOf('type/') != -1) {
new_type = document.location.search.substring(document.location.search.indexOf('type/') + 5);
// 去除origin的数据
const url = document.location.href.replace(document.location.origin, '');
if (url.indexOf('type/') != -1) {
new_type = url.substring(url.indexOf('type/') + 5);
// 去除字符串的.html
// 去除字符串的.html
const dot_data = new_type.split('.')[0];