mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:02:46 +00:00
refactor: add application access
This commit is contained in:
parent
ee5c199449
commit
66606bcaec
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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}`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue