feat: continue CreatorHub plan01 implementation
This commit is contained in:
+32
-1
@@ -42,6 +42,15 @@ const resourcePaths = {
|
||||
attempts: '/phase-a/attempts',
|
||||
audit: '/phase-a/audit',
|
||||
'network-exits': '/network-exits',
|
||||
'creator-accounts': '/creator/accounts',
|
||||
'creator-competitors': '/creator/competitors',
|
||||
'creator-works': '/creator/works',
|
||||
'creator-comments': '/creator/comments',
|
||||
'creator-leads': '/creator/leads',
|
||||
'creator-rules': '/creator/rules',
|
||||
'creator-operations': '/creator/operations',
|
||||
'creator-conversations': '/creator/conversations',
|
||||
'creator-events': '/creator/events',
|
||||
}
|
||||
|
||||
const withID = (record, fallback) => ({ ...record, id: record.id ?? record.alias ?? record.version ?? record.name ?? fallback })
|
||||
@@ -69,7 +78,7 @@ export const dataProvider = {
|
||||
},
|
||||
async getOne({ resource, id }) {
|
||||
const path = resourcePaths[resource]
|
||||
if (!path || !['accounts', 'network-exits', 'browsers', 'drafts', 'confirmations', 'tasks', 'attempts'].includes(resource)) return unsupported(resource, 'getOne')
|
||||
if (!path || !['accounts', 'network-exits', 'browsers', 'drafts', 'confirmations', 'tasks', 'attempts', 'creator-accounts', 'creator-competitors', 'creator-works', 'creator-comments', 'creator-rules', 'creator-operations'].includes(resource)) return unsupported(resource, 'getOne')
|
||||
const record = await request(`${path}/${encodeURIComponent(id)}`)
|
||||
return { data: withID(record, id) }
|
||||
},
|
||||
@@ -138,11 +147,33 @@ export const dataProvider = {
|
||||
if (action !== 'check' && action !== 'disable') throw new Error(`未知网络出口操作: ${action}`)
|
||||
return request(`/network-exits/${encodeURIComponent(id)}/${action}`, { method: 'POST' })
|
||||
},
|
||||
creatorRequest(path, options) {
|
||||
return request(path, options)
|
||||
},
|
||||
creatorAction(path, data) {
|
||||
return request(path, data === undefined ? { method: 'POST' } : jsonOptions('POST', data))
|
||||
},
|
||||
creatorCreate(path, data) {
|
||||
return request(path, jsonOptions('POST', data))
|
||||
},
|
||||
creatorGet(path) {
|
||||
return request(path)
|
||||
},
|
||||
creatorUpdate(path, data) {
|
||||
return request(path, jsonOptions('PUT', data))
|
||||
},
|
||||
}
|
||||
|
||||
function filterKeys(resource) {
|
||||
return {
|
||||
drafts: ['account_id'], confirmations: ['draft_id'], tasks: ['account_id', 'draft_id', 'state'],
|
||||
audit: ['account_id', 'task_id', 'attempt_id', 'browser_env_alias', 'network_exit_id', 'event_type', 'from', 'to'],
|
||||
'creator-competitors': ['platform'],
|
||||
'creator-works': ['platform', 'source_id', 'source_type', 'published_after', 'published_before', 'min_likes', 'min_comments', 'min_shares'],
|
||||
'creator-comments': ['platform', 'work_id'],
|
||||
'creator-leads': ['platform'],
|
||||
'creator-operations': ['account_id'],
|
||||
'creator-conversations': ['account_id'],
|
||||
'creator-events': ['account_id'],
|
||||
}[resource] || []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user