refactor: add application access
This commit is contained in:
parent
ee5c199449
commit
66606bcaec
@ -1,14 +1,14 @@
|
|||||||
import { Result } from '@/request/Result'
|
import {Result} from '@/request/Result'
|
||||||
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
|
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
||||||
import type { pageRequest } from '@/api/type/common'
|
import type {pageRequest} from '@/api/type/common'
|
||||||
import type { ApplicationFormType } from '@/api/type/application'
|
import type {ApplicationFormType} from '@/api/type/application'
|
||||||
import { type Ref } from 'vue'
|
import {type Ref} from 'vue'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
|
|
||||||
const prefix: any = { _value: '/workspace/' }
|
const prefix: any = {_value: '/workspace/'}
|
||||||
Object.defineProperty(prefix, 'value', {
|
Object.defineProperty(prefix, 'value', {
|
||||||
get: function () {
|
get: function () {
|
||||||
const { user } = useStore()
|
const {user} = useStore()
|
||||||
return this._value + user.getWorkspaceId() + '/application'
|
return this._value + user.getWorkspaceId() + '/application'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -187,6 +187,32 @@ const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
|
|||||||
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
|
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
|
||||||
return get(`/chat_user/auth/types`, {}, loading)
|
return get(`/chat_user/auth/types`, {}, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取平台状态
|
||||||
|
*/
|
||||||
|
const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (application_id) => {
|
||||||
|
return get(`${prefix.value}/${application_id}/platform/status`)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 更新平台状态
|
||||||
|
*/
|
||||||
|
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
|
||||||
|
application_id,
|
||||||
|
data
|
||||||
|
) => {
|
||||||
|
return post(`${prefix.value}/${application_id}/platform/status`, data)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取平台配置
|
||||||
|
*/
|
||||||
|
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
|
||||||
|
application_id,
|
||||||
|
type
|
||||||
|
) => {
|
||||||
|
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getAllApplication,
|
getAllApplication,
|
||||||
getApplication,
|
getApplication,
|
||||||
@ -203,4 +229,7 @@ export default {
|
|||||||
chat,
|
chat,
|
||||||
getChatUserAuthType,
|
getChatUserAuthType,
|
||||||
getApplicationSetting,
|
getApplicationSetting,
|
||||||
|
getPlatformStatus,
|
||||||
|
updatePlatformStatus,
|
||||||
|
getPlatformConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,13 +116,13 @@ function refresh() {
|
|||||||
|
|
||||||
function getPlatformStatus() {
|
function getPlatformStatus() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
// applicationApi.getPlatformStatus(id).then((res: any) => {
|
applicationApi.getPlatformStatus(id).then((res: any) => {
|
||||||
// platforms.forEach((platform) => {
|
platforms.forEach((platform) => {
|
||||||
// platform.isActive = res.data[platform.key][1]
|
platform.isActive = res.data[platform.key][1]
|
||||||
// platform.exists = res.data[platform.key][0]
|
platform.exists = res.data[platform.key][0]
|
||||||
// })
|
})
|
||||||
// loading.value = false
|
loading.value = false
|
||||||
// })
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeStatus(type: string, value: boolean) {
|
function changeStatus(type: string, value: boolean) {
|
||||||
|
|||||||
@ -383,16 +383,16 @@ const open = async (id: string, type: PlatformType) => {
|
|||||||
dataLoaded.value = false
|
dataLoaded.value = false
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
try {
|
try {
|
||||||
// const res = await applicationApi.getPlatformConfig(id, type)
|
const res = await applicationApi.getPlatformConfig(id, type)
|
||||||
// if (res.data) {
|
if (res.data) {
|
||||||
// form[configType.value] = res.data
|
form[configType.value] = res.data
|
||||||
// }
|
}
|
||||||
// dataLoaded.value = true
|
dataLoaded.value = true
|
||||||
} catch {
|
} catch {
|
||||||
MsgError(t('views.application.tip.loadingErrorMessage'))
|
MsgError(t('views.application.tip.loadingErrorMessage'))
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
form[configType.value].callback_url = `${window.location.origin}/api/${type}/${id}`
|
form[configType.value].callback_url = `${window.location.origin}/api/chat/${type}/${id}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user