feat 适配pid可能已经被编码的情况
All checks were successful
Build image / build (push) Successful in 32s

This commit is contained in:
timerzz 2024-12-03 12:39:45 +08:00
parent 3a09aaa751
commit 4f87bcecf8
5 changed files with 19 additions and 10 deletions

6
src/api/encode.js Normal file
View File

@ -0,0 +1,6 @@
export const encodeURL = (url)=>{
if (url.indexOf('%') !== -1) {
return url
}
return encodeURIComponent(url)
}

View File

@ -13,5 +13,5 @@ export const UpdateProduct=(p)=>{
} }
export const GetProduct = (pid) => { export const GetProduct = (pid) => {
return product.get(`p/${encodeURIComponent(pid)}`) return product.get(`p/${encodeURL(pid)}`)
} }

View File

@ -1,5 +1,6 @@
import {mande} from "mande"; import {mande} from "mande";
import {queryRemoveZero} from "@/api/utils.js"; import {queryRemoveZero} from "@/api/utils.js";
import {encodeURL} from "@/api/encode.js";
const providers = mande('/api/v2/providers') const providers = mande('/api/v2/providers')
@ -47,13 +48,13 @@ export const FetchProviderArticlePrice = (providerArticle)=>{
} }
export const FetchProviderArticleAts = (providerArticle)=>{ export const FetchProviderArticleAts = (providerArticle)=>{
return provider.post(`/${providerArticle.providerId}/ats/fetch/${encodeURIComponent(providerArticle.skuID)}`) return provider.post(`/${providerArticle.providerId}/ats/fetch/${encodeURL(providerArticle.skuID)}`)
} }
export const GetProviderArticleAts = (providerId, pid)=>{ export const GetProviderArticleAts = (providerId, pid)=>{
return provider.get(`/${providerId}/ats/${encodeURIComponent(pid)}`) return provider.get(`/${providerId}/ats/${encodeURL(pid)}`)
} }
export const FetchProviderArticleDetail = (providerId, pid)=>{ export const FetchProviderArticleDetail = (providerId, pid)=>{
return provider.post(`/${providerId}/detail/fetch/${encodeURIComponent(pid)}`) return provider.post(`/${providerId}/detail/fetch/${encodeURL(pid)}`)
} }

View File

@ -1,6 +1,7 @@
import {mande} from "mande"; import {mande} from "mande";
import {provider} from "@/api/provider.js"; import {provider} from "@/api/provider.js";
import {queryRemoveZero} from "@/api/utils.js"; import {queryRemoveZero} from "@/api/utils.js";
import {encodeURL} from "@/api/encode.js";
const tracers = mande('/api/v2/tracers') const tracers = mande('/api/v2/tracers')
@ -10,13 +11,13 @@ export const ListTracers = (q) => {
} }
export const CreateTracer = (providerId, skuID)=>{ export const CreateTracer = (providerId, skuID)=>{
return provider.post(`${providerId}/ats-trace/${encodeURIComponent(skuID)}`) return provider.post(`${providerId}/ats-trace/${encodeURL(skuID)}`)
} }
export const DeleteTracer = (providerId, skuID)=>{ export const DeleteTracer = (providerId, skuID)=>{
return provider.delete(`${providerId}/ats-trace/${encodeURIComponent(skuID)}`) return provider.delete(`${providerId}/ats-trace/${encodeURL(skuID)}`)
} }
export const StopTracer = (providerId,skuID)=>{ export const StopTracer = (providerId,skuID)=>{
return provider.post(`${providerId}/ats-trace/stop/${encodeURIComponent(skuID)}`) return provider.post(`${providerId}/ats-trace/stop/${encodeURL(skuID)}`)
} }

View File

@ -1,6 +1,7 @@
import {mande} from "mande"; import {mande} from "mande";
import {provider} from "@/api/provider.js"; import {provider} from "@/api/provider.js";
import {queryRemoveZero} from "@/api/utils.js"; import {queryRemoveZero} from "@/api/utils.js";
import {encodeURL} from "@/api/encode.js";
const watchers = mande('/api/v2/watchers') const watchers = mande('/api/v2/watchers')
@ -10,13 +11,13 @@ export const ListWatchers = (q) => {
} }
export const CreateWatcher = (providerId, skuID)=>{ export const CreateWatcher = (providerId, skuID)=>{
return provider.post(`${providerId}/watch/${encodeURIComponent(skuID)}`) return provider.post(`${providerId}/watch/${encodeURL(skuID)}`)
} }
export const DeleteWatcher = (providerId, skuID)=>{ export const DeleteWatcher = (providerId, skuID)=>{
return provider.delete(`${providerId}/watch/${encodeURIComponent(skuID)}`) return provider.delete(`${providerId}/watch/${encodeURL(skuID)}`)
} }
export const StopWatcher = (providerId,skuID)=>{ export const StopWatcher = (providerId,skuID)=>{
return provider.post(`${providerId}/watch/stop/${encodeURIComponent(skuID)}`) return provider.post(`${providerId}/watch/stop/${encodeURL(skuID)}`)
} }