Skip to content

Commit 6f8c94e

Browse files
committed
feat: Fixed JSON Parse
1 parent 187cf0a commit 6f8c94e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { PluginSetting } from '@opentiny/tiny-engine-common'
3030
import { Collapse, CollapseItem } from '@opentiny/vue'
3131
import { constants } from '@opentiny/tiny-engine-utils'
3232
33-
const { DEFAULT_INTERCEPTOR, DEFAULT_PROXY } = constants
33+
const { DEFAULT_INTERCEPTOR } = constants
3434
3535
const isOpen = ref(false)
3636
@@ -68,7 +68,7 @@ export default {
6868
`
6969
})
7070
const state = reactive({
71-
proxy: JSON.stringify(proxy, null, 2),
71+
proxy: JSON.stringify(proxy || DEFAULT_PROXY, null, 2),
7272
willFetchValue: willFetch?.value,
7373
dataHandlerValue: dataHandler?.value,
7474
errorHandlerValue: errorHandler?.value
@@ -78,7 +78,7 @@ export default {
7878
const id = getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id
7979
8080
const handler = {
81-
proxy: JSON.parse(state.proxy || DEFAULT_PROXY),
81+
proxy: JSON.parse(state.proxy || JSON.stringify(DEFAULT_PROXY)),
8282
willFetch: { type: 'JSFunction', value: state.willFetchValue || DEFAULT_INTERCEPTOR.willFetch.value },
8383
dataHandler: {
8484
type: 'JSFunction',
@@ -89,7 +89,7 @@ export default {
8989
9090
requestGlobalDataHandler(id, { data_source_global: handler }).then((data) => {
9191
if (data) {
92-
useResource().appSchemaState.proxy = JSON.parse(state.proxy || '{}')
92+
useResource().appSchemaState.proxy = JSON.parse(state.proxy || JSON.stringify(DEFAULT_PROXY))
9393
useResource().appSchemaState.willFetch = { type: 'JSFunction', value: state.willFetchValue }
9494
useResource().appSchemaState.dataHandler = { type: 'JSFunction', value: state.dataHandlerValue }
9595
useResource().appSchemaState.errorHandler = { type: 'JSFunction', value: state.errorHandlerValue }

0 commit comments

Comments
 (0)