功能:完善 YumiNail 全栈修复与打包

This commit is contained in:
xiaowang
2026-05-15 21:10:41 +08:00
parent 3d0a859980
commit 1f05e0ab44
42 changed files with 768 additions and 316 deletions
+38 -3
View File
@@ -26,6 +26,39 @@ function buildRequestUrl(url, params) {
return query ? `${target}${target.includes('?') ? '&' : '?'}${query}` : target
}
function extractPath(value) {
const target = String(value || '')
if (!target) {
return ''
}
if (/^[a-z][a-z\d+\-.]*:\/\//i.test(target)) {
try {
return new URL(target).pathname
} catch (error) {}
}
return target.split('?')[0] || ''
}
function toBackendRequestPath(url) {
const path = extractPath(url).replace(/\/+$/, '') || '/'
if (path === '/admin/api') {
return '/admin'
}
if (path.startsWith('/admin/api/')) {
return `/admin/${path.slice('/admin/api/'.length)}`
}
if (path === '/api/admin') {
return '/admin'
}
if (path.startsWith('/api/admin/')) {
return `/admin/${path.slice('/api/admin/'.length)}`
}
if (path === '/admin' || path.startsWith('/admin/')) {
return path
}
return path.startsWith('/') ? `/admin${path}` : `/admin/${path}`
}
function isAuthFreePath(url) {
return [
'/auth/login',
@@ -124,15 +157,17 @@ function buildSignatureHeaders(options) {
return headers
}
const formData = options.formData
const hasFormData = formData && Object.keys(formData).length > 0
const contentType = String((options.header && options.header['Content-Type']) || options.contentType || 'application/json').toLowerCase()
const payload = contentType.includes('application/json')
const payload = contentType.includes('application/json') && !hasFormData
? buildJsonPayload(options.data)
: buildCanonicalParams(options.formData || options.data || options.params)
: buildCanonicalParams(formData || options.data || options.params)
const timestamp = String(Date.now())
const nonce = randomNonce()
const canonical = [
method,
options.url,
toBackendRequestPath(options.url),
timestamp,
nonce,
sha256Hex(payload)