ChangelogModal.svelte 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 pt-4 dark:text-gray-300 text-gray-700">
  18. <div class="flex justify-between items-start">
  19. <div class="text-xl font-semibold">
  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. <div class=" w-full p-4 px-5 text-gray-700 dark:text-gray-100">
  52. <div class=" overflow-y-scroll max-h-80 scrollbar-hidden">
  53. <div class="mb-3">
  54. {#if changelog}
  55. {#each Object.keys(changelog) as version}
  56. <div class=" mb-3 pr-2">
  57. <div class="font-semibold text-xl mb-1 dark:text-white">
  58. v{version} - {changelog[version].date}
  59. </div>
  60. <hr class=" dark:border-gray-800 my-2" />
  61. {#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
  62. <div class="">
  63. <div
  64. class="font-semibold uppercase text-xs {section === 'added'
  65. ? 'text-white bg-blue-600'
  66. : section === 'fixed'
  67. ? 'text-white bg-green-600'
  68. : section === 'changed'
  69. ? 'text-white bg-yellow-600'
  70. : section === 'removed'
  71. ? 'text-white bg-red-600'
  72. : ''} w-fit px-3 rounded-full my-2.5"
  73. >
  74. {section}
  75. </div>
  76. <div class="my-2.5 px-1.5">
  77. {#each Object.keys(changelog[version][section]) as item}
  78. <div class="text-sm mb-2">
  79. <div class="font-semibold uppercase">
  80. {changelog[version][section][item].title}
  81. </div>
  82. <div class="mb-2 mt-1">{changelog[version][section][item].content}</div>
  83. </div>
  84. {/each}
  85. </div>
  86. </div>
  87. {/each}
  88. </div>
  89. {/each}
  90. {/if}
  91. </div>
  92. </div>
  93. <div class="flex justify-end pt-3 text-sm font-medium">
  94. <button
  95. on:click={() => {
  96. localStorage.version = $config.version;
  97. show = false;
  98. }}
  99. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  100. >
  101. <span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
  102. </button>
  103. </div>
  104. </div>
  105. </Modal>