ChangelogModal.svelte 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <script lang="ts">
  2. import { onMount, getContext } from 'svelte';
  3. import { Confetti } from 'svelte-confetti';
  4. import { WEBUI_NAME, config, settings } from '$lib/stores';
  5. import { WEBUI_VERSION } from '$lib/constants';
  6. import { getChangelog } from '$lib/apis';
  7. import Modal from './common/Modal.svelte';
  8. import { updateUserSettings } from '$lib/apis/users';
  9. const i18n = getContext('i18n');
  10. export let show = false;
  11. let changelog = null;
  12. onMount(async () => {
  13. const res = await getChangelog();
  14. changelog = res;
  15. });
  16. </script>
  17. <Modal bind:show size="lg">
  18. <div class="px-5 pt-4 dark:text-gray-300 text-gray-700">
  19. <div class="flex justify-between items-start">
  20. <div class="text-xl font-semibold">
  21. {$i18n.t('What’s New in')}
  22. {$WEBUI_NAME}
  23. <Confetti x={[-1, -0.25]} y={[0, 0.5]} />
  24. </div>
  25. <button
  26. class="self-center"
  27. on:click={() => {
  28. localStorage.version = $config.version;
  29. show = false;
  30. }}
  31. >
  32. <svg
  33. xmlns="http://www.w3.org/2000/svg"
  34. viewBox="0 0 20 20"
  35. fill="currentColor"
  36. class="w-5 h-5"
  37. >
  38. <path
  39. 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"
  40. />
  41. </svg>
  42. </button>
  43. </div>
  44. <div class="flex items-center mt-1">
  45. <div class="text-sm dark:text-gray-200">{$i18n.t('Release Notes')}</div>
  46. <div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-200 dark:bg-gray-700" />
  47. <div class="text-sm dark:text-gray-200">
  48. v{WEBUI_VERSION}
  49. </div>
  50. </div>
  51. </div>
  52. <div class=" w-full p-4 px-5 text-gray-700 dark:text-gray-100">
  53. <div class=" overflow-y-scroll max-h-96 scrollbar-hidden">
  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-semibold text-xl mb-1 dark:text-white">
  59. v{version} - {changelog[version].date}
  60. </div>
  61. <hr class="border-gray-100 dark:border-gray-850 my-2" />
  62. {#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
  63. <div class="">
  64. <div
  65. class="font-semibold 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={async () => {
  97. localStorage.version = $config.version;
  98. await settings.set({ ...$settings, ...{ version: $config.version } });
  99. await updateUserSettings(localStorage.token, { ui: $settings });
  100. show = false;
  101. }}
  102. class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
  103. >
  104. <span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
  105. </button>
  106. </div>
  107. </div>
  108. </Modal>