55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
import {isArr} from "licia";
|
|
|
|
const information = {
|
|
debug: true,
|
|
baseUrl: 'http://localhost:8080',
|
|
}
|
|
|
|
export function amisRender(target, amisJson) {
|
|
let amisJsonObject = amisJson(information)
|
|
if (information.debug) {
|
|
console.log(amisJsonObject)
|
|
}
|
|
amisRequire('amis/embed').embed(
|
|
target,
|
|
amisJsonObject,
|
|
information,
|
|
{
|
|
theme: 'antd',
|
|
enableAMISDebug: information.debug,
|
|
},
|
|
)
|
|
}
|
|
|
|
function parseEdges(edges) {
|
|
if (isArr(edges)) {
|
|
|
|
}
|
|
}
|
|
|
|
export function amisElideGraphQLAdaptor(payload, response, api, context) {
|
|
// console.log(payload, response, api, context)
|
|
let result = []
|
|
console.log(payload)
|
|
if (payload.data) {
|
|
let items = payload.data[Object.keys(payload.data)[0]]['edges']
|
|
for (let item of items) {
|
|
result.push(item.node)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
export function amisElideJsonapiAdaptor(payload, response, api, context) {
|
|
let result = []
|
|
if (payload.data && isArr(payload.data)) {
|
|
for (let item of payload.data) {
|
|
result.push({
|
|
...item,
|
|
...item['attributes'],
|
|
})
|
|
}
|
|
}
|
|
return result
|
|
}
|