fix: normalize overseas PDA API paths
This commit is contained in:
+11
-10
@@ -40,10 +40,19 @@ async function tokenAfterUnauthorized(failedToken) {
|
||||
return refreshOverseasToken()
|
||||
}
|
||||
|
||||
function overseasUrl(path) {
|
||||
const base = String(session.apiBase || '').replace(/\/$/, '')
|
||||
const value = `/${String(path || '').replace(/^\/+/, '')}`
|
||||
const normalized = /\/(?:api|overseas-api)$/.test(base)
|
||||
? value.replace(/^\/api(?=\/)/, '')
|
||||
: value
|
||||
return `${base}${normalized}`
|
||||
}
|
||||
|
||||
function rawRequest(method, path, data, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${session.apiBase}${path}`,
|
||||
url: overseasUrl(path),
|
||||
method,
|
||||
data,
|
||||
header: { Accept: 'application/json', Authorization: `Bearer ${token}` },
|
||||
@@ -72,7 +81,7 @@ export async function overseasRequest(method, path, data, retry = true) {
|
||||
function rawUpload(path, filePath, name, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: `${session.apiBase}${path}`,
|
||||
url: overseasUrl(path),
|
||||
filePath,
|
||||
name,
|
||||
header: { Authorization: `Bearer ${token}` },
|
||||
@@ -82,14 +91,6 @@ function rawUpload(path, filePath, name, token) {
|
||||
})
|
||||
}
|
||||
|
||||
function overseasUrl(path) {
|
||||
const value = String(path || '')
|
||||
const normalized = /\/(?:api|overseas-api)$/.test(session.apiBase)
|
||||
? value.replace(/^\/api(?=\/)/, '')
|
||||
: value
|
||||
return `${session.apiBase}${normalized}`
|
||||
}
|
||||
|
||||
function rawDownload(path, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.downloadFile({
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { overseasRequest } from './overseas.js'
|
||||
|
||||
const BASE = '/api/pda/v1/last-leg/pallet-operations'
|
||||
const BASE = '/pda/v1/last-leg/pallet-operations'
|
||||
|
||||
export function resolvePallet(code) {
|
||||
return overseasRequest('POST', `${BASE}/pallets/resolve`, { code: String(code || '').trim() })
|
||||
|
||||
Reference in New Issue
Block a user