fix(editor): Polyfill crypto.randomUUID (#12052)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-12-05 10:09:36 +01:00 committed by GitHub
parent a16d006f89
commit 0537524c3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
import { useRoute } from 'vue-router';
import { v4 as uuid } from 'uuid';
import LoadingView from '@/views/LoadingView.vue';
import BannerStack from '@/components/banners/BannerStack.vue';
import AskAssistantChat from '@/components/AskAssistant/AskAssistantChat.vue';
@ -17,6 +18,11 @@ import { useSettingsStore } from '@/stores/settings.store';
import { useHistoryHelper } from '@/composables/useHistoryHelper';
import { useStyles } from './composables/useStyles';
// Polyfill crypto.randomUUID
if (!('randomUUID' in crypto)) {
Object.defineProperty(crypto, 'randomUUID', { value: uuid });
}
const route = useRoute();
const rootStore = useRootStore();
const assistantStore = useAssistantStore();

View file

@ -9,7 +9,7 @@ import type { IExecutionFlattedResponse, IExecutionResponse, IRestApiContext } f
const getBrowserId = () => {
let browserId = localStorage.getItem(BROWSER_ID_STORAGE_KEY);
if (!browserId && 'randomUUID' in crypto) {
if (!browserId) {
browserId = crypto.randomUUID();
localStorage.setItem(BROWSER_ID_STORAGE_KEY, browserId);
}