♻️ refactor: Refactor API endpoints to use dynamic API prefix from environment variables

- Updated all service files to replace hardcoded API paths with `${import.meta.env.VITE_API_PREFIX}` for better configurability.
- Ensured consistency across user, common, and gateway services by applying the new API prefix format.
- Removed unnecessary comments and maintained ESLint disable directives where applicable.
This commit is contained in:
web@ppanel
2025-12-11 03:58:26 +00:00
parent 99e7f6062d
commit ae5e95477c
45 changed files with 676 additions and 551 deletions
+20 -16
View File
@@ -1,4 +1,3 @@
//
/* eslint-disable */
import request from "@workspace/ui/lib/request";
@@ -10,7 +9,7 @@ export async function getBatchSendEmailTaskList(
) {
return request<
API.Response & { data?: API.GetBatchSendEmailTaskListResponse }
>("/api/v1/admin/marketing/email/batch/list", {
>(`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/email/batch/list`, {
method: "GET",
params: {
...params,
@@ -25,7 +24,9 @@ export async function getPreSendEmailCount(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.GetPreSendEmailCountResponse }>(
"/api/v1/admin/marketing/email/batch/pre-send-count",
`${
import.meta.env.VITE_API_PREFIX
}/v1/admin/marketing/email/batch/pre-send-count`,
{
method: "POST",
headers: {
@@ -43,7 +44,7 @@ export async function createBatchSendEmailTask(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
"/api/v1/admin/marketing/email/batch/send",
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/email/batch/send`,
{
method: "POST",
headers: {
@@ -62,14 +63,17 @@ export async function getBatchSendEmailTaskStatus(
) {
return request<
API.Response & { data?: API.GetBatchSendEmailTaskStatusResponse }
>("/api/v1/admin/marketing/email/batch/status", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
});
>(
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/email/batch/status`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/** Stop a batch send email task POST /v1/admin/marketing/email/batch/stop */
@@ -78,7 +82,7 @@ export async function stopBatchSendEmailTask(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
"/api/v1/admin/marketing/email/batch/stop",
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/email/batch/stop`,
{
method: "POST",
headers: {
@@ -96,7 +100,7 @@ export async function createQuotaTask(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
"/api/v1/admin/marketing/quota/create",
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/quota/create`,
{
method: "POST",
headers: {
@@ -115,7 +119,7 @@ export async function queryQuotaTaskList(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.QueryQuotaTaskListResponse }>(
"/api/v1/admin/marketing/quota/list",
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/quota/list`,
{
method: "GET",
params: {
@@ -132,7 +136,7 @@ export async function queryQuotaTaskPreCount(
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.QueryQuotaTaskPreCountResponse }>(
"/api/v1/admin/marketing/quota/pre-count",
`${import.meta.env.VITE_API_PREFIX}/v1/admin/marketing/quota/pre-count`,
{
method: "POST",
headers: {