Skip to content

Commit 66606bc

Browse files
committed
refactor: add application access
1 parent ee5c199 commit 66606bc

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

ui/src/api/application/application.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Result } from '@/request/Result'
2-
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
3-
import type { pageRequest } from '@/api/type/common'
4-
import type { ApplicationFormType } from '@/api/type/application'
5-
import { type Ref } from 'vue'
1+
import {Result} from '@/request/Result'
2+
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
3+
import type {pageRequest} from '@/api/type/common'
4+
import type {ApplicationFormType} from '@/api/type/application'
5+
import {type Ref} from 'vue'
66
import useStore from '@/stores'
77

8-
const prefix: any = { _value: '/workspace/' }
8+
const prefix: any = {_value: '/workspace/'}
99
Object.defineProperty(prefix, 'value', {
1010
get: function () {
11-
const { user } = useStore()
11+
const {user} = useStore()
1212
return this._value + user.getWorkspaceId() + '/application'
1313
},
1414
})
@@ -187,6 +187,32 @@ const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
187187
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
188188
return get(`/chat_user/auth/types`, {}, loading)
189189
}
190+
191+
/**
192+
* 获取平台状态
193+
*/
194+
const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (application_id) => {
195+
return get(`${prefix.value}/${application_id}/platform/status`)
196+
}
197+
/**
198+
* 更新平台状态
199+
*/
200+
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
201+
application_id,
202+
data
203+
) => {
204+
return post(`${prefix.value}/${application_id}/platform/status`, data)
205+
}
206+
/**
207+
* 获取平台配置
208+
*/
209+
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
210+
application_id,
211+
type
212+
) => {
213+
return get(`${prefix.value}/${application_id}/platform/${type}`)
214+
}
215+
190216
export default {
191217
getAllApplication,
192218
getApplication,
@@ -203,4 +229,7 @@ export default {
203229
chat,
204230
getChatUserAuthType,
205231
getApplicationSetting,
232+
getPlatformStatus,
233+
updatePlatformStatus,
234+
getPlatformConfig
206235
}

ui/src/views/application/ApplicationAccess.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ function refresh() {
116116
117117
function getPlatformStatus() {
118118
loading.value = true
119-
// applicationApi.getPlatformStatus(id).then((res: any) => {
120-
// platforms.forEach((platform) => {
121-
// platform.isActive = res.data[platform.key][1]
122-
// platform.exists = res.data[platform.key][0]
123-
// })
124-
// loading.value = false
125-
// })
119+
applicationApi.getPlatformStatus(id).then((res: any) => {
120+
platforms.forEach((platform) => {
121+
platform.isActive = res.data[platform.key][1]
122+
platform.exists = res.data[platform.key][0]
123+
})
124+
loading.value = false
125+
})
126126
}
127127
128128
function changeStatus(type: string, value: boolean) {

ui/src/views/application/component/AccessSettingDrawer.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,16 @@ const open = async (id: string, type: PlatformType) => {
383383
dataLoaded.value = false
384384
formRef.value?.resetFields()
385385
try {
386-
// const res = await applicationApi.getPlatformConfig(id, type)
387-
// if (res.data) {
388-
// form[configType.value] = res.data
389-
// }
390-
// dataLoaded.value = true
386+
const res = await applicationApi.getPlatformConfig(id, type)
387+
if (res.data) {
388+
form[configType.value] = res.data
389+
}
390+
dataLoaded.value = true
391391
} catch {
392392
MsgError(t('views.application.tip.loadingErrorMessage'))
393393
} finally {
394394
loading.value = false
395-
form[configType.value].callback_url = `${window.location.origin}/api/${type}/${id}`
395+
form[configType.value].callback_url = `${window.location.origin}/api/chat/${type}/${id}`
396396
}
397397
}
398398

0 commit comments

Comments
 (0)