7
7
<v-icon color =" currentColor" :icon =" mdiClose" @click =" show = false" />
8
8
</v-card-title >
9
9
<v-container >
10
+ <v-row align =" center" >
11
+ <v-col >
12
+ <div >FUNC Version</div >
13
+ <div class =" text-caption text-grey" >
14
+ {{ appVersion }}
15
+ {{ !store.funcUpdateAvailable ? "(latest)" : "" }}
16
+ </div >
17
+ </v-col >
18
+ <v-col class =" text-right" >
19
+ <v-btn
20
+ :color =" url ? 'warning' : ''"
21
+ variant =" tonal"
22
+ :disabled =" !url"
23
+ :href =" url"
24
+ >
25
+ Download
26
+ <v-tooltip
27
+ activator =" parent"
28
+ location =" left"
29
+ :text =" `Download ${funcLatest}`"
30
+ />
31
+ </v-btn >
32
+ </v-col >
33
+ </v-row >
10
34
<v-row align =" center" >
11
35
<v-col >
12
36
<div >Node Version</div >
13
37
<div class =" text-caption text-grey" >
14
38
{{ store.goalVersion?.installed }}
39
+ {{ !store.nodeUpdateAvailable ? "(latest)" : "" }}
15
40
</div >
16
41
</v-col >
17
42
<v-col class =" text-right" >
18
43
<v-btn
19
- :color =" store.updateAvailable ? 'warning' : ''"
44
+ :color =" store.nodeUpdateAvailable ? 'warning' : ''"
20
45
variant =" tonal"
21
- :disabled =" !store.updateAvailable || store.downloading"
22
- @click =" updateLatest ()"
46
+ :disabled =" !store.nodeUpdateAvailable || store.downloading"
47
+ @click =" updateNodeLatest ()"
23
48
>
24
49
Update
25
50
<v-tooltip
28
53
:text =" `Update to ${store.goalVersion?.latest}`"
29
54
/>
30
55
</v-btn >
31
- <Releases class =" ml-2" @release =" updateRelease" />
32
56
</v-col >
33
57
</v-row >
34
58
<v-row align =" center" >
@@ -72,28 +96,39 @@ const show = computed({
72
96
},
73
97
});
74
98
99
+ const appVersion = __APP_VERSION__ ;
100
+ const funcLatest = ref ();
101
+ const url = ref ();
75
102
let init = false ;
76
103
77
- onBeforeMount (() => {
104
+ onBeforeMount (async () => {
78
105
if (activeNetwork .value !== " mainnet" ) setShowNetworks (true );
79
- getVersion ();
106
+ await getVersion ();
107
+ if (store .funcUpdateAvailable ) {
108
+ url .value = (await FUNC .api .get (" func/latest" )).data ;
109
+ }
80
110
});
81
111
82
112
async function getVersion() {
83
113
try {
84
- const version = await FUNC .api .get (" goal/version" );
85
- store .goalVersion = version .data ;
114
+ const func = await axios ({
115
+ url: " https://api.github.com/repos/GalaxyPay/func/releases/latest" ,
116
+ });
117
+ funcLatest .value = func .data ?.name .slice (1 );
118
+ store .funcUpdateAvailable = funcLatest .value !== appVersion ;
119
+ const goalVersion = await FUNC .api .get (" goal/version" );
120
+ store .goalVersion = goalVersion .data ;
86
121
if (store .goalVersion ?.installed ) store .ready = true ;
87
122
else {
88
123
if (! init ) {
89
124
init = true ;
90
- updateLatest (true );
125
+ updateNodeLatest (true );
91
126
} else {
92
127
throw Error (" Download Failed" );
93
128
}
94
129
}
95
130
96
- store .updateAvailable =
131
+ store .nodeUpdateAvailable =
97
132
!! store .goalVersion ?.latest &&
98
133
store .goalVersion ?.latest !== store .goalVersion ?.installed ;
99
134
} catch (err : any ) {
@@ -102,16 +137,16 @@ async function getVersion() {
102
137
}
103
138
}
104
139
105
- async function updateLatest (bypass = false ) {
140
+ async function updateNodeLatest (bypass = false ) {
106
141
if (
107
142
! bypass &&
108
143
! confirm (" Are you sure you want to update your node to the latest version?" )
109
144
)
110
145
return ;
111
- await updateRelease (" latest" );
146
+ await updateNode (" latest" );
112
147
}
113
148
114
- async function updateRelease (release : string ) {
149
+ async function updateNode (release : string ) {
115
150
try {
116
151
store .downloading = true ;
117
152
store .stopNodeServices = true ;
0 commit comments