File tree 4 files changed +19
-12
lines changed
src/shared/lib/use-settings
4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { defineComponent } from "vue";
18
18
import { useNuxtApp } from " #app" ;
19
19
import { LayoutSidebar } from " ~/src/widgets/ui" ;
20
20
import { useEvents } from " ~/src/shared/lib/use-events" ;
21
+ import { useSettings } from " ~/src/shared/lib/use-settings" ;
21
22
import SfdumpWrap from " ~/src/shared/lib/vendor/dumper" ;
22
23
import { useSettingsStore } from " ~/stores/settings" ;
23
24
@@ -31,9 +32,12 @@ export default defineComponent({
31
32
32
33
const settingsStore = useSettingsStore ();
33
34
const { themeType, isFixedHeader } = storeToRefs (settingsStore );
34
- const { $config, $api } = useNuxtApp ();
35
+ const { $config } = useNuxtApp ();
36
+ const {
37
+ api : { getVersion },
38
+ } = useSettings ();
35
39
36
- const apiVersion = await $api . getVersion ();
40
+ const apiVersion = await getVersion ();
37
41
38
42
const { events } = useEvents ();
39
43
Original file line number Diff line number Diff line change @@ -41,9 +41,6 @@ export default defineNuxtConfig({
41
41
} ,
42
42
} ,
43
43
css : [ "~/assets/index.css" ] ,
44
- plugins : [
45
- { src : '~/plugins/api.client.ts' } ,
46
- ] ,
47
44
modules : [
48
45
'@nuxtjs/tailwindcss' ,
49
46
'@pinia/nuxt' ,
Original file line number Diff line number Diff line change
1
+ export * from './use-settings'
Original file line number Diff line number Diff line change 1
- import { REST_API_URL } from "~/src/shared/lib /io" ;
1
+ import { REST_API_URL } from ".. /io" ;
2
2
3
- export default defineNuxtPlugin ( ( ) => {
3
+
4
+ type TUseSettings = {
5
+ api : {
6
+ getVersion : ( ) => Promise < string >
7
+ }
8
+ }
9
+
10
+ export const useSettings = ( ) : TUseSettings => {
4
11
const getAppVersion = ( ) => fetch ( `${ REST_API_URL } /api/version` )
5
12
. then ( ( response ) => response . json ( ) )
6
13
. then ( ( response ) => response ?. version || 'unknown' )
7
14
. catch ( ( ) => 'unknown' ) ;
8
15
9
16
return {
10
- provide : {
11
- api : {
12
- getVersion : getAppVersion ,
13
- }
17
+ api : {
18
+ getVersion : getAppVersion ,
14
19
}
15
20
}
16
- } )
21
+ }
You can’t perform that action at this time.
0 commit comments