From 4f87bcecf86bfa3df4e03a1d1c0d951833be9200 Mon Sep 17 00:00:00 2001 From: timerzz Date: Tue, 3 Dec 2024 12:39:45 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E9=80=82=E9=85=8Dpid=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E8=A2=AB=E7=BC=96=E7=A0=81=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/encode.js | 6 ++++++ src/api/product.js | 2 +- src/api/provider.js | 7 ++++--- src/api/tracer.js | 7 ++++--- src/api/watcher.js | 7 ++++--- 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/api/encode.js diff --git a/src/api/encode.js b/src/api/encode.js new file mode 100644 index 0000000..5b63eb9 --- /dev/null +++ b/src/api/encode.js @@ -0,0 +1,6 @@ +export const encodeURL = (url)=>{ + if (url.indexOf('%') !== -1) { + return url + } + return encodeURIComponent(url) +} \ No newline at end of file diff --git a/src/api/product.js b/src/api/product.js index 5552c2d..318a13b 100644 --- a/src/api/product.js +++ b/src/api/product.js @@ -13,5 +13,5 @@ export const UpdateProduct=(p)=>{ } export const GetProduct = (pid) => { - return product.get(`p/${encodeURIComponent(pid)}`) + return product.get(`p/${encodeURL(pid)}`) } \ No newline at end of file diff --git a/src/api/provider.js b/src/api/provider.js index b4e8725..f365e9e 100644 --- a/src/api/provider.js +++ b/src/api/provider.js @@ -1,5 +1,6 @@ import {mande} from "mande"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const providers = mande('/api/v2/providers') @@ -47,13 +48,13 @@ export const FetchProviderArticlePrice = (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)=>{ - return provider.get(`/${providerId}/ats/${encodeURIComponent(pid)}`) + return provider.get(`/${providerId}/ats/${encodeURL(pid)}`) } export const FetchProviderArticleDetail = (providerId, pid)=>{ - return provider.post(`/${providerId}/detail/fetch/${encodeURIComponent(pid)}`) + return provider.post(`/${providerId}/detail/fetch/${encodeURL(pid)}`) } \ No newline at end of file diff --git a/src/api/tracer.js b/src/api/tracer.js index aca9b0e..a7ef47e 100644 --- a/src/api/tracer.js +++ b/src/api/tracer.js @@ -1,6 +1,7 @@ import {mande} from "mande"; import {provider} from "@/api/provider.js"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const tracers = mande('/api/v2/tracers') @@ -10,13 +11,13 @@ export const ListTracers = (q) => { } 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)=>{ - return provider.delete(`${providerId}/ats-trace/${encodeURIComponent(skuID)}`) + return provider.delete(`${providerId}/ats-trace/${encodeURL(skuID)}`) } export const StopTracer = (providerId,skuID)=>{ - return provider.post(`${providerId}/ats-trace/stop/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/ats-trace/stop/${encodeURL(skuID)}`) } \ No newline at end of file diff --git a/src/api/watcher.js b/src/api/watcher.js index bcef5d8..5c33d7e 100644 --- a/src/api/watcher.js +++ b/src/api/watcher.js @@ -1,6 +1,7 @@ import {mande} from "mande"; import {provider} from "@/api/provider.js"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const watchers = mande('/api/v2/watchers') @@ -10,13 +11,13 @@ export const ListWatchers = (q) => { } export const CreateWatcher = (providerId, skuID)=>{ - return provider.post(`${providerId}/watch/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/watch/${encodeURL(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)=>{ - return provider.post(`${providerId}/watch/stop/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/watch/stop/${encodeURL(skuID)}`) } \ No newline at end of file