-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Hiroshiba <[email protected]>
- Loading branch information
Showing
10 changed files
with
194 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<template> | ||
<q-dialog v-model="modelValueComputed"> | ||
<q-card class="q-py-sm q-px-md"> | ||
<q-card-section class="q-pb-sm" align="center"> | ||
<div class="text-h6"> | ||
<q-icon name="info" color="primary" />アップデート通知 | ||
</div> | ||
</q-card-section> | ||
<q-card-section class="q-pt-sm" align="center"> | ||
<div class="text-body1"> | ||
最新バージョン {{ props.latestVersion }} が利用可能です。<br /> | ||
公式サイトから最新バージョンをダウンロードできます。 | ||
</div> | ||
</q-card-section> | ||
<q-card-section class="q-py-none scrollable-area"> | ||
<template | ||
v-for="(info, infoIndex) of props.newUpdateInfos" | ||
:key="infoIndex" | ||
> | ||
<div class="text-h6">バージョン {{ info.version }}</div> | ||
<ul> | ||
<template | ||
v-for="(item, descriptionIndex) of info.descriptions" | ||
:key="descriptionIndex" | ||
> | ||
<li>{{ item }}</li> | ||
</template> | ||
</ul> | ||
</template> | ||
</q-card-section> | ||
<q-card-actions align="center" class="button-area"> | ||
<q-btn | ||
padding="xs md" | ||
label="キャンセル" | ||
unelevated | ||
color="surface" | ||
text-color="display" | ||
class="q-mt-sm" | ||
@click="closeUpdateNotificationDialog()" | ||
/> | ||
<q-btn | ||
padding="xs md" | ||
label="公式サイトを開く" | ||
unelevated | ||
color="primary" | ||
text-color="display-on-primary" | ||
class="q-mt-sm" | ||
@click=" | ||
openOfficialWebsite(); | ||
closeUpdateNotificationDialog(); | ||
" | ||
/> | ||
</q-card-actions> | ||
</q-card> | ||
</q-dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { UpdateInfo } from "@/type/preload"; | ||
const props = | ||
defineProps<{ | ||
modelValue: boolean; | ||
latestVersion: string; | ||
newUpdateInfos: UpdateInfo[]; | ||
}>(); | ||
const emit = | ||
defineEmits<{ | ||
(e: "update:modelValue", value: boolean): void; | ||
}>(); | ||
const modelValueComputed = computed({ | ||
get: () => props.modelValue, | ||
set: (val) => emit("update:modelValue", val), | ||
}); | ||
const closeUpdateNotificationDialog = () => { | ||
modelValueComputed.value = false; | ||
}; | ||
const openOfficialWebsite = () => { | ||
window.open(import.meta.env.VITE_OFFICIAL_WEBSITE_URL, "_blank"); | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@use '@/styles/colors' as colors; | ||
.scrollable-area { | ||
overflow-y: auto; | ||
max-height: 250px; | ||
} | ||
.scrollable-area h5 { | ||
margin: 10px 0; | ||
} | ||
.scrollable-area h6 { | ||
margin: 15px 0; | ||
} | ||
.button-area { | ||
border-top: 1px solid colors.$splitter; | ||
/* ボタン領域の上部に線を引く */ | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ref } from "vue"; | ||
import semver from "semver"; | ||
import { UpdateInfo } from "@/type/preload"; | ||
|
||
// 最新版があるか調べる | ||
// 現バージョンより新しい最新版があれば`latestVersion`に代入される | ||
export const useFetchNewUpdateInfos = () => { | ||
const isCheckingFinished = ref<boolean>(false); | ||
const currentVersion = ref(""); | ||
const latestVersion = ref(""); | ||
const newUpdateInfos = ref<UpdateInfo[]>([]); | ||
|
||
window.electron | ||
.getAppInfos() | ||
.then((obj) => { | ||
currentVersion.value = obj.version; | ||
}) | ||
.then(() => { | ||
const url: string | undefined = import.meta.env | ||
.VITE_LATEST_UPDATE_INFOS_URL; | ||
if (!url) { | ||
throw new Error( | ||
"VITE_LATEST_UPDATE_INFOS_URLが未設定です。.env内に記載してください。" | ||
); | ||
} | ||
fetch(url) | ||
.then((response) => { | ||
if (!response.ok) throw new Error("Network response was not ok."); | ||
return response.json(); | ||
}) | ||
.then((json) => { | ||
newUpdateInfos.value = json.filter((item: UpdateInfo) => { | ||
return semver.lt(currentVersion.value, item.version); | ||
}); | ||
if (newUpdateInfos.value?.length) { | ||
latestVersion.value = newUpdateInfos.value[0].version; | ||
} | ||
isCheckingFinished.value = true; | ||
}); | ||
}); | ||
|
||
return { | ||
isCheckingFinished, | ||
latestVersion, | ||
newUpdateInfos, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters