ChangelogModal.svelte 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <script lang="ts">
  2. import { onMount, getContext } from 'svelte';
  3. import { Confetti } from 'svelte-confetti';
  4. import { WEBUI_NAME, config } from '$lib/stores';
  5. import { WEBUI_VERSION } from '$lib/constants';
  6. import { getChangelog } from '$lib/apis';
  7. import Modal from './common/Modal.svelte';
  8. const i18n = getContext('i18n');
  9. export let show = false;
  10. let changelog = null;
  11. onMount(async () => {
  12. const res = await getChangelog();
  13. changelog = res;
  14. });
  15. </script>
  16. <Modal bind:show>
  17. <div class="px-5 py-4 dark:text-gray-300">
  18. <div class="flex justify-between items-start">
  19. <div class="text-xl font-bold">
  20. {$i18n.t('What’s New in')}
  21. {$WEBUI_NAME}
  22. <Confetti x={[-1, -0.25]} y={[0, 0.5]} />
  23. </div>
  24. <button
  25. class="self-center"
  26. on:click={() => {
  27. localStorage.version = $config.version;
  28. show = false;
  29. }}
  30. >
  31. <svg
  32. xmlns="http://www.w3.org/2000/svg"
  33. viewBox="0 0 20 20"
  34. fill="currentColor"
  35. class="w-5 h-5"
  36. >
  37. <path
  38. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  39. />
  40. </svg>
  41. </button>
  42. </div>
  43. <div class="flex items-center mt-1">
  44. <div class="text-sm dark:text-gray-200">{$i18n.t('Release Notes')}</div>
  45. <div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-200 dark:bg-gray-700" />
  46. <div class="text-sm dark:text-gray-200">
  47. v{WEBUI_VERSION}
  48. </div>
  49. </div>
  50. </div>
  51. <hr class=" dark:border-gray-800" />
  52. <div class=" w-full p-4 px-5">
  53. <div class=" overflow-y-scroll max-h-80">
  54. <div class="mb-3">
  55. {#if changelog}
  56. {#each Object.keys(changelog) as version}
  57. <div class=" mb-3 pr-2">
  58. <div class="font-bold text-xl mb-1 dark:text-white">
  59. v{version} - {changelog[version].date}
  60. </div>
  61. <hr class=" dark:border-gray-800 my-2" />
  62. {#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
  63. <div class="">
  64. <div
  65. class="font-bold uppercase text-xs {section === 'added'
  66. ? 'text-white bg-blue-600'
  67. : section === 'fixed'
  68. ? 'text-white bg-green-600'
  69. : section === 'changed'
  70. ? 'text-white bg-yellow-600'
  71. : section === 'removed'
  72. ? 'text-white bg-red-600'
  73. : ''} w-fit px-3 rounded-full my-2.5"
  74. >
  75. {section}
  76. </div>
  77. <div class="my-2.5 px-1.5">
  78. {#each Object.keys(changelog[version][section]) as item}
  79. <div class="text-sm mb-2">
  80. <div class="font-semibold uppercase">
  81. {changelog[version][section][item].title}
  82. </div>
  83. <div class="mb-2 mt-1">{changelog[version][section][item].content}</div>
  84. </div>
  85. {/each}
  86. </div>
  87. </div>
  88. {/each}
  89. </div>
  90. {/each}
  91. {/if}
  92. </div>
  93. </div>
  94. <div class="flex justify-end pt-3 text-sm font-medium">
  95. <button
  96. on:click={() => {
  97. localStorage.version = $config.version;
  98. show = false;
  99. }}
  100. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  101. >
  102. <span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
  103. </button>
  104. </div>
  105. </div>
  106. </Modal>