2023-11-24 11:02:52 +00:00
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
import applicationApi from '@/api/application'
|
2023-11-29 07:42:48 +00:00
|
|
|
import { type Ref } from 'vue'
|
2023-11-24 11:02:52 +00:00
|
|
|
|
|
|
|
|
const useApplicationStore = defineStore({
|
|
|
|
|
id: 'application',
|
2023-11-29 09:34:45 +00:00
|
|
|
state: () => ({
|
|
|
|
|
location: `${window.location.origin}/ui/chat/`
|
|
|
|
|
}),
|
2023-11-24 11:02:52 +00:00
|
|
|
actions: {
|
|
|
|
|
async asyncGetAllApplication() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
applicationApi
|
|
|
|
|
.getAllAppilcation()
|
|
|
|
|
.then((data) => {
|
|
|
|
|
resolve(data)
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
reject(error)
|
|
|
|
|
})
|
|
|
|
|
})
|
2023-11-29 03:25:14 +00:00
|
|
|
},
|
|
|
|
|
|
2023-11-29 07:42:48 +00:00
|
|
|
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
|
2023-11-29 03:25:14 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
applicationApi
|
2023-11-29 07:42:48 +00:00
|
|
|
.getApplicationDetail(id, loading)
|
2023-11-29 03:25:14 +00:00
|
|
|
.then((data) => {
|
|
|
|
|
resolve(data)
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
reject(error)
|
|
|
|
|
})
|
|
|
|
|
})
|
2023-11-29 09:34:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async asyncGetAccessToken(id: string, loading?: Ref<boolean>) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
applicationApi
|
|
|
|
|
.getAccessToken(id, loading)
|
|
|
|
|
.then((data) => {
|
|
|
|
|
resolve(data)
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
reject(error)
|
|
|
|
|
})
|
|
|
|
|
})
|
2023-11-24 11:02:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default useApplicationStore
|