feat(web): add pinia/vue-flow deps and update API layer
This commit is contained in:
@@ -1,13 +1,25 @@
|
||||
import client from './client'
|
||||
|
||||
export function login(data: { tenantCode: string; username: string; password: string }) {
|
||||
return client.post('/api/v1/account/login', data)
|
||||
}
|
||||
|
||||
export function createTenant(data: { tenantCode: string; tenantName: string }) {
|
||||
return client.post('/api/v1/account/tenant', data)
|
||||
}
|
||||
|
||||
export function listTenants() {
|
||||
return client.get('/api/v1/account/tenant/list')
|
||||
}
|
||||
|
||||
export function createUser(data: { username: string; password: string; realName?: string }) {
|
||||
return client.post('/api/v1/account/user', data)
|
||||
}
|
||||
|
||||
export function login(data: { tenantCode: string; username: string; password: string }) {
|
||||
return client.post('/api/v1/account/login', data)
|
||||
export function listUsers() {
|
||||
return client.get('/api/v1/account/user/list')
|
||||
}
|
||||
|
||||
export function me() {
|
||||
return client.get('/api/v1/account/me')
|
||||
}
|
||||
|
||||
@@ -4,14 +4,30 @@ export function createChannelSubject(data: any) {
|
||||
return client.post('/api/v1/channel-subject', data)
|
||||
}
|
||||
|
||||
export function listChannelSubjects() {
|
||||
return client.get('/api/v1/channel-subject/list')
|
||||
}
|
||||
|
||||
export function createChannelAccount(data: any) {
|
||||
return client.post('/api/v1/channel-account', data)
|
||||
}
|
||||
|
||||
export function listChannelAccounts() {
|
||||
return client.get('/api/v1/channel-account/list')
|
||||
}
|
||||
|
||||
export function initChannelAccount(data: any) {
|
||||
return client.post('/api/v1/channel-account/init', data)
|
||||
}
|
||||
|
||||
export function createConversation(data: any) {
|
||||
return client.post('/api/v1/conversation', data)
|
||||
}
|
||||
|
||||
export function listConversations() {
|
||||
return client.get('/api/v1/conversation/list')
|
||||
}
|
||||
|
||||
export function bindConversationAccount(conversationId: number, data: any) {
|
||||
return client.post(`/api/v1/conversation/${conversationId}/bind-account`, data)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ const client = axios.create({
|
||||
})
|
||||
|
||||
client.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('mci-token')
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
const tenantCode = localStorage.getItem('mci-tenant-code') || 'default'
|
||||
config.headers['X-Tenant-Code'] = tenantCode
|
||||
return config
|
||||
@@ -17,6 +21,11 @@ client.interceptors.request.use((config) => {
|
||||
client.interceptors.response.use(
|
||||
(response) => response.data,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.clear()
|
||||
window.location.href = '/login'
|
||||
return Promise.reject(error)
|
||||
}
|
||||
const message = error.response?.data?.message || error.message || '请求失败'
|
||||
return Promise.reject(new Error(message))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ export function createPerson(data: any) {
|
||||
return client.post('/api/v1/person', data)
|
||||
}
|
||||
|
||||
export function listPersons() {
|
||||
return client.get('/api/v1/person/list')
|
||||
}
|
||||
|
||||
export function listTags() {
|
||||
return client.get('/api/v1/tag/list')
|
||||
}
|
||||
|
||||
5
admin-web/src/api/dashboard.ts
Normal file
5
admin-web/src/api/dashboard.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import client from './client'
|
||||
|
||||
export function getDashboardStats() {
|
||||
return client.get('/api/v1/dashboard/stats')
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import client from './client'
|
||||
|
||||
export function createFlowDefinition(data: any) {
|
||||
return client.post('/api/v1/flow/definition', data)
|
||||
return client.post('/api/v1/inbound/flow', data)
|
||||
}
|
||||
|
||||
export function listFlowDefinitions() {
|
||||
return client.get('/api/v1/flow/definition/list')
|
||||
return client.get('/api/v1/inbound/flow/list')
|
||||
}
|
||||
|
||||
9
admin-web/src/api/inbound.ts
Normal file
9
admin-web/src/api/inbound.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import client from './client'
|
||||
|
||||
export function receiveMessage(data: any) {
|
||||
return client.post('/api/v1/inbound/receive', data)
|
||||
}
|
||||
|
||||
export function getFlowTraces(eventId: string) {
|
||||
return client.get(`/api/v1/inbound/${eventId}/trace`)
|
||||
}
|
||||
@@ -8,6 +8,9 @@ export function testSendMessage(data: any) {
|
||||
return client.post('/api/v1/send/test', data)
|
||||
}
|
||||
|
||||
export function listSendRecords(taskId: string) {
|
||||
return client.get(`/api/v1/send/${taskId}/records`)
|
||||
export function listSendRecords(taskId?: string) {
|
||||
if (taskId) {
|
||||
return client.get(`/api/v1/send/${taskId}/records`)
|
||||
}
|
||||
return client.get('/api/v1/send/list')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user