86
86
87
87
<script setup lang="ts">
88
88
import { computed , ref , type Component } from " vue" ;
89
- import semver from " semver" ;
90
89
import HelpPolicy from " ./HelpPolicy.vue" ;
91
90
import LibraryPolicy from " ./LibraryPolicy.vue" ;
92
91
import HowToUse from " ./HowToUse.vue" ;
@@ -97,6 +96,7 @@ import QAndA from "./QAndA.vue";
97
96
import ContactInfo from " ./ContactInfo.vue" ;
98
97
import { UpdateInfo as UpdateInfoObject } from " @/type/preload" ;
99
98
import { useStore } from " @/store" ;
99
+ import { useFetchNewUpdateInfos } from " @/composables/useFetchNewUpdateInfos" ;
100
100
101
101
type PageItem = {
102
102
type: " item" ;
@@ -131,48 +131,7 @@ const store = useStore();
131
131
const updateInfos = ref <UpdateInfoObject []>();
132
132
store .dispatch (" GET_UPDATE_INFOS" ).then ((obj ) => (updateInfos .value = obj ));
133
133
134
- const isCheckingFinished = ref <boolean >(false );
135
-
136
- // 最新版があるか調べる
137
- const currentVersion = ref (" " );
138
- const latestVersion = ref (" " );
139
- window .electron
140
- .getAppInfos ()
141
- .then ((obj ) => {
142
- currentVersion .value = obj .version ;
143
- })
144
- .then (() => {
145
- fetch (" https://api.github.com/repos/VOICEVOX/voicevox/releases" , {
146
- method: " GET" ,
147
- headers: {
148
- " Content-Type" : " application/json" ,
149
- Accept: " application/json" ,
150
- },
151
- })
152
- .then ((response ) => {
153
- if (! response .ok ) throw new Error (" Network response was not ok." );
154
- return response .json ();
155
- })
156
- .then ((json ) => {
157
- const newerVersion = json .find (
158
- (item : { prerelease: boolean ; tag_name: string }) => {
159
- return (
160
- ! item .prerelease &&
161
- semver .valid (currentVersion .value ) &&
162
- semver .valid (item .tag_name ) &&
163
- semver .lt (currentVersion .value , item .tag_name )
164
- );
165
- }
166
- );
167
- if (newerVersion ) {
168
- latestVersion .value = newerVersion .tag_name ;
169
- }
170
- isCheckingFinished .value = true ;
171
- })
172
- .catch ((err ) => {
173
- throw new Error (err );
174
- });
175
- });
134
+ const { isCheckingFinished, latestVersion } = useFetchNewUpdateInfos ();
176
135
177
136
const isUpdateAvailable = computed (() => {
178
137
return isCheckingFinished .value && latestVersion .value !== " " ;
@@ -223,7 +182,7 @@ const pagedata = computed(() => {
223
182
name: " アップデート情報" ,
224
183
component: UpdateInfo ,
225
184
props: {
226
- downloadLink: " https://voicevox.hiroshiba.jp/ " ,
185
+ downloadLink: import . meta . env . VITE_OFFICIAL_WEBSITE_URL ,
227
186
updateInfos: updateInfos .value ,
228
187
isUpdateAvailable: isUpdateAvailable .value ,
229
188
latestVersion: latestVersion .value ,
0 commit comments