@@ -3,9 +3,15 @@ import { get, post, postStream, del, put, request, download, exportFile } from '
33import type { pageRequest } from '@/api/type/common'
44import type { ApplicationFormType } from '@/api/type/application'
55import { type Ref } from 'vue'
6+ import useStore from '@/stores'
67
7- const prefix = '/workspace/' + localStorage . getItem ( 'workspace_id' ) + '/application'
8-
8+ const prefix : any = { _value : '/workspace/' }
9+ Object . defineProperty ( prefix , 'value' , {
10+ get : function ( ) {
11+ const { user } = useStore ( )
12+ return this . _value + user . getWorkspaceId ( ) + '/application'
13+ } ,
14+ } )
915/**
1016 * 获取全部应用
1117 * @param 参数
@@ -14,7 +20,7 @@ const getAllApplication: (param?: any, loading?: Ref<boolean>) => Promise<Result
1420 param ,
1521 loading ,
1622) => {
17- return get ( `${ prefix } ` , param , loading )
23+ return get ( `${ prefix . value } ` , param , loading )
1824}
1925
2026/**
@@ -28,7 +34,7 @@ const getApplication: (
2834 param : any ,
2935 loading ?: Ref < boolean > ,
3036) => Promise < Result < any > > = ( page , param , loading ) => {
31- return get ( `${ prefix } /${ page . current_page } /${ page . page_size } ` , param , loading )
37+ return get ( `${ prefix . value } /${ page . current_page } /${ page . page_size } ` , param , loading )
3238}
3339
3440/**
@@ -39,7 +45,7 @@ const postApplication: (
3945 data : ApplicationFormType ,
4046 loading ?: Ref < boolean > ,
4147) => Promise < Result < any > > = ( data , loading ) => {
42- return post ( `${ prefix } ` , data , undefined , loading )
48+ return post ( `${ prefix . value } ` , data , undefined , loading )
4349}
4450
4551/**
@@ -51,7 +57,7 @@ const putApplication: (
5157 data : ApplicationFormType ,
5258 loading ?: Ref < boolean > ,
5359) => Promise < Result < any > > = ( application_id , data , loading ) => {
54- return put ( `${ prefix } /${ application_id } ` , data , undefined , loading )
60+ return put ( `${ prefix . value } /${ application_id } ` , data , undefined , loading )
5561}
5662
5763/**
@@ -62,7 +68,7 @@ const delApplication: (
6268 application_id : string ,
6369 loading ?: Ref < boolean > ,
6470) => Promise < Result < boolean > > = ( application_id , loading ) => {
65- return del ( `${ prefix } /${ application_id } ` , undefined , { } , loading )
71+ return del ( `${ prefix . value } /${ application_id } ` , undefined , { } , loading )
6672}
6773
6874/**
@@ -73,7 +79,7 @@ const getApplicationDetail: (
7379 application_id : string ,
7480 loading ?: Ref < boolean > ,
7581) => Promise < Result < any > > = ( application_id , loading ) => {
76- return get ( `${ prefix } /${ application_id } ` , undefined , loading )
82+ return get ( `${ prefix . value } /${ application_id } ` , undefined , loading )
7783}
7884
7985/**
@@ -84,7 +90,7 @@ const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promis
8490 application_id ,
8591 loading ,
8692) => {
87- return get ( `${ prefix } /${ application_id } /access_token` , undefined , loading )
93+ return get ( `${ prefix . value } /${ application_id } /access_token` , undefined , loading )
8894}
8995
9096/**
@@ -99,7 +105,7 @@ const putAccessToken: (
99105 data : any ,
100106 loading ?: Ref < boolean > ,
101107) => Promise < Result < any > > = ( application_id , data , loading ) => {
102- return put ( `${ prefix } /${ application_id } /access_token` , data , undefined , loading )
108+ return put ( `${ prefix . value } /${ application_id } /access_token` , data , undefined , loading )
103109}
104110
105111/**
@@ -113,7 +119,7 @@ const exportApplication = (
113119) => {
114120 return exportFile (
115121 application_name + '.mk' ,
116- `${ prefix } /${ application_id } /export` ,
122+ `${ prefix . value } /${ application_id } /export` ,
117123 undefined ,
118124 loading ,
119125 )
@@ -126,7 +132,7 @@ const importApplication: (data: any, loading?: Ref<boolean>) => Promise<Result<a
126132 data ,
127133 loading ,
128134) => {
129- return post ( `${ prefix } /import` , data , undefined , loading )
135+ return post ( `${ prefix . value } /import` , data , undefined , loading )
130136}
131137
132138/**
@@ -138,7 +144,7 @@ const getStatistics: (
138144 data : any ,
139145 loading ?: Ref < boolean > ,
140146) => Promise < Result < any > > = ( application_id , data , loading ) => {
141- return get ( `${ prefix } /${ application_id } /application_stats` , data , loading )
147+ return get ( `${ prefix . value } /${ application_id } /application_stats` , data , loading )
142148}
143149/**
144150 * 打开调试对话id
@@ -150,7 +156,7 @@ const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<s
150156 application_id ,
151157 loading ,
152158) => {
153- return get ( `${ prefix } /${ application_id } /open` , { } , loading )
159+ return get ( `${ prefix . value } /${ application_id } /open` , { } , loading )
154160}
155161/**
156162 * 对话
0 commit comments