mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-31 18:22:49 +00:00
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import applicationApi from '@/api/application/application'
|
|
import applicationXpackApi from '@/api/application/application-xpack'
|
|
import { type Ref } from 'vue'
|
|
import useUserStore from './user'
|
|
const useApplicationStore = defineStore('application', {
|
|
state: () => ({
|
|
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
|
|
}),
|
|
actions: {
|
|
|
|
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
|
|
return new Promise((resolve, reject) => {
|
|
applicationApi
|
|
.getApplicationDetail(id, loading)
|
|
.then((data) => {
|
|
resolve(data)
|
|
})
|
|
.catch((error) => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
|
|
async asyncGetAccessToken(id: string, loading?: Ref<boolean>) {
|
|
return new Promise((resolve, reject) => {
|
|
const user = useUserStore()
|
|
// if (user.isEE() || user.isPE()) {
|
|
// applicationXpackApi
|
|
// .getAccessToken(id, loading)
|
|
// .then((data) => {
|
|
// resolve(data)
|
|
// })
|
|
// .catch((error) => {
|
|
// reject(error)
|
|
// })
|
|
// } else {
|
|
applicationApi
|
|
.getAccessToken(id, loading)
|
|
.then((data) => {
|
|
resolve(data)
|
|
})
|
|
.catch((error) => {
|
|
reject(error)
|
|
})
|
|
// }
|
|
})
|
|
},
|
|
|
|
// 修改应用
|
|
async asyncPutApplication(id: string, data: any, loading?: Ref<boolean>) {
|
|
return new Promise((resolve, reject) => {
|
|
applicationApi
|
|
.putApplication(id, data, loading)
|
|
.then((data) => {
|
|
resolve(data)
|
|
})
|
|
.catch((error) => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
})
|
|
|
|
export default useApplicationStore
|