refactor: add application access

This commit is contained in:
wxg0103 2025-06-20 17:13:01 +08:00
parent ee5c199449
commit 66606bcaec
3 changed files with 49 additions and 20 deletions

View File

@ -1,14 +1,14 @@
import { Result } from '@/request/Result'
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
import type { pageRequest } from '@/api/type/common'
import type { ApplicationFormType } from '@/api/type/application'
import { type Ref } from 'vue'
import {Result} from '@/request/Result'
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
import type {pageRequest} from '@/api/type/common'
import type {ApplicationFormType} from '@/api/type/application'
import {type Ref} from 'vue'
import useStore from '@/stores'
const prefix: any = { _value: '/workspace/' }
const prefix: any = {_value: '/workspace/'}
Object.defineProperty(prefix, 'value', {
get: function () {
const { user } = useStore()
const {user} = useStore()
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) => {
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 {
getAllApplication,
getApplication,
@ -203,4 +229,7 @@ export default {
chat,
getChatUserAuthType,
getApplicationSetting,
getPlatformStatus,
updatePlatformStatus,
getPlatformConfig
}

View File

@ -116,13 +116,13 @@ function refresh() {
function getPlatformStatus() {
loading.value = true
// applicationApi.getPlatformStatus(id).then((res: any) => {
// platforms.forEach((platform) => {
// platform.isActive = res.data[platform.key][1]
// platform.exists = res.data[platform.key][0]
// })
// loading.value = false
// })
applicationApi.getPlatformStatus(id).then((res: any) => {
platforms.forEach((platform) => {
platform.isActive = res.data[platform.key][1]
platform.exists = res.data[platform.key][0]
})
loading.value = false
})
}
function changeStatus(type: string, value: boolean) {

View File

@ -383,16 +383,16 @@ const open = async (id: string, type: PlatformType) => {
dataLoaded.value = false
formRef.value?.resetFields()
try {
// const res = await applicationApi.getPlatformConfig(id, type)
// if (res.data) {
// form[configType.value] = res.data
// }
// dataLoaded.value = true
const res = await applicationApi.getPlatformConfig(id, type)
if (res.data) {
form[configType.value] = res.data
}
dataLoaded.value = true
} catch {
MsgError(t('views.application.tip.loadingErrorMessage'))
} finally {
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}`
}
}