VersionUpdateBadge.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <q-badge v-if="latestVersion
  3. && systemState.systemInfo
  4. &&latestVersion.tag_name !== systemState.systemInfo?.version"
  5. class="cursor-pointer"
  6. label="new"
  7. title="有新的版本更新"
  8. @click="visible = true"
  9. />
  10. <q-dialog v-if="latestVersion" v-model="visible"
  11. max-width="400px"
  12. max-height="400px">
  13. <q-card>
  14. <q-card-section>
  15. <div class="text-h5">{{latestVersion.tag_name}}更新日志</div>
  16. </q-card-section>
  17. <q-separator/>
  18. <q-card-section>
  19. <markdown :source="latestVersion.body" />
  20. </q-card-section>
  21. <q-separator/>
  22. <q-card-section align="right">
  23. <q-btn
  24. color="primary"
  25. @click="navigateToReleasePage"
  26. >
  27. 前往更新
  28. </q-btn>
  29. </q-card-section>
  30. </q-card>
  31. </q-dialog>
  32. </template>
  33. <script setup>
  34. import {onMounted, ref} from 'vue';
  35. import Markdown from 'components/Markdown';
  36. import {systemState} from 'src/store/systemState';
  37. const latestVersion = ref(null);
  38. const visible = ref(false);
  39. const getLatestVersion = async () => {
  40. const data = await fetch('https://api.github.com/repos/allanpk716/chinesesubfinder/releases/latest').then(
  41. (res) => res.json()
  42. );
  43. latestVersion.value = data;
  44. };
  45. const navigateToReleasePage = () => {
  46. window.open(latestVersion.value.html_url);
  47. visible.value = false;
  48. }
  49. onMounted(getLatestVersion);
  50. </script>