🐛 Fix payload case issue

This commit is contained in:
LittleSheep 2025-01-11 15:36:17 +08:00
parent bf43234eae
commit 7e0dff9f0f
5 changed files with 28 additions and 15 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -38,7 +38,7 @@
"remark-parse": "^11.0.0", "remark-parse": "^11.0.0",
"remark-rehype": "^11.1.1", "remark-rehype": "^11.1.1",
"sitemap": "^8.0.0", "sitemap": "^8.0.0",
"solar-js-sdk": "^0.1.1", "solar-js-sdk": "^0.1.2",
"unified": "^11.0.5", "unified": "^11.0.5",
"zustand": "^5.0.3" "zustand": "^5.0.3"
}, },

View File

@ -8,7 +8,7 @@
"name": "LittleSheep", "name": "LittleSheep",
"email": "littlesheep.code@hotmail.com" "email": "littlesheep.code@hotmail.com"
}, },
"version": "0.1.1", "version": "0.1.2",
"tsup": { "tsup": {
"entry": [ "entry": [
"src/index.ts" "src/index.ts"

View File

@ -15,18 +15,18 @@ function toCamelCase(obj: any): any {
return obj return obj
} }
// function toSnakeCase(obj: any): any { function toSnakeCase(obj: any): any {
// if (Array.isArray(obj)) { if (Array.isArray(obj)) {
// return obj.map(toSnakeCase) return obj.map(toSnakeCase)
// } else if (obj && typeof obj === 'object') { } else if (obj && typeof obj === 'object') {
// return Object.keys(obj).reduce((result: any, key) => { return Object.keys(obj).reduce((result: any, key) => {
// const snakeKey = key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`) const snakeKey = key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`)
// result[snakeKey] = toSnakeCase(obj[key]) result[snakeKey] = toSnakeCase(obj[key])
// return result return result
// }, {}) }, {})
// } }
// return obj return obj
// } }
const baseURL = 'https://api.sn.solsynth.dev' const baseURL = 'https://api.sn.solsynth.dev'
@ -43,6 +43,19 @@ export const sni: AxiosInstance = (() => {
}, },
(error) => error, (error) => error,
) )
/// Case convertor
inst.interceptors.request.use(
(config) => {
if (config.data) {
config.data = toSnakeCase(config.data)
}
return config
},
(error) => Promise.reject(error),
)
inst.interceptors.response.use( inst.interceptors.response.use(
(response) => { (response) => {
if (response.data) { if (response.data) {

View File

@ -12,7 +12,7 @@ export const getServerSideProps: GetServerSideProps = (async (context) => {
return getConsoleStaticProps({ return getConsoleStaticProps({
props: { props: {
title: `Edit Release "${data.name}"`, title: `Edit Release v${data.version}`,
release: data, release: data,
}, },
}) })